ESP32-based Smart Greenhouse Control With DHT Sensor (ThingSpeak)
by sarful in Circuits > Arduino
18 Views, 0 Favorites, 0 Comments
ESP32-based Smart Greenhouse Control With DHT Sensor (ThingSpeak)
This project uses an ESP32 board along with a DHT sensor (either DHT11 or DHT22) to monitor temperature and humidity inside a greenhouse. The data is uploaded to ThingSpeak, where it can be monitored and visualized in real time. Based on sensor readings, a relay module controls devices such as a fan and water pump to regulate temperature and humidity inside the greenhouse.
Supplies
Components Required:
- ESP32 Board – The microcontroller for IoT applications.
- DHT11 Sensor or DHT22 Sensor – Temperature and humidity sensor.
- Relay Module – Controls the fan and water pump.
- Water Pump – Automated irrigation based on humidity.
- Fan – Cooling system to control temperature.
- Breadboard – For connecting components.
- Jumper Wires – For wiring connections.
- Power Supply – To power the ESP32 and other devices.
- LCD Display (Optional) – To display temperature and humidity values locally.
- Push Button (Optional) – To manually control the fan and water pump.
Wiring Instructions:
- Connect the DHT Sensor:
- VCC of DHT to 3.3V on the ESP32.
- GND of DHT to GND on the ESP32.
- Data Pin of DHT to Pin D4 on the ESP32.
- Connect the Relay Module:
- Relay IN Pin to GPIO D5 (or any available pin on the ESP32).
- Relay VCC to 3.3V on the ESP32.
- Relay GND to GND on the ESP32.
- Common (COM) of the relay to the water pump or fan.
- Normally Open (NO) pin to the power supply of the device you want to control.
- Optional: LCD Display:
- Connect the LCD Display to the SDA and SCL pins of the ESP32 for I2C communication.
- Optional: Push Button:
- Connect the push button to GPIO D2 for manual control of the fan and water pump.
Setting Up ThingSpeak:
- Create a ThingSpeak Account:
- Go to ThingSpeak and sign up for a free account.
- Create a Channel:
- After logging in, create a new channel by going to Channels → Create New Channel.
- Add four fields: Temperature (Field 1), Humidity (Field 2), Fan Control (Field 3), and Water Pump Control (Field 4).
- Obtain the API Key:
- After creating the channel, go to the Channel Settings section and copy the Write API Key. This key will be used in the code to send data to ThingSpeak.
- Optional: Add Widgets for Visualization:
- Under the Apps tab, go to Widgets to add graphical widgets (such as gauges for temperature and humidity) and control widgets for the fan and water pump.
Arduino Code:
Testing and Calibration:
- Upload the Code:
- Open the Arduino IDE, paste the code, and upload it to your ESP32.
- Monitor Serial Output:
- Open the Serial Monitor in the Arduino IDE to view the temperature and humidity readings. It will display values like:
- Check ThingSpeak:
- Go to your ThingSpeak account and check the live data feed. You should see real-time updates for temperature, humidity, and device control (fan and pump).
- The fan and water pump should automatically turn on/off based on the conditions.
Manual Control:
If you have added a push button, you can wire it to control the fan or water pump manually. When pressed, the button can toggle the fan or pump status on the ThingSpeak platform.
Conclusion:
This ESP32-based Smart Greenhouse Control project allows you to:
- Monitor temperature and humidity in real-time using ThingSpeak.
- Automatically control a fan and water pump to maintain ideal greenhouse conditions.
- Optionally visualize the data using ThingSpeak widgets or add manual control using a push button.
Affiliate Disclaimer:
Some of the links provided are affiliate links, meaning I may earn a small commission if you make a purchase through them, at no additional cost to you. Your support helps me continue creating free, useful content. Thank you!