I am using nRF52832 DK, with SES as IDE on Ubuntu-16.04 OS PC. I want to stream some data from PC to DK. The DK is connected to PC for power supply and programming the chip. So I thought of using a USB to UART converter and connect USB to PC and UART pins to DK. I looked at /examples/peripheral/uart example. I want to print the data in debug terminal, to verify that the data received is correct. How do I do that? Does this sound like a good approach to send data from PC to DK? I want to stream data for quite long time(for an hour or so). Can someone help me with this?
Thanks, Sai Kiran.
The Segger chip on the nRF52 DK already includes UART to USB serial bridge (Virtual COM port) which you can use. The serial port should show up as ttyACMx (where x = port number) in /dev/ when you connect the DK to your PC.
Note: the serial port usually requires root permissions by default. You can change that by installing this package: https://github.com/NordicSemiconductor/nrf-udev
There are no permission issues. I have written a python script to send data through serial port. Here is the Python Code.
ser = serial.Serial('/dev/ttyACM0', 115200) # open serial port
print(ser.name) # check which port was really used
ser.write(b'Hello') # write a string
On the DK, I am using UART example, found in <SDK_Root>/examples/peripheral/uart/pca10040/blank/ses. I want to see the text "hello" on debug terminal. So, here is the corresponding code for that(am not sure if this is the correct approach).
main.c file: -
const app_uart_comm_params_t comm_params =
#if defined (UART_PRESENT)
//printf("\r\nUART example started.\r\n");
NRF_LOG_INFO("UART example started");
while (app_uart_get(&cr) != NRF_SUCCESS);
while (app_uart_put(cr) != NRF_SUCCESS);
/* Custom code START */
/* Custom code START */
if (cr == 'q' || cr == 'Q')
// Do nothing.
I just added NRF_LOG_INFO(cr) line, to the available example. When I run the code, I do not see any message in Debug terminal. I am able to see hello message in Putty however.
I don't think it's possible to connect the Debug terminal in SES to a "COM" port. We only use it for RTT logging.
// Config settings to enable RTT logging
SO does this mean that I will be able to see UART messages only using RTT. I have checked sdk_config.h. NRF_LOG_BACKEND_RTT_ENABLED option is not there. Should I add it to use RTT?
Most examples support logging over both UART and RTT, but not all. Maybe the UART/Serial Port Emulation over BLE example in \examples\ble_peripheral\ble_app_uart would be a better starting point for you.
I tried using BLE_APP_UART example. When I run the python code to transmit the data via USB, the DK encounters an error. If the python code is halted, the code just runs fine, without any errors, but there is no information from the system. Any idea what's going on here?
Were you able to view the RTT logs in the debug terminal now? The log should include more information if the program crashed.