Skip to content

robinmoon2/IoT-project

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

40 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

IoT-project

Project summary 🔧

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.html from 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.

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.

How to run the project (Main board vs Field board)

Common preparation

  1. Install PlatformIO and open this project in VS Code.
  2. Update Wi‑Fi credentials in include/main.h:
const char* ssid = "YourSSID";
const char* password = "YourPassword";
  1. Connect sensors, LoRa antenna and any external wake hardware according to the wiring.

Run as Main board (Wi‑Fi + Web server)

  1. Configure the board to run as main:
    • Quick way: edit include/main.h and set:
const bool MAINBOARD = true;
  • Alternatively, add a PlatformIO environment with -DMAINBOARD=1.
  1. Upload LittleFS contents (serves index.html):
pio run -e heltec_wifi_lora_32_V3 -t uploadfs
  1. Build and flash the firmware:
pio run -e heltec_wifi_lora_32_V3 -t upload
  1. Open serial monitor to view IP and logs:
pio device monitor -e heltec_wifi_lora_32_V3 -b 115200
  1. In a browser open http://<IP>/ or http://<IP>/api/data to view JSON data. The main board requests data from field nodes over LoRa (default ~60s) and shows it on the OLED.

Run as Field board (low-power sensor node)

  1. Ensure include/main.h has:
const bool MAINBOARD = false;
  1. Verify sensor wiring and water-level analog input (pin 19 in code).
  2. Build and flash firmware:
pio run -e heltec_wifi_lora_32_V3 -t upload
  1. 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).

Useful PlatformIO commands 🔁

  • 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

Notes & caveats ⚠️

  • Water level needs calibration (code currently uses /530*100 placeholder).
  • 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:main and env:field) with -DMAINBOARD=1/-DMAINBOARD=0 build flags to switch roles without changing source code.

Next steps 💡

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

About

IOT project with LoRa and Web communication

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Contributors