µFR Nano UART on Raspberry Pi 3
View Categories

µFR Nano UART on Raspberry Pi 3

Required Configuration for UART on Raspberry Pi 3B #

This guide provides the steps for configuring UART on a Raspberry Pi 3B to connect µFR Nano UART or µFR Nano RS232 devices via GPIO. It covers configuration settings, pin assignments, and a Python script for testing communication and reset functionality.


1. Raspberry Pi Configuration (raspi-config) #

  1. Open the Raspberry Pi configuration tool:
    sudo raspi-config
  2. Navigate to:
    Interfacing Options > Serial
  3. Respond to the following prompts:
    • “Would you like a login shell to be accessible over serial?” – Select No
    • “Would you like the serial port hardware to be enabled?” – Select Yes
  4. Verify the configuration message states:
    The serial login shell is disabled
    The serial interface is enabled

2. Configuring UART over GPIO #

Modify /boot/firmware/config.txt #

Ensure the following lines are included in the config.txt file:

[all]
enable_uart=1
dtoverlay=pi3-miniuart-bt
  • This assigns the main UART (/dev/ttyAMA0) to GPIO pins.
  • Bluetooth is reassigned to the mini UART (/dev/ttyS0).

Modify /boot/firmware/cmdline.txt #

Remove any console=serial0,115200 (or similar) entry from cmdline.txt to prevent interference with UART communication.

The modified cmdline.txt should look like this (as a single line):

console=tty1 root=PARTUUID=xxxxx-xx rootfstype=ext4 fsck.repair=yes rootwait

3. Enabling RTS/CTS Control via Software #

  1. Clone the repository to enable RTS/CTS control:
    git clone https://github.com/mholling/rpirtscts
  2. Run the following command to enable RTS/CTS:
    sudo ./rpirtscts on
  3. Verify the RTS/CTS configuration on GPIO pins 16 and 17:
    sudo raspi-gpio get | grep -E "14|15|16|17"

    Sample Output:

    GPIO 14: level=1 alt=0 func=TXD0
    GPIO 15: level=1 alt=0 func=RXD0
    GPIO 16: level=0 alt=3 func=CTS0
    GPIO 17: level=0 alt=3 func=RTS0

4. Pinout: µFR Nano UART/RS232 to Raspberry Pi GPIO #

µFR Pin Raspberry Pi GPIO Function
Pin 1 GPIO 2 (5V) Power Supply
Pin 2 (TX) GPIO 15 (RXD) Receive
Pin 3 (RX) GPIO 14 (TXD) Transmit
Pin 4 (Reset) GPIO 17 (RTS) Reset Control (RTS)
Pin 5 (Ground) GPIO 6 Ground

5. Example Python Script for Testing Communication and Reset #

This Python script tests the reset functionality. When reset, the device should send the byte sequence 0x03, 0x55, 0x55, 0xBB via UART.

import serial
import time

Create a serial connection:

ser = serial.Serial( port=’/dev/ttyAMA0′, baudrate=115200, parity=serial.PARITY_NONE, stopbits=serial.STOPBITS_ONE, bytesize=serial.EIGHTBITS, timeout=0.33, rtscts=True )

Use the following code to test the RTS functionality:

`try:
while True:
print("Set RTS to LOW")
ser.setRTS(False) # Clear RTS (set it low)
time.sleep(1) # Wait before setting it back high

ser = serial.Serial(port='/dev/ttyAMA0',
baudrate=115200,
parity=serial.PARITY_NONE,
stopbits=serial.STOPBITS_ONE,
bytesize=serial.EIGHTBITS,
timeout=0.33,
rtscts=True)

try:
while True:
print("Set RTS to LOW")
s = ser.readline()
print(s)

123456789 ser.setRTS(False) # Clear RTS (set it low) time.sleep(1) # Wait before setting it back high print("Set RTS to HIGH") ser.setRTS(True) # Set RTS high s = ser.readline() print(s) time.sleep(1) # Wait before clearing it again

except KeyboardInterrupt:
print("Exiting...")

finally:
ser.close() # Ensure the serial connection is closed


6. Useful Links #


This guide ensures proper UART setup on Raspberry Pi 3B for both µFR Nano UART and µFR Nano RS232 devices, enabling reliable communication via GPIO. For further assistance, please refer to the provided links or contact our support team.