Example Code for Raspberry pi(UART)-High Precision Positioning
Last revision 2025/12/11
This article offers a comprehensive guide on utilizing Raspberry Pi in UART mode for high-precision positioning via RTK technology. It details hardware setup, software requirements, and step-by-step programming instructions, making it an invaluable resource for hobbyists and tech enthusiasts seeking to enhance their project accuracy.
Hardware preparation
- Raspberry Pi 4B
- DFR0566 Raspberry Pi 4B/3B+ IO Expansion Board
- RTK High-Precision Positioning Kit-4G
Software Preparation
- Raspberry Pi Imager
- [DFRobot_RTK_4G](- DFRobot_RTK_4G)
- CORS Account (Choose an appropriate platform as needed)
UART Tutorial
Wiring Diagram
| Raspberry pi | PIN | GNSS-RTK | PIN |
|---|---|---|---|
| Raspberry pi | + | GNSS-RTK | VCC(RED) |
| Raspberry pi | - | GNSS-RTK | GND(BLACK) |
| Raspberry pi | T | GNSS-RTK | RX(GREEN) |
| Raspberry pi | R | GNSS-RTK | TX(BLUE) |
Change to UART Mode
- Create directory and get library file
command1: cd ~
command2: cd Desktop
command3: mkdir df
- Create folder
command: cd df
- Switch to folder
command: git clone https://github.com/DFRobot/DFRobot_RTK_4G.git
- Get library file
command: cd DFRobot_RTK_4G/python/raspberrypi/examples
- Switch to example file
command: sudo vi get_gnss_4g.py # Edit the file to change mode

Move the hardware DIP switch to the UART mode. Note: When toggling the DIP switch, the device is powered on. Please power cycle the device after switching for the change to take effect.
command: sudo python3 get_gnss_4g.py
Was this article helpful?
