Document multi-meter UART mapping and energy-only sender behavior

This commit is contained in:
2026-02-04 15:22:30 +01:00
parent 938f490a32
commit c62f07bf44

View File

@@ -1,7 +1,7 @@
# DD3-LoRa-Bridge-MultiSender # DD3-LoRa-Bridge-MultiSender
Unified firmware for LilyGO T3 v1.6.1 (ESP32 + SX1276 + SSD1306) running as either: Unified firmware for LilyGO T3 v1.6.1 (ESP32 + SX1276 + SSD1306) running as either:
- `Sender`: reads meter values and sends binary batches over LoRa. - `Sender`: reads energy-only values from multiple IEC 62056-21 meters and sends binary batches over LoRa.
- `Receiver`: accepts batches, ACKs with optional time, publishes to MQTT/web. - `Receiver`: accepts batches, ACKs with optional time, publishes to MQTT/web.
## Protocol (minimal) ## Protocol (minimal)
@@ -27,6 +27,9 @@ CRC16 validation is still required on every frame.
### 1) `BATCH_UP` ### 1) `BATCH_UP`
- Uses existing binary batch/chunk transport. - Uses existing binary batch/chunk transport.
- `sample_count == 0` is valid and means `SYNC_REQUEST`. - `sample_count == 0` is valid and means `SYNC_REQUEST`.
- Payload starts with `schema_id`:
- `0`: legacy schema (kept for compatibility)
- `1`: `EnergyMulti` schema (ts + integer kWh for up to 3 meters)
### 2) `ACK_DOWN` (7 bytes) ### 2) `ACK_DOWN` (7 bytes)
- `flags` (`u8`): bit0 = `time_valid` - `flags` (`u8`): bit0 = `time_valid`
@@ -55,6 +58,37 @@ Only then:
This guarantees no pre-`2026-02-01` epoch reaches MQTT or SD/DB paths. This guarantees no pre-`2026-02-01` epoch reaches MQTT or SD/DB paths.
## Multi-meter sender mode
- Meter protocol: IEC 62056-21 ASCII Mode D
- UART framing: `9600 7E1`
- Extracted OBIS: only total energy `1-0:1.8.0`
- Conversion: kWh is sent as integer using `floor` (`12345.67 -> 12345`)
### Meter count by build mode
- Debug builds (`SERIAL_DEBUG_MODE=1`): `METER_COUNT=2`
- keeps USB serial logs on UART0
- uses UART1 + UART2 for meters
- Prod builds (`SERIAL_DEBUG_MODE=0`): `METER_COUNT=3`
- no serial logging
- reclaims UART0 for meter 3 RX
### Meter RX pins (TTGO T3 v1.6.1 defaults)
- `PIN_METER1_RX = GPIO34` (UART2 RX)
- `PIN_METER2_RX = GPIO25` (UART1 RX)
- `PIN_METER3_RX = GPIO3` (UART0 RX, prod only)
All pins are configurable in `include/config.h`.
## Receiver MQTT output (EnergyMulti)
For `schema_id=1`, MQTT payload includes integer fields:
- `energy1_kwh`
- `energy2_kwh`
- `energy3_kwh` (when meter count is 3)
## Receiver behavior ## Receiver behavior
On `BATCH_UP`: On `BATCH_UP`:
@@ -85,4 +119,5 @@ DS3231 RTC support was removed:
```bash ```bash
pio run -e lilygo-t3-v1-6-1 pio run -e lilygo-t3-v1-6-1
pio run -e lilygo-t3-v1-6-1-test pio run -e lilygo-t3-v1-6-1-test
pio run -e lilygo-t3-v1-6-1-prod
``` ```