Add SD logging and update docs
- Add optional microSD CSV logging per sender/day on receiver - Wire logger into receiver packet handling - Document new batch header fields, build envs, and SD logging - Make sender links open in a new tab
This commit is contained in:
19
README.md
19
README.md
@@ -175,7 +175,7 @@ Packet layout:
|
||||
|
||||
LoRa radio settings:
|
||||
- Frequency: **433 MHz** or **868 MHz** (set by build env via `LORA_FREQUENCY_HZ`)
|
||||
- SF11, BW 125 kHz, CR 4/5, CRC on, Sync Word 0x34
|
||||
- SF12, BW 125 kHz, CR 4/5, CRC on, Sync Word 0x34
|
||||
|
||||
## Data Format
|
||||
MeterData JSON (sender + MQTT):
|
||||
@@ -205,6 +205,10 @@ Fixed header (little-endian):
|
||||
- `dt_s` u8 (seconds, >0)
|
||||
- `n` u8 (sample count, <=30)
|
||||
- `battery_mV` u16
|
||||
- `err_m` u8 (meter read failures, sender-side counter)
|
||||
- `err_d` u8 (decode failures, sender-side counter)
|
||||
- `err_tx` u8 (LoRa TX failures, sender-side counter)
|
||||
- `err_last` u8 (last error code: 0=None, 1=MeterRead, 2=Decode, 3=LoraTx)
|
||||
|
||||
Body:
|
||||
- `E0` u32 (absolute energy in Wh)
|
||||
@@ -219,6 +223,7 @@ Body:
|
||||
Notes:
|
||||
- Receiver reconstructs timestamps from `t_last` and `dt_s`.
|
||||
- Total power is computed on receiver as `p1 + p2 + p3`.
|
||||
- Sender error counters are carried in the batch header and applied to all samples.
|
||||
|
||||
## Device IDs
|
||||
- Derived from WiFi STA MAC.
|
||||
@@ -250,6 +255,7 @@ inline constexpr uint16_t EXPECTED_SENDER_IDS[NUM_SENDERS] = { 0xF19C };
|
||||
- `/`: status overview
|
||||
- `/wifi`: WiFi/MQTT/NTP config (AP and STA)
|
||||
- `/sender/<device_id>`: per-sender details
|
||||
- Sender IDs on `/` are clickable (open sender page in a new tab).
|
||||
|
||||
## MQTT
|
||||
- Topic: `smartmeter/<deviceId>/state`
|
||||
@@ -272,6 +278,8 @@ inline constexpr uint16_t EXPECTED_SENDER_IDS[NUM_SENDERS] = { 0xF19C };
|
||||
- `lilygo-t3-v1-6-1-test`: test build with `ENABLE_TEST_MODE`
|
||||
- `lilygo-t3-v1-6-1-868`: production build for 868 MHz modules
|
||||
- `lilygo-t3-v1-6-1-868-test`: test build for 868 MHz modules
|
||||
- `lilygo-t3-v1-6-1-payload-test`: build with `PAYLOAD_CODEC_TEST`
|
||||
- `lilygo-t3-v1-6-1-868-payload-test`: 868 MHz build with `PAYLOAD_CODEC_TEST`
|
||||
|
||||
## Config Knobs
|
||||
Key timing settings in `include/config.h`:
|
||||
@@ -283,6 +291,7 @@ Key timing settings in `include/config.h`:
|
||||
- `BATCH_RETRY_POLICY` (keep or drop on retry exhaustion)
|
||||
- `SERIAL_DEBUG_MODE` / `SERIAL_DEBUG_DUMP_JSON`
|
||||
- `LORA_SEND_BYPASS` (debug only)
|
||||
- `ENABLE_SD_LOGGING` / `PIN_SD_CS`
|
||||
|
||||
## Limits & Known Constraints
|
||||
- **Compression**: MeterData uses lightweight RLE (good for JSON but not optimal).
|
||||
@@ -292,6 +301,14 @@ Key timing settings in `include/config.h`:
|
||||
- **OLED**: no hardware reset line is used (matches working reference).
|
||||
- **Batch ACKs**: sender waits for ACK after a batch and retries up to `BATCH_MAX_RETRIES` with `BATCH_ACK_TIMEOUT_MS` between attempts.
|
||||
|
||||
## SD Logging (Receiver)
|
||||
Optional CSV logging to microSD (FAT32) when `ENABLE_SD_LOGGING = true`.
|
||||
|
||||
- Path: `/dd3/<device_id>/YYYY-MM-DD.csv`
|
||||
- Columns:
|
||||
`ts_utc,p_w,p1_w,p2_w,p3_w,e_kwh,bat_v,bat_pct,rssi,snr,err_m,err_d,err_tx,err_last`
|
||||
- `err_last` is written as text (`meter`, `decode`, `loratx`) only on the last sample of a batch that reports an error.
|
||||
|
||||
## Files & Modules
|
||||
- `include/config.h`, `src/config.cpp`: pins, radio settings, sender IDs
|
||||
- `include/data_model.h`, `src/data_model.cpp`: MeterData + ID init
|
||||
|
||||
Reference in New Issue
Block a user