# Using RTT viewer and Uart to send ESP8266 AT commands [closed]

Hello , I am using sdk12.2 and pca10028. I have implemented rtt viewer so that I dont need uart to debug or to print something. I am using uart to send AT commands to esp8266. I have tested individually and my uart code can send AT commands and I am getting response back. Now I am combining this code with ble_app_uart_c(central ) for scanning nearby ble devices.

scan function - New Text Document (3).txt.

Uart_loopback_test - New Text Document (3).txt

Uart_terminal - uart_terminal.PNG

RTT_Terminal - rtt_terminal.PNG

main.c - New Text Document (3).txt

Thanks, Shailav

edit retag reopen delete

### Closed as "the question is answered, right answer was accepted" by Newbie at 2017-07-21 07:36:57 +0200

Have you tried to debug to figure out why your scanning stops? Do you get an error somewhere that resets the device? This might give some insight.

( 2017-07-18 10:56:57 +0200 )editconvert to answer

Hi Peter, I figured out the challenge. I am actually trying to scan the nearby ble devices using the code ble_app_uart_c . Now I want to send this data through esp8266 using at commands. Now unfortunately nrf51822 has only 1 uart so I am using rtt viewer to see the data of scan devices. So the left uart I am using now to send AT commands to esp8266. Now my challenge is when I am using the function of uart in function of scan response is attached in question above. I am not getting output as expected. Although I am successful in sending data through uart to Esp8266 wifi module. For your reference I am attaching the uart code for esp8266 above in question. Please suggest me changes. Thanks, Shailav

( 2017-07-18 12:23:07 +0200 )editconvert to answer

Ok. So what do you get? Have you tried to debug? Have you checked if you get any errors?

( 2017-07-18 13:39:09 +0200 )editconvert to answer

Hi, I am not getting errors. I am attaching screenshot of the function and output from uart as well as rtt viewer above in question. My function call uart_loopback_test() is not getting executed when I am calling this in case BLE_GAP_EVT_ADV_REPORT: I want to send the mac address, rssi and UUId via esp8266 to server. Thanks, Shailav

( 2017-07-19 10:24:57 +0200 )editconvert to answer

Maybe this is happening because you are calling it from interrupt context? Does it work if you set a flag when you get the BLE_GAPEVT_ADV_REPORT and call uart_loopback_test() from main instead? Or you could try to increase the interrupt priority of the uart?

( 2017-07-19 10:28:47 +0200 )editconvert to answer

Hi, Can you please show me code snippet to implement your suggestions? Thanks, Shailav

( 2017-07-19 10:32:30 +0200 )editconvert to answer

bool flag = 0;
on_ble_evt()
{
flag = 1;
}

main()
{
for
{
if(flag==1)
{
flag = 0;
uart_loopback_test();
}
power_manage();
}
}


The interrupt priority can be changed in sdk_config.h, try setting UART_DEFAULT_CONFIG_IRQ_PRIORITY 1

( 2017-07-19 12:36:58 +0200 )editconvert to answer

Hi, My main challenge is I want to pass the parameters like

        for (uint32_t i = 0; i < 40; i++)
{
while (app_uart_put(tx_DATA[i]) != NRF_SUCCESS);
}
nrf_delay_ms(10000);


So how should I implement this? Thats why I was trying to call uart_loopback_test in BLE_GAP_EVT_ADV_REPORT. Thanks,

( 2017-07-19 13:46:56 +0200 )editconvert to answer

Can't you just copy the address to a global array?

( 2017-07-19 14:06:25 +0200 )editconvert to answer

Hi, I can copy that.I have 2 functions in my main loop: uart_loopback_test(); scan_start(); So when the scan_start(); my code starts scanning nearby devices and it never returns to main function again. So I was trying to call uart_loopback_test(); in BLE_GAPEVT_ADV_REPORT. But unfortunately my uart_loopback_test is not working in BLE_GAPEVT_ADV_REPORT function. I am attaching my main file in question above. Please suggest me changes. Thanks

( 2017-07-19 14:47:26 +0200 )editconvert to answer

( 2017-07-19 15:26:30 +0200 )editconvert to answer

Hi, I want to scan 1 device UUID and want to send that to Webserver using Esp8266. Then again I want scan other device UUID and want to send that data to webserver. So Scanning should be continuous to detect new devices. Thanks,

( 2017-07-19 15:31:19 +0200 )editconvert to answer

I'm not suggesting this to be your final product, I'm trying to suggest something that will solve the problem you are having. To figure out why it is not working. Can you please try stop scanning and see if you are able to return to main(), and then call uart_loopback_test() from there? Or try to increase the UART priority to 1? Or try to disable the uart interrupt so that it will poll the register instead? Or you can upload your complete project so I can test it here.

( 2017-07-19 15:53:28 +0200 )editconvert to answer

Hi, I have set priority to 1. I am attaching my project.

Thanks, Shailav

( 2017-07-19 16:10:31 +0200 )editconvert to answer

Why not just use an ESP32 for both Wifi and BLE ?

( 2017-07-20 09:47:18 +0200 )editconvert to answer
1

What if you change APP_IRQ_PRIORITY_LOWEST to APP_IRQ_PRIORITY_HIGHEST when you call APP_UART_FIFO_INIT inside uart_init()?

( 2017-07-20 11:24:37 +0200 )editconvert to answer

Hi Petter, I changed to APP_IRQ_PRIORITY_HIGHEST. But I can see something working. I will try the code again and will let you know. Thanks, Shailav

( 2017-07-20 12:17:46 +0200 )editconvert to answer

I have tried. It works here. It is sending data over the UART. Can I ask why you have those 10 second delays in your code?

( 2017-07-20 12:33:54 +0200 )editconvert to answer

Its a random delay I kept so that I can properly get the response from back from ESP8266. Is that effecting my code? Should I remove?

( 2017-07-20 12:36:27 +0200 )editconvert to answer

I don't see how random delay would help? And it isn't random is it?

( 2017-07-20 12:47:50 +0200 )editconvert to answer

Yeah it is not helping. I will remove the delay. I will let you know about the progress.

( 2017-07-20 12:59:40 +0200 )editconvert to answer

Hi Peter, Its working now. Thanks for all the support.

( 2017-07-20 14:59:46 +0200 )editconvert to answer

What did the trick?

( 2017-07-20 15:49:24 +0200 )editconvert to answer

Sort by » oldest newest most voted

Changing APP_IRQ_PRIORITY_HIGHEST worked for me and the rest was working fine. Thanks, Shailav

more

## Recent blog posts

• ### 6 Things to Know about Bluetooth Beacons

Posted 2017-09-22 08:27:00 by Rose Martin
• ### Creating a Keil project for a Bluetooth Mesh example

Posted 2017-09-19 12:08:11 by Kristian Skordal
• ### Using millis() like in Arduino.

Posted 2017-09-18 11:58:04 by schef
• ### Flashing nRF5x firmware using any dumb terminal program via standard serial COM port

Posted 2017-09-18 03:53:40 by Nguyen Hoan Hoang
• ### How to Debug the nRF52 Interrupts — Useful Tips

Posted 2017-09-13 15:15:22 by Yaniv Nis

## Recent questions

• ### Any nRF52840 examples for BLE Mesh?

Posted 2017-09-24 17:06:24 by aszka
• ### Can not find Nordic dongle from my application

Posted 2017-09-24 14:23:37 by ofer
• ### Can’t program BT832 Module using NRF52-DK

Posted 2017-09-24 10:47:56 by Alexey
• ### Is there any Dc offset on nRF52840 RF port ?

Posted 2017-09-24 09:43:40 by Artak
• ### buttonless dfu in sdk 14

Posted 2017-09-24 07:43:16 by Stas