What this project does
- This is an IoT monitoring project using Heltec ESP32 LoRa boards to monitor environmental data on a surface or field.
- The project supports two device roles:
- Main board (master): connects to Wi‑Fi, hosts a small web server (serves
index.htmlfrom LittleFS), requests/receives sensor data over LoRa, displays info on the onboard OLED, and exposes a simple HTTP API (/api/data,/api/receive). - Field board (node): reads sensors (BME680 for temperature/humidity/pressure and TMG3993 for light), measures an analog water-level sensor, transmits readings via LoRa, and enters deep sleep to conserve power.
- Main board (master): connects to Wi‑Fi, hosts a small web server (serves
Key components
- Sensors: BME680 (temp/humidity/pressure), TMG3993 (light / lux).
- Communication: LoRa (RADIOLIB + SX12x family).
- Storage & UI: LittleFS for
index.html, onboard OLED display for status. - Power saving: Field nodes use deep sleep with timer and external wake.
- Install PlatformIO and open this project in VS Code.
- Update Wi‑Fi credentials in
include/main.h:
const char* ssid = "YourSSID";
const char* password = "YourPassword";- Connect sensors, LoRa antenna and any external wake hardware according to the wiring.
- Configure the board to run as main:
- Quick way: edit
include/main.hand set:
- Quick way: edit
const bool MAINBOARD = true;- Alternatively, add a PlatformIO environment with
-DMAINBOARD=1.
- Upload LittleFS contents (serves
index.html):
pio run -e heltec_wifi_lora_32_V3 -t uploadfs
- Build and flash the firmware:
pio run -e heltec_wifi_lora_32_V3 -t upload
- Open serial monitor to view IP and logs:
pio device monitor -e heltec_wifi_lora_32_V3 -b 115200
- In a browser open
http://<IP>/orhttp://<IP>/api/datato view JSON data. The main board requests data from field nodes over LoRa (default ~60s) and shows it on the OLED.
- Ensure
include/main.hhas:
const bool MAINBOARD = false;- Verify sensor wiring and water-level analog input (pin 19 in code).
- Build and flash firmware:
pio run -e heltec_wifi_lora_32_V3 -t upload
- After flashing the field board will acquire sensors, send a LoRa payload (format:
0,temp,hum,pressure,light,water) and enter deep sleep (wakes every ~60 s or by external wake).
- Build:
pio run -e heltec_wifi_lora_32_V3 - Upload firmware:
pio run -e heltec_wifi_lora_32_V3 -t upload - Upload LittleFS:
pio run -e heltec_wifi_lora_32_V3 -t uploadfs - Serial monitor:
pio device monitor -e heltec_wifi_lora_32_V3 -b 115200
- Water level needs calibration (code currently uses
/530*100placeholder). - LoRa frequency and region settings (e.g.,
FREQUENCY = 866.3,REGION_US915) must be adjusted to local regulations. - To avoid manual edits, consider adding two PlatformIO environments (e.g.,
env:mainandenv:field) with-DMAINBOARD=1/-DMAINBOARD=0build flags to switch roles without changing source code.
If you want, I can add env:main/env:field entries to platformio.ini and/or polish the LittleFS index.html UI. Just say which change you prefer.
If you have modifications advices or issues, we will be glad to respond