Smart Greenhouse IoT ESP32 Nodered
An ESP32 display project involving OLED display, DHT22, Servo motor.
Parts and sourceBefore you start
Check the exact OLED display, DHT22, Servo motor configuration against the upstream wiring or parts list.
Upstream README
SmartGreenhouse β IoT Project
Overview
SmartGreenhouse is an IoT-based smart garden system designed to monitor and control greenhouse conditions.
The system integrates environmental and soil monitoring (temperature, humidity, light, and water level) with automated or manual actuation of irrigation, ventilation, and lighting.
A Node-RED dashboard provides real-time monitoring, historical data visualization, and remote control through MQTT-based communication. The project also supports remote access via the Remote-RED mobile app.
Project Preview
Here are some visuals of the implemented system and dashboard:
Node-RED Dashboard

Physical Greenhouse Prototype

Features
-
π± Irrigation:
- Automatic watering based on soil humidity thresholds set via dashboard.
- Manual control of the water pump.
-
π¬ Ventilation:
- Automatic fan activation based on configured temperature thresholds.
- Manual fan control through dashboard.
-
π‘ Lighting:
- Adaptive LED lighting control depending on external light levels.
- Manual brightness adjustment from dashboard.
-
π Monitoring & Visualization:
- Local OLED display showing system status.
- Node-RED dashboard for remote monitoring and control.
- Historical temperature data stored in InfluxDB and visualized in dashboard.
- Push notifications (via Remote-RED app) when the water tank reaches a critical level.
Hardware Components
Sensors
- DHT22 β Ambient temperature and humidity sensor
- Soil hygrometer probe β Soil moisture measurement
- HC-SR04 ultrasonic sensor β Water tank level monitoring
- LDR (Light Dependent Resistor) β External light intensity measurement
- Push-button β Manual input for reset and door control
Actuators
- LEDs β Adaptive lighting
- DC Fan (5V) β Greenhouse ventilation
- DC Pump (12V) β Irrigation
- Relay module (5V) β Switching fan and pump
- OLED Display (SSD1306) β Local system status visualization
- Servo motor β Greenhouse door control
Software Architecture
-
Firmware (Python for ESP32):
- Classes for each device (e.g.,
Pump,Fan,Cistern,LDR,OLED) abstract sensor/actuator management. mqtt_clientclass handles MQTT communication (connection, publish, subscribe).- Main loop manages automation logic and state publishing.
- Classes for each device (e.g.,
-
Node-RED Dashboard:
- Displays sensor readings in real time.
- Provides manual control of actuators.
- Integrates with InfluxDB for historical data visualization.
- Accessible remotely via Remote-RED app.
Protocols & Communication
- MQTT: Implemented with a cloud-based Mosquitto broker for publish/subscribe communication.
- IΒ²C: Used for communication between ESP32 and OLED display (SSD1306).
- Wi-Fi: ESP32 connectivity for data exchange with MQTT broker and Node-RED.
Repository Structure
βββ /src # Python source files (ESP32 firmware)
β βββ main.py
β βββ pump.py
β βββ fan.py
β βββ ldr.py
β βββ oled.py
β βββ ...
βββ /dashboard # Node-RED dashboard flow
β βββ dashboard.json
βββ README.md
Getting Started
Prerequisites
- ESP32 microcontroller
- Node-RED installed locally or on server
- Mosquitto MQTT broker (cloud or local instance)
- InfluxDB instance for historical data storage (optional but recommended)
Setup Instructions
- Flash the ESP32 with the provided Python source files (
/src). - Import
dashboard.jsoninto your Node-RED environment. - Configure MQTT broker credentials in both firmware and Node-RED.
- (Optional) Connect InfluxDB to store and visualize temperature history.
- Use Remote-RED app for mobile access.
Technologies Used
- Python (MicroPython on ESP32)
- Node-RED (dashboard & control logic)
- MQTT (Mosquitto Broker)
- InfluxDB (time-series data storage)
- Remote-RED (mobile remote access)
- IΒ²C communication (OLED display)
- Wi-Fi connectivity