M5NtripClient
December 28, 2025 Β· View on GitHub
A portable NTRIP (Networked Transport of RTCM via Internet Protocol) client for M5Stack devices that receives RTK correction data from NTRIP casters and forwards it to u-blox GNSS receivers for high-precision positioning.
Overview
This project turns your M5Stack into a standalone NTRIP client that:
- Connects to WiFi networks
- Authenticates with NTRIP casters to receive RTCM correction data
- Forwards RTCM data to u-blox GNSS receivers via serial connection
- Sends GGA NMEA sentences back to the caster for accurate corrections
- Displays real-time status information on the M5Stack screen
- Provides a portable, battery-powered RTK solution
Features
- Auto-reconnection: Automatically reconnects to NTRIP server if connection is lost
- Real-time Display: Shows WiFi status, NTRIP connection, data rate, GPS quality
- GGA Feedback: Sends NMEA GGA sentences to caster every 5 seconds for optimal corrections
- Multi-tasking: Uses FreeRTOS tasks for concurrent operations
- Health Monitoring: Detects connection issues and automatically attempts recovery
- GPS Quality Indicators: Color-coded display showing fix quality (Invalid/GPS/DGPS/RTK Float/RTK Fixed)
- Button Controls: Power off and manual reconnection via physical buttons
- Data Statistics: Real-time RTCM data rate and total data received
Hardware Requirements
Bill of Materials (BOM)
- M5Stack Core 1 - ESP32-based development kit with display
- u-blox ZED-F9R - Multi-band GNSS receiver with RTK support
- Optional: Battery pack for M5Stack (for portable operation)
Wiring Diagram
Connect the M5Stack to the ZED-F9R as follows:
| M5Stack Pin | ZED-F9R Pin | Description |
|---|---|---|
| 5V | 5V | Power supply |
| GND | GND | Ground |
| GPIO 16 | TXO2 | Serial receive (UART2 TX from GPS) |
| GPIO 17 | RXD2 | Serial transmit (UART2 RX to GPS) |
Software Requirements
Dependencies
- PlatformIO - Development platform
- M5Unified - M5Stack unified library
- Arduino framework for ESP32
Compatible Platforms
- PlatformIO IDE
- Visual Studio Code with PlatformIO extension
Installation
1. Clone the Repository
git clone https://github.com/michalpelka/M5NtripClient.git
cd M5NtripClient
2. Configure Secrets
Create a secrets header file with your WiFi and NTRIP credentials:
cp include/Secrets/secrets.h.template include/Secrets/secrets.h
Edit include/Secrets/secrets.h with your actual credentials:
namespace secrets {
const char* SSID = "your_wifi_ssid"; // Your WiFi network name
const char* PASSWORD = "your_wifi_password"; // Your WiFi password
const char* NTRIP_HOST = "ntrip.example.com"; // NTRIP caster hostname
const uint16_t NTRIP_PORT = 2101; // NTRIP caster port (typically 2101)
const char* NTRIP_MOUNTPOINT = "MOUNTPOINT"; // Your NTRIP mountpoint
const char* NTRIP_USERNAME = "username"; // NTRIP username
const char* NTRIP_PASSWORD = "password"; // NTRIP password
}
3. Configure u-blox Receiver
You need to configure your u-blox ZED-F9R receiver using u-center software:
Required Settings:
- Accept RTCM corrections on UART2 (RXD2)
- Output only GGA NMEA sentences on UART2 (TXD2)
- Set UART2 baudrate to 115200
A pre-configured settings file is provided: p9r+m5stack.ucf
To apply settings in u-center:
- Connect ZED-F9R to your computer via USB
- Open u-center software
- Load the configuration file:
Tools > Receiver Configuration > Load Configurationβ selectp9r+m5stack.ucf - Transfer to receiver:
Tools > Receiver Configuration > Transfer file > GPS - Save to BBR/Flash:
View > Configuration View > CFG > Save current configuration
4. Build and Upload
Using PlatformIO CLI:
pio run --target upload
Or use the PlatformIO IDE interface to build and upload.
Usage
Starting the Device
- Power on your M5Stack
- The device will:
- Connect to WiFi (displays connection status)
- Connect to NTRIP caster
- Authenticate with the caster
- Begin receiving and forwarding RTCM data
Display Information
The M5Stack display shows:
- IP Address: Current WiFi IP
- WiFi RSSI: Signal strength in dBm
- RTCM Data Rate: Current data rate in bytes/second
- Total Data: Cumulative data received in KB
- NTRIP Status: Connected (green) or disconnected (red) with retry count
- GGA Quality: GPS fix quality with color coding:
- π΄ Red (0): Invalid/No fix
- π‘ Yellow (1): GPS fix
- π΅ Cyan (2): DGPS fix
- π’ Green (5): RTK Float
- π’ Green-Yellow (4): RTK Fixed
- GGA Sentence: Current NMEA GGA sentence from receiver
Power off
Double click red button on the side of M5Stack.
Serial Monitor
Connect to serial monitor at 115200 baud to see debug information:
pio device monitor
Troubleshooting
Cannot Connect to WiFi
- Verify SSID and password in
secrets.h - Check WiFi signal strength
- Ensure 2.4GHz WiFi network (ESP32 doesn't support 5GHz)
Cannot Connect to NTRIP Server
- Verify NTRIP host, port, and credentials in
secrets.h - Check that mountpoint exists and is accessible
- Verify internet connectivity
- Some NTRIP services require valid subscription
No RTK Fix
- Ensure ZED-F9R has clear view of sky
- Verify RTCM data is being received (check data rate on display)
- Confirm GGA sentences are being sent to caster
- Check that mountpoint provides corrections for your location
- RTK requires time to converge (typically 30 seconds to several minutes)
No Data Displayed
- Verify wiring between M5Stack and ZED-F9R
- Check baudrate configuration (115200)
- Ensure ZED-F9R is configured to output GGA on UART2
Device Restarts/Crashes
- Check power supply (USB or battery)
- Monitor serial output for error messages
- Verify all connections are secure
Development
Project Structure
M5NtripClient/
βββ src/
β βββ main.cpp # Main application logic
β βββ ntrip.cpp # NTRIP client implementation
β βββ base64.cpp # Base64 encoding for authentication
βββ include/
β βββ ntrip.h # NTRIP client header
β βββ base64.h # Base64 encoding header
β βββ Secrets/
β βββ secrets.h.template # Template for credentials
βββ platformio.ini # PlatformIO configuration
βββ p9r+m5stack.ucf # u-blox receiver configuration
Key Components
- FreeRTOS Tasks:
lcdUpdateTask: Updates display every secondggaReadTask: Reads GGA sentences from GPShealthCheckTask: Monitors connection health
- Main Loop: Handles NTRIP data reception and GGA transmission
Contributing
Contributions are welcome! Please feel free to submit issues or pull requests.
License
This project is licensed under the GNU General Public License v2.0 - see the LICENSE file for details.
Acknowledgments
- Built with M5Unified library
- Uses PlatformIO development platform
- Implements NTRIP protocol for RTK corrections (custom implementation following NTRIP v1.0 specification)
- Utilizes Base64.c library
Author
MichaΕ PeΕka - michalpelka