A01NYUB Ultrasonic Distance Sensor on Raspberry Pi 5 Without Expansion Board
Donald.Jenkins 2026-09-21 15:39:19 43 Views2 Replies Hi everyone,
I’m trying to connect the DFRobot A01NYUB ultrasonic distance sensor (SEN0313) directly to a Raspberry Pi 5, without using the DFRobot IO Expansion Board.
The A01NYUB communicates through UART at 9600 bps and supports an operating voltage of 3.3–5V. DFRobot provides Raspberry Pi example code, but their official example appears to be written around the IO Expansion Board.
My main questions are:
Can the A01NYUB be connected directly to the Pi 5 GPIO UART pins?Which GPIO pins should be used for TX/RX?Is powering the sensor from the Pi's 3.3V pin sufficient?Do I need a voltage divider or logic-level shifter between the sensor TX and the Pi RX?Has anyone successfully used the A01NYUB on a Pi 5 without an expansion board?Are there any differences in UART configuration on the Pi 5 that I should be aware of?
I found a community project specifically for using the A01NYUB directly with the Raspberry Pi via UART, so I'm interested in hearing from anyone who has tried this approach:
That’s a helpful explanation, especially the GPIO14/15 wiring and the note about disabling the serial console.
stephen.hanks Yes, you can run the A01NYUB straight off the Pi 5 GPIO pins - no expansion board needed.
Wiring: sensor TXD → Pi TXD (GPIO14), sensor RXD → Pi RXD (GPIO15). Power it from the Pi's 3.3V pin - that also locks the logic level to 3.3V, so you don't need a level shifter or divider (the sensor runs 3.3-5V, but on 3.3V everything stays 3.3V-safe).
Two Pi 5 things to check:
Open the serial port: sudo raspi-config → Interface Options → Serial Port → disable the login shell over serial, enable the serial hardware. Otherwise /dev/ttyAMA0 is held by the system console.Set the baud to 9600: stty -F /dev/ttyAMA0 9600. Then reading it is just opening that port.The official Pi example is tied to the IO Expansion Board, but the raw UART protocol is the same - Pi 5 GPIO14/15 still work with serial0. For a plug-and-play skip-the-code option the IO Expansion Board is handy, but for raw UART your direct approach is fine.
Jason.Miao 
