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.
Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.
Step 1: Required Components
Below are the required components,
ESP32 in India - https://amzn.to/2NpbsE2
ESP32 in UK - https://amzn.to/34g0SWX
ESP32 in USA - https://amzn.to/34g0SWX
Soil Moisture Sensor
Soil Moisture Sensor in India- https://amzn.to/2PyAi7l
Soil Moisture Sensor in UK - https://amzn.to/2PyAi7l
Soil Moisture Sensor in USA - https://amzn.to/2PyAi7l
NTC Temperature Sensor
NTC Temperature Sensor in India- https://amzn.to/34f87hD
NTC Temperature Sensor in UK - https://amzn.to/34hVSkt
NTC Temperature Sensor in USA - https://amzn.to/34hVSkt
LDR Sensor in India - https://amzn.to/32XcePf
LDR Sensor in UK - https://amzn.to/32XcePf
LDR Sensor in USA - https://amzn.to/32XcePf
DC Water Pump +5v
DC Water Pump +5v in India - https://amzn.to/2qZavuI
DC Water Pump +5v in UK - https://amzn.to/3359PC0
DC Water Pump +5v in USA - https://amzn.to/3359PC0
BreadBoard in India- https://amzn.to/2MW0Opb
BreadBoard in USA- https://amzn.to/32WZZSV
BreadBoard in UK- https://amzn.to/32WZZSV
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.