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:
parent
e05edb92a0
commit
f218cd468b
4 changed files with 384 additions and 25 deletions
|
|
@ -2,8 +2,23 @@
|
|||
|
||||
// --- GPIO Pin Assignments ---
|
||||
// UART1 to RS-422 module via 3.3V<->5V level shifter
|
||||
#define PIN_RS422_TX 17 // ESP32 TX -> level shifter -> MAX490 RXD
|
||||
#define PIN_RS422_RX 18 // MAX490 TXD -> level shifter -> ESP32 RX
|
||||
#define PIN_RS422_TX 17 // ESP32 TX -> level shifter -> MAX485₁ DI
|
||||
#define PIN_RS422_RX 18 // MAX485₂ RO -> level shifter -> ESP32 RX
|
||||
|
||||
// GPS UART (UART2) — RYS352A
|
||||
#define PIN_GPS_RX 5 // ESP32 RX <- GPS TX (NMEA out)
|
||||
#define PIN_GPS_TX 6 // ESP32 TX -> GPS RX (config in, optional)
|
||||
#define PIN_GPS_PPS 7 // 1Hz PPS rising edge (interrupt)
|
||||
#define GPS_BAUD 9600
|
||||
|
||||
// I2C Sensor Bus
|
||||
#define PIN_I2C_SDA 8
|
||||
#define PIN_I2C_SCL 9
|
||||
#define I2C_FREQ 400000 // 400kHz
|
||||
|
||||
// Sensor I2C addresses
|
||||
#define MPU9250_ADDR 0x68
|
||||
#define BMP388_ADDR 0x76
|
||||
|
||||
// Onboard RGB LED (WS2812, DevKitC-1 V1.1)
|
||||
#define PIN_LED 38
|
||||
|
|
@ -23,6 +38,13 @@
|
|||
#define NUS_RX_UUID "6E400002-B5A3-F393-E0A9-E50E24DCCA9E" // Client writes here
|
||||
#define NUS_TX_UUID "6E400003-B5A3-F393-E0A9-E50E24DCCA9E" // ESP32 notifies here
|
||||
|
||||
// Sensor Service UUIDs (custom, A0E7xxxx block)
|
||||
#define SENSOR_SERVICE_UUID "A0E70001-B5A3-F393-E0A9-E50E24DCCA9E"
|
||||
#define SENSOR_GPS_UUID "A0E70002-B5A3-F393-E0A9-E50E24DCCA9E"
|
||||
#define SENSOR_ORIENT_UUID "A0E70003-B5A3-F393-E0A9-E50E24DCCA9E"
|
||||
#define SENSOR_ENV_UUID "A0E70004-B5A3-F393-E0A9-E50E24DCCA9E"
|
||||
#define SENSOR_PPS_UUID "A0E70005-B5A3-F393-E0A9-E50E24DCCA9E"
|
||||
|
||||
// --- Timing ---
|
||||
// Inter-byte coalescing window: collect bytes arriving within this
|
||||
// gap into one BLE notification instead of sending byte-by-byte
|
||||
|
|
@ -31,6 +53,12 @@
|
|||
// LED refresh interval
|
||||
#define LED_UPDATE_MS 50
|
||||
|
||||
// Sensor read/report intervals
|
||||
#define GPS_REPORT_MS 1000 // 1Hz GPS position reports
|
||||
#define IMU_REPORT_MS 100 // 10Hz orientation updates
|
||||
#define BARO_REPORT_MS 1000 // 1Hz pressure/temperature
|
||||
#define STATUS_PRINT_MS 1000 // 1Hz USB serial status line
|
||||
|
||||
// --- LED ---
|
||||
#define LED_BRIGHTNESS 30 // 0-255, keep low to avoid blinding in enclosure
|
||||
#define LED_COUNT 1
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue