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 Reply
  • Thanks Jorgen, I have removed RTS and CTS and updated my Python code as below, now UART is working fine.

    thanks for your great support.

    def Uart_Serial_Read():
      try:  
        ser = serial.Serial ("/dev/serial0")
        ser.baudrate = 115200
        print ("Serial com program start here..")
        i=1
        while True:
                   data = ser.readline()
                   l=len(data)
                   print "Length: ", l," Itration : ",i
                   for j in range(0, l-1):
                                      print(ord(data[j:j+1])),
                   print ""
                   i=i+1
        ser.close()
       except:
        Uart_Serial_Read() 
    import serial
    Uart_Serial_Read()

Children
Related