An ESP32-based sensor node that collects environmental data and transmits it wirelessly via ESP-NOW protocol to a central hub. This is part of the FAO56 IoT system for agricultural monitoring and irrigation management.
The Sensor Node captures temperature, humidity, and soil moisture data at configurable intervals. It operates on battery power with efficient sleep modes to conserve energy. Data is transmitted wirelessly to an ESP-NOW UART Hub, which forwards the information to the cloud.
- Low Power Operation: Optimized for battery-powered deployment
- Multi-Sensor Support: Temperature, humidity, and soil moisture sensing
- ESP-NOW Communication: Efficient short-range wireless data transmission
- Automatic Pairing: Self-registers with ESP-NOW hub
- Deep Sleep Modes: Extends battery life through power management
- Configurable Sampling: Adjustable measurement intervals
- ESP32 development board (NodeMCU-32S or ESP32-30pin)
- DHT11/DHT22 temperature and humidity sensor
- Capacitive soil moisture sensor
- Power source (Battery or USB)
- Waterproof enclosure for field deployment
#define DHT_PIN 33 // DHT temperature/humidity sensor pin
#define DHT_TYPE DHT11 // DHT sensor type
#define MOISTURE_PIN 32 // Analog pin for soil moisture sensorstruct sensorData {
uint8_t msgType; // Message type (DATA or PAIRING)
char nodeID[8]; // Node identifier
float temp; // Temperature reading in °C
float humidity; // Humidity reading in %
long moisture; // Soil moisture reading in %
};- Wake Up: Device wakes from deep sleep or powers on
- Hub Connection: Pairs with ESP-NOW hub if not already paired
- Sensor Reading: Collects temperature, humidity, and soil moisture data
- Data Transmission: Sends readings to hub via ESP-NOW
- Sleep: Enters deep sleep mode to conserve power
- Repeat: Wakes after configured interval to send new readings
The sensor node implements several strategies to minimize power consumption:
- Deep sleep between measurement cycles
- Quick sensor reads and transmissions
- Power-efficient wireless protocol (ESP-NOW)
- Configurable sleep duration based on requirements
The config file is located in config.h:
#define NODE_ID "S-0" // Unique identifier for this node#define SLEEP_TIMER 10 // Sleep duration in minutes#define AIR_VALUE 2559 // ADC reading for dry soil
#define WATER_VALUE 1225 // ADC reading for wet soil
#define DEFAULT_MEASUREMENT -100 // Default value for failed readings- PlatformIO IDE or Arduino IDE with ESP32 support
- ESP32 board package installed
The project uses PlatformIO with configuration in platformio.ini:
- Target: ESP32 NodeMCU-32S or ESP32-30pin
- Framework: Arduino
- Required libraries: DHT sensor library, ESP-NOW
- Connect ESP32 to computer via USB
- Select correct COM port and board
- Build and upload firmware
- Monitor serial output for debugging
- Ensure battery is fully charged
- Confirm sensors are properly connected
- Verify successful pairing with hub before final placement
- Place in waterproof enclosure
- Install at desired location in field
Serial output provides detailed information about:
- Sensor initialization
- Reading values from sensors
- ESP-NOW pairing status
- Data transmission success/failure
- Sleep cycle information
Monitor at 115200 baud to view debug information during setup and testing.
This sensor node works in conjunction with:
- ESP-NOW UART Hub: Receives sensor data and forwards to MQTT hub
- MQTT Hub: Processes data and sends to cloud services
- FAO56 System: Uses collected data for irrigation management
- Failed sensor readings: Check sensor connections and power
- Pairing failures: Ensure hub is in range and operational
- Short battery life: Check for sleep mode issues or short circuits
- Incorrect readings: Verify sensor calibration values (AIR_VALUE and WATER_VALUE)
- No data transmission: Check ESP-NOW configuration and hub status
- Battery Connection: Connect battery to VIN and GND pins
- Sensor Placement: Ensure soil moisture sensor is properly inserted in soil
- Waterproofing: Use silicone sealant around sensor connections
- Antenna Position: Keep antenna clear of metal objects and ground
Part of the FAO56 IoT agricultural monitoring system.