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:
co-authored by
Claude Opus 4.5
parent
265a53768e
commit
5554341b49
@@ -0,0 +1,157 @@
|
||||
# ZNET LoRa Remote Sensor Node
|
||||
|
||||
Battery-powered sensor nodes that transmit temperature, humidity, and air quality data to the ZNET gateway via LoRa.
|
||||
|
||||
## Supported Hardware
|
||||
|
||||
| Board | Chip | LoRa | Notes |
|
||||
|-------|------|------|-------|
|
||||
| Heltec WiFi LoRa 32 V3 | ESP32-S3 | SX1262 | Recommended - built-in OLED |
|
||||
| TTGO LoRa32 V2.1 | ESP32 | SX1276 | Budget option |
|
||||
| DIY ESP32 + SX1276 | ESP32 | SX1276 | Full customization |
|
||||
|
||||
## Supported Sensors
|
||||
|
||||
| Sensor | Data | Use Case |
|
||||
|--------|------|----------|
|
||||
| DHT22 | Temp + Humidity | Ambient monitoring |
|
||||
| BME680 | Temp + Humidity + Pressure + Gas | Air quality monitoring |
|
||||
| DS18B20 | Temperature (high precision) | Remote tank monitoring |
|
||||
|
||||
## Quick Start
|
||||
|
||||
### 1. Install PlatformIO
|
||||
|
||||
```bash
|
||||
pip install platformio
|
||||
```
|
||||
|
||||
### 2. Configure Node
|
||||
|
||||
Edit `include/config.h`:
|
||||
|
||||
```cpp
|
||||
// Set unique node ID or use 0xFFFF for auto-assign
|
||||
#define NODE_ID 0x0101
|
||||
|
||||
// Node name (max 8 chars)
|
||||
#define NODE_NAME "Ambient1"
|
||||
|
||||
// Report interval (seconds)
|
||||
#define REPORT_INTERVAL_SEC 60
|
||||
```
|
||||
|
||||
### 3. Build & Upload
|
||||
|
||||
```bash
|
||||
cd remote-node
|
||||
|
||||
# For Heltec V3 with DHT22:
|
||||
pio run -e heltec_v3_dht22 --target upload
|
||||
|
||||
# For Heltec V3 with BME680:
|
||||
pio run -e heltec_v3_bme680 --target upload
|
||||
|
||||
# For TTGO board:
|
||||
pio run -e ttgo_lora32_v21 --target upload
|
||||
```
|
||||
|
||||
### 4. Monitor Output
|
||||
|
||||
```bash
|
||||
pio device monitor
|
||||
```
|
||||
|
||||
## Wiring
|
||||
|
||||
### DHT22 Sensor
|
||||
|
||||
```
|
||||
ESP32 GPIO7 ─────────── DHT22 DATA
|
||||
ESP32 3.3V ──────────── DHT22 VCC
|
||||
ESP32 GND ───────────── DHT22 GND
|
||||
|
||||
10kΩ pullup between DATA and VCC
|
||||
```
|
||||
|
||||
### BME680 Sensor (I2C)
|
||||
|
||||
```
|
||||
ESP32 SDA (21) ──────── BME680 SDA
|
||||
ESP32 SCL (22) ──────── BME680 SCL
|
||||
ESP32 3.3V ──────────── BME680 VCC
|
||||
ESP32 GND ───────────── BME680 GND
|
||||
```
|
||||
|
||||
### Battery Connection
|
||||
|
||||
```
|
||||
LiPo + ─────┬───────── ESP32 VBAT
|
||||
│
|
||||
┌┴┐
|
||||
│ │ 100kΩ
|
||||
└┬┘
|
||||
├───────── ADC Pin (Battery monitoring)
|
||||
┌┴┐
|
||||
│ │ 100kΩ
|
||||
└┬┘
|
||||
│
|
||||
LiPo - ─────┴───────── ESP32 GND
|
||||
```
|
||||
|
||||
## Power Consumption
|
||||
|
||||
| State | Current | Notes |
|
||||
|-------|---------|-------|
|
||||
| Deep Sleep | ~10 μA | ESP32 deep sleep |
|
||||
| Active (reading) | ~15 mA | Sensor reading |
|
||||
| TX | ~80 mA | LoRa transmission |
|
||||
| **Average @ 60s** | **~1 mA** | Typical |
|
||||
|
||||
### Battery Life Estimates (1000mAh LiPo)
|
||||
|
||||
| Interval | Battery Life |
|
||||
|----------|--------------|
|
||||
| 30 sec | ~2 weeks |
|
||||
| 60 sec | ~1 month |
|
||||
| 5 min | ~6 months |
|
||||
| 10 min | ~1 year |
|
||||
|
||||
## Protocol
|
||||
|
||||
See [../docs/LORA_PROTOCOL.md](../docs/LORA_PROTOCOL.md) for full LoRa packet specification.
|
||||
|
||||
### Node ID Ranges
|
||||
|
||||
| Range | Purpose |
|
||||
|-------|---------|
|
||||
| 0x0001-0x00FF | Tank sensors |
|
||||
| 0x0100-0x01FF | Ambient (DHT22) |
|
||||
| 0x0200-0x02FF | Environmental (BME680) |
|
||||
| 0xFFFF | Auto-assign |
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### No LoRa transmission
|
||||
|
||||
1. Check LoRa frequency matches gateway (915 MHz for US)
|
||||
2. Verify SPI pins are correct for your board
|
||||
3. Check serial monitor for "LoRa init failed" errors
|
||||
|
||||
### Sensor read fails
|
||||
|
||||
1. Check wiring connections
|
||||
2. Verify correct GPIO pins in config.h
|
||||
3. For I2C sensors, run I2C scanner to verify address
|
||||
|
||||
### Short battery life
|
||||
|
||||
1. Increase `REPORT_INTERVAL_SEC`
|
||||
2. Disable OLED (`ENABLE_OLED 0`)
|
||||
3. Disable serial debug in production (`ENABLE_SERIAL_DEBUG 0`)
|
||||
|
||||
### Not receiving ACKs
|
||||
|
||||
1. Verify gateway is running and receiving
|
||||
2. Check sync word matches (0x12)
|
||||
3. Reduce spreading factor if range is short (better reliability)
|
||||
Reference in New Issue
Block a user