This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

UART Connection NRF52832 with Raspberry Pi

I am trying to transferAdvertisement data from NRF52832 to Raspberry PI using BLE_app_UART example. I have updated the config as below,

app_uart_comm_params_t const comm_params =
{
.rx_pin_no = 3,
.tx_pin_no = 2,
.rts_pin_no = 17,
.cts_pin_no = 18,
.flow_control = APP_UART_FLOW_CONTROL_DISABLED,
.use_parity = false,
.baud_rate = UART_BAUDRATE_BAUDRATE_Baud115200
};

I have wired as below

NRF52832  ------   Raspberry Pi

rx_pin_no 3 ----- GPIO14(UART_TXD0)

tx_pin_no 2 ----- GPIO15(UART_RXD0)

rts_pin_no 17 ------- GPIO 16
cts_pin_no 18 ------  GPIO 17

GND  ----- GND

After this connection if I run the below Python code in Raspberry PI, I am getting invalid characters printed and reading after 1 byte getting error as 'Serial port is not ready'.

import serial
from time import sleep

ser = serial.Serial ("/dev/ttyS0", 115200)    #Open port with baud rate
while True:
    received_data = ser.read()              #read serial port
    sleep(0.03)
    data_left = ser.inWaiting()             #check for remaining byte
    received_data += ser.read(data_left)
    print (received_data)                   #print received data
    

Please help if have missed any thing in the connection between Raspberry and NRF52832 or config.

Parents
  • Why did you configure and connect RTS/CTS while you are not using it?

        .flow_control = APP_UART_FLOW_CONTROL_DISABLED

  • I have taken the same BLE_app_UART example code as it is , just I have hard coded pin numbers.

    app_uart_comm_params_t const comm_params =
        {
            .rx_pin_no    = RX_PIN_NUMBER,
            .tx_pin_no    = TX_PIN_NUMBER,
            .rts_pin_no   = RTS_PIN_NUMBER,
            .cts_pin_no   = CTS_PIN_NUMBER,
            .flow_control = APP_UART_FLOW_CONTROL_DISABLED,
            .use_parity   = false,
            .baud_rate    = UART_BAUDRATE_BAUDRATE_Baud115200
        };

    In Python ser.read() working one time and printing values, for the next cycle showing 'raise portNotOpenError'.

    If I change to ser.readline(), I am getting 32 data values from Adv report. and next cycle showing 'raise portNotOpenError'.

    I am not able to find out config.h associated with this project. 

Reply
  • I have taken the same BLE_app_UART example code as it is , just I have hard coded pin numbers.

    app_uart_comm_params_t const comm_params =
        {
            .rx_pin_no    = RX_PIN_NUMBER,
            .tx_pin_no    = TX_PIN_NUMBER,
            .rts_pin_no   = RTS_PIN_NUMBER,
            .cts_pin_no   = CTS_PIN_NUMBER,
            .flow_control = APP_UART_FLOW_CONTROL_DISABLED,
            .use_parity   = false,
            .baud_rate    = UART_BAUDRATE_BAUDRATE_Baud115200
        };

    In Python ser.read() working one time and printing values, for the next cycle showing 'raise portNotOpenError'.

    If I change to ser.readline(), I am getting 32 data values from Adv report. and next cycle showing 'raise portNotOpenError'.

    I am not able to find out config.h associated with this project. 

Children
No Data
Related