Add LoRa sensor network support

- Design LoRa packet protocol with CRC16 validation
- Add protocol header files (lora_protocol.h, lora_packet.h)
- Create battery-powered remote node firmware template
  - Support for DHT22, BME680, DS18B20 sensors
  - Deep sleep for battery conservation
  - Automatic gateway registration
- Add LoRa receive to gateway firmware
  - RadioLib SX1262 integration
  - Node registry for tracking up to 16 nodes
  - HTTP forwarding of received readings
  - ACK responses to remote nodes
- Create comprehensive setup guide with wiring diagrams

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
leehughes
2026-01-24 17:50:53 -06:00
co-authored by Claude Opus 4.5
parent 265a53768e
commit 5554341b49
11 changed files with 3199 additions and 34 deletions
+72 -3
View File
@@ -130,12 +130,78 @@ All configuration in `include/config.h`:
- [x] Offline buffering when network unavailable
- [x] Automatic sensor discovery (1-Wire)
### Future (Phase 3)
- [ ] LoRa receive for remote sensor nodes
- [ ] Battery-powered remote node firmware
### Phase 3: LoRa Network (Complete)
- [x] LoRa packet protocol design (docs/LORA_PROTOCOL.md)
- [x] Protocol header files (include/lora_protocol.h, include/lora_packet.h)
- [x] Battery-powered remote node firmware (remote-node/)
- [x] LoRa receive for gateway (RadioLib SX1262)
- [x] Gateway LoRa → HTTP forwarding
- [x] Automatic node registration and ACK responses
### Future
- [ ] Sensor agreement monitoring
- [ ] Flash storage for offline buffer persistence
## Remote Sensor Nodes
Battery-powered sensor nodes in `remote-node/` that transmit to the gateway via LoRa.
### Build & Upload
```bash
cd remote-node
# DHT22 variant (ambient temp/humidity)
pio run -e heltec_v3_dht22 --target upload
# BME680 variant (temp/humidity/pressure/VOC)
pio run -e heltec_v3_bme680 --target upload
```
### Configuration
Edit `remote-node/include/config.h`:
- `NODE_ID` - Unique ID or 0xFFFF for auto-assign
- `NODE_NAME` - Human-readable name (8 chars max)
- `REPORT_INTERVAL_SEC` - How often to transmit (default 60s)
### Power Consumption
- Deep sleep: ~10 μA
- Average @ 60s interval: ~1 mA
- 1000mAh LiPo battery life: ~1 month
## LoRa Protocol
The gateway will receive data from remote sensor nodes via LoRa 915MHz. Full specification in `docs/LORA_PROTOCOL.md`.
### Key Files
| File | Purpose |
|------|---------|
| `docs/LORA_PROTOCOL.md` | Full protocol specification |
| `include/lora_protocol.h` | Constants, types, CRC functions |
| `include/lora_packet.h` | Packet builder/parser helpers |
### Supported Sensors
| Type | Code | Payload Size | Data |
|------|------|--------------|------|
| DHT22 | 0x01 | 7 bytes | Temp, Humidity, Battery, RSSI |
| BME680 | 0x02 | 12 bytes | Temp, Humidity, Pressure, Gas, IAQ |
| DS18B20 | 0x03 | 5 bytes | Temp (high precision), Battery, RSSI |
### Node ID Ranges
| Range | Purpose |
|-------|---------|
| 0x0001-0x00FF | Tank sensors |
| 0x0100-0x01FF | Ambient sensors (DHT22) |
| 0x0200-0x02FF | Environmental (BME680) |
| 0xFFFF | Auto-assign request |
## Documentation
| Document | Purpose |
|----------|---------|
| `docs/SETUP_GUIDE.md` | Complete setup guide with wiring diagrams |
| `docs/LORA_PROTOCOL.md` | LoRa packet format specification |
| `remote-node/README.md` | Remote node firmware guide |
## Related Projects
- **ZNET Web**: `~/Nextcloud/Dev/znet-web` - Backend receives temperature data
@@ -151,3 +217,6 @@ All configuration in `include/config.h`:
| Date | Version | Change |
|------|---------|--------|
| 2026-01-24 | 1.0.0 | Initial implementation |
| 2026-01-24 | 1.1.0 | LoRa protocol design, header files |
| 2026-01-24 | 1.2.0 | Remote node firmware template (DHT22, BME680, DS18B20) |
| 2026-01-24 | 1.3.0 | Gateway LoRa receive, node registry, HTTP forwarding |