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.
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
- 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
- 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)
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) |
- PlatformIO - Development platform
- M5Unified - M5Stack unified library
- Arduino framework for ESP32
- PlatformIO IDE
- Visual Studio Code with PlatformIO extension
git clone https://github.com/michalpelka/M5NtripClient.git
cd M5NtripClientCreate a secrets header file with your WiFi and NTRIP credentials:
cp include/Secrets/secrets.h.template include/Secrets/secrets.hEdit 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
}You need to configure your u-blox ZED-F9R receiver using u-center software:
- 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
- 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
Using PlatformIO CLI:
pio run --target uploadOr use the PlatformIO IDE interface to build and upload.
- 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
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
Double click red button on the side of M5Stack.
Connect to serial monitor at 115200 baud to see debug information:
pio device monitor- Verify SSID and password in
secrets.h - Check WiFi signal strength
- Ensure 2.4GHz WiFi network (ESP32 doesn't support 5GHz)
- 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
- 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)
- Verify wiring between M5Stack and ZED-F9R
- Check baudrate configuration (115200)
- Ensure ZED-F9R is configured to output GGA on UART2
- Check power supply (USB or battery)
- Monitor serial output for error messages
- Verify all connections are secure
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
- FreeRTOS Tasks:
lcdUpdateTask: Updates display every secondggaReadTask: Reads GGA sentences from GPShealthCheckTask: Monitors connection health
- Main Loop: Handles NTRIP data reception and GGA transmission
Contributions are welcome! Please feel free to submit issues or pull requests.
This project is licensed under the GNU General Public License v2.0 - see the LICENSE file for details.
- 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
MichaΕ PeΕka - michalpelka