This project implements a greenhouse environmental monitoring node for a 3-hectare tomato farm.
It measures soil temperature and soil moisture (with optional EC and pH), displays live readings on an OLED when requested, and sends data periodically to a central server via a LoRa node.
The main controller is an ESP32-DevKitV1, interfacing with sensors and peripherals via SDI-12, ADC, I2C, and SPI.
- Soil moisture measurement via SDI-12 sensor
- Soil temperature measurement via analog sensor
- Data transmission to LoRa gateway over SPI
- Live data display on 1" OLED via I2C, activated by a button
- Low-power operation with deep sleep and OLED power cut-off
- Configurable send intervals (fixed + random delay) to avoid collisions
- Interval updates via downlink from LoRa node
- Daily RTC sync between ESP32 internal RTC and DS3231
- OTA firmware updates from LoRa node
| Module / Sensor | Interface | ESP32 Pins |
|---|---|---|
| Soil moisture (SDI-12) | UART | GPIO17 (TX), GPIO16 (RX) |
| Soil temperature (analog) | ADC1 | GPIO34 |
| LoRa node | SPI | MISO=19, MOSI=23, SCLK=18, CS=5 |
| OLED 1" | I2C | SDA=21, SCL=22 |
| Button | GPIO | GPIO0 |
| DS3231 | I2C | SDA=21, SCL=22 |
| OLED power control | GPIO | GPIO15 |
| Battery voltage | ADC1 | GPIO35 |
- ESP-IDF v4.4 or later
- Built-in ESP-IDF libraries: driver, esp_adc_cal, esp_log, esp_sleep, esp_timer, esp_ota_ops
- snake_case for functions/variables, PascalCase for structs
- 4-space indentation
- Docstring above each function, inline comments for complex logic
- Modular components with include/ for public headers