Lost + Found ATGM336H GPS+BDS Dual-Mode Receiver driver library for Raspberry Pi Pico C SDK
- C 93.5%
- Python 4.1%
- CMake 2.4%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
| include | ||
| src | ||
| CMakeLists.txt | ||
| conanfile.py | ||
| README.md | ||
lf-atgm336h
Reusable ATGM336H GPS+BDS Dual-Mode GNSS receiver driver library for the Raspberry Pi Pico / Pico 2 C SDK, packaged as a Conan package.
This is part of the Lost + Found suite of projects.
🛠️ Usage with CMake
Copy the driver directory into your project as a subdirectory:
add_subdirectory(lib/lf-atgm336h)
target_link_libraries(your_project PRIVATE
lf-atgm336h
)
And in your C/C++ code:
#include "lf_atgm336h.h"
🔌 Hardware Setup
Connect the ATGM336H GPS+BDS module to your Raspberry Pi Pico/Pico 2:
- Pico GP0 (TX) <-> Breakout RXD
- Pico GP1 (RX) <-> Breakout TXD
- Pico GP2 <-> Breakout PPS (Pulse Per Second timing pin)
- Pico GND <-> Breakout GND
- Pico 3V3 OUT <-> Breakout VCC
(Note: Pins and UART hardware instance can be configured during context initialization).
💡 Example
#include <stdio.h>
#include "pico/stdlib.h"
#include "lf_atgm336h.h"
int main() {
stdio_init_all();
sleep_ms(2000);
lf_atgm336h_t gps;
// Initialize the module on UART0, GP0 (TX), GP1 (RX), and GP2 (PPS)
if (!lf_atgm336h_init(&gps, uart0, 9600, 0, 1, 2)) {
printf("Failed to initialize ATGM336H driver!\n");
return -1;
}
printf("ATGM336H Driver Initialized successfully.\n");
// Configure the module update frequency to 5Hz and disable GSV sentences using CASIC command
// (Note: lf_atgm336h_send_command automatically calculates and appends NMEA XOR checksums)
lf_atgm336h_send_command(&gps, "PCAS02,200"); // 200ms interval = 5Hz
lf_atgm336h_send_command(&gps, "PCAS03,0,0,0,0,0,0,0,0,0"); // Disable verbose GSV/GSA sentences
while (true) {
// Asynchronously check for PPS pulses
uint64_t last_pulse;
uint32_t count;
if (lf_atgm336h_get_pps(&gps, &last_pulse, &count)) {
printf("[PPS] Pulse #%u triggered at %llu us\n", count, last_pulse);
}
// Call update frequently to process serial buffers
if (lf_atgm336h_update(&gps)) {
if (lf_atgm336h_has_fix(&gps)) {
float lat, lon;
int h, m, day, month, year;
float s;
lf_atgm336h_get_position(&gps, &lat, &lon);
lf_atgm336h_get_time(&gps, &h, &m, &s);
lf_atgm336h_get_date(&gps, &day, &month, &year);
printf("[FIX] UTC: %02d:%02d:%05.2f | Date: %02d/%02d/%04d | Lat: %.6f, Lon: %.6f\n",
h, m, s, day, month, year, lat, lon);
} else {
printf("[NO FIX] Satellites scanning...\n");
}
}
tight_loop_contents();
}
}