Add GPS, IMU, and barometer sensor suite to BLE bridge firmware

RYS352A GPS on UART2 (GPIO5/6) with PPS interrupt (GPIO7),
MPU-9250 IMU and BMP388 barometer on shared I2C bus (GPIO8/9).
Sensor data exposed via dedicated BLE service with binary
notify characteristics alongside the existing NUS serial bridge.
Sensors degrade gracefully if not wired.
This commit is contained in:
Ryan Malloy 2026-02-11 15:47:20 -07:00
parent e05edb92a0
commit f218cd468b
4 changed files with 384 additions and 25 deletions

View file

@ -15,6 +15,7 @@ with optional IMU and barometric sensors for orientation and refraction correcti
**Sensors (optional):**
- 1× GY-9250 (MPU-9250) — 9-axis IMU (accelerometer + gyroscope + magnetometer)
- 1× BMP388 — barometric pressure + temperature
- 1× RYS352A GPS module — observer location + PPS timing
## Schematic
@ -204,14 +205,50 @@ Where R is refraction in arcminutes, el is apparent elevation in degrees,
P is pressure in hPa, T is temperature in °C. At el=15°, P=1013, T=20°C:
R ≈ 3.4 arcmin ≈ 0.057°. Small but meaningful for narrow-beam antennas.
## GPS — RYS352A
The RYS352A is a compact GPS module with PPS output. It connects via UART2 and
provides observer location for satellite pass prediction and a 1Hz PPS pulse
for precise UTC time synchronization.
```
ESP32 GPIO5 (UART2 RX) ◄── RYS352A TX (NMEA sentences out)
ESP32 GPIO6 (UART2 TX) ──► RYS352A RX (config commands in, optional)
ESP32 GPIO7 ◄── RYS352A PPS (1Hz rising edge, ~100ns jitter)
ESP32 3V3 ──► RYS352A VCC
ESP32 GND ──► RYS352A GND
```
| Module Pin | ESP32 Pin | Function |
|------------|-----------|----------|
| VCC | 3V3 | 3.3V power (onboard LDO on most breakouts) |
| GND | GND | Ground |
| TX | GPIO5 (UART2 RX) | NMEA sentence output at 9600 baud |
| RX | GPIO6 (UART2 TX) | UBX/NMEA config input (optional) |
| PPS | GPIO7 | 1Hz pulse synchronized to GPS time |
**PPS (Pulse Per Second):** The RYS352A outputs a precise 1Hz pulse on the
rising edge, synchronized to UTC via GPS constellation. The firmware captures
this edge via interrupt (`micros()` timestamp) for correlating satellite events
with sub-microsecond precision relative to the GPS epoch. The module's RTC
battery backup enables warm starts (~5s) after initial cold start fix (~30-60s).
**UART notes:** The RYS352A defaults to 9600 baud NMEA output. The TX line
(GPIO6) is optional — only needed if you want to send UBX configuration
commands to change update rate, constellation selection, or enable additional
NMEA sentences. The firmware uses TinyGPS++ to parse standard GGA/RMC sentences.
## Full GPIO Map
| GPIO | Function | Interface | Notes |
|------|----------|-----------|-------|
| 17 | RS-422 TX | UART1 TX | → Level shifter → MAX485₁ DI |
| 18 | RS-422 RX | UART1 RX | ← Level shifter ← MAX485₂ RO |
| 5 | GPS RX | UART2 RX | ← RYS352A TX (NMEA out) |
| 6 | GPS TX | UART2 TX | → RYS352A RX (config in) |
| 7 | GPS PPS | GPIO interrupt | 1Hz rising edge |
| 8 | I2C SDA | I2C | MPU-9250 + BMP388 (shared bus) |
| 9 | I2C SCL | I2C | MPU-9250 + BMP388 (shared bus) |
| 17 | RS-422 TX | UART1 TX | → Level shifter → MAX485₁ DI |
| 18 | RS-422 RX | UART1 RX | ← Level shifter ← MAX485₂ RO |
| 38 | RGB LED | WS2812 | Onboard NeoPixel (DevKitC V1.1) |
| 43 | USB Console TX | UART0 | CH343 USB-serial (untouched) |
| 44 | USB Console RX | UART0 | CH343 USB-serial (untouched) |