Introduction: IoT Based Smart Gardening and Smart Agriculture Using ESP32
World is changing as time and so agriculture.
Nowadays, People are integrating electronics in every field and agriculture is not exception for this. This merging of electronics in agriculture is helping farmers and people who manages gardens.
In this article we will see how to monitor and how to manage gardening and agriculture. We will use (ESP32) controlling module for IoT and we will update the data on cloud and based on readings we will take the appropriate action.
In this project we have used sensors like LDR(Light depedent Resistor), Temperature sensor, Soil Moisture level sensor and we will use water pump to react on the sensors data. Apart from this we can use lots of sensors to monitor.
Step 1: Required Components
Below are the required components,
- Soil Moisture Sensor
- NTC Temperature Sensor
- LDR Sensor
- DC Water Pump +5v
- Breadboard - https://www.banggood.in/custlink/DGKyeOSast
- Jumper Wires - https://www.banggood.in/custlink/vGGheoIogd
- Nodemcu - https://www.banggood.in/custlink/mmKheOZjl3
- ESP32 - https://www.banggood.in/custlink/KDmh0l8aOr
Step 2: Working Principle
ESP32 controlling module is used for gathering the data from sensors like LDR(Light depedent Resistor), Temparature sensor, Soil Moisture level sensor. If the soil moisture level is very low then we will turn ON the water Pump. We are monitoring the motor status as well for the feedback to confirm the motor status.
We are using temparature sensor to regulate the water on crop's root which will keep the crop fresh. ESP32 is gathering the data from all sensors and sending/publishing all the data to MQTT server and subscribing for the motor control topic.
Step 3: Projects Pics
Step 4: Code Explaination:
And from the mqtt server or other node (from where we are observing or controlling motor). In our case we are using mobile as node and we have subscribe for the following topic.
Topics to subscribe from controlling node (mobile) and ESP32 will publish for the topic
Publish the topic from controlling node and ESP32 will subscribe for the topic
In the setup_wifi function we are connecting to wifi and control will be stop there till wifi connection.
In the reconnect function ESP32 will try to connect to MQTT server and wait till connection.
callback is the function which will get invoke or will get execute once subscribed topic is available.
In the setup function we are initilizing Serial communication, Wifi connection and MQTT connection.
getTemperature,getMoisturePercentage and getLightPercentage function is reading the data from sensor and returning the value which has to publish over MQTT.
And in the loop function which gets executed continously, ESP32 will send the collected data over mqtt.
Step 5: Schematic
Step 6: Code
Step 7: Tutorial
1 Person Made This Project!
- sugendran made it!