IoT Based Smart Gardening and Smart Agriculture Using ESP32

by embpic in Circuits > Arduino

10345 Views, 13 Favorites, 0 Comments

IoT Based Smart Gardening and Smart Agriculture Using ESP32

1.jpg
2.jpg

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.

Required Components

Below are the required components,

  1. Soil Moisture Sensor
  2. NTC Temperature Sensor
  3. LDR Sensor
  4. DC Water Pump +5v
  5. Breadboard - https://www.banggood.in/custlink/DGKyeOSast
  6. ​Jumper Wires - https://www.banggood.in/custlink/vGGheoIogd​
  7. Nodemcu - https://www.banggood.in/custlink/mmKheOZjl3
  8. ESP32 - https://www.banggood.in/custlink/KDmh0l8aOr

Transistor

Resistors

Few Wires

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.

Projects Pics

3.jpg
4.jpg
5.jpg

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

stechiez/agree/light

stechiez/agree/temp

stechiez/agree/soil

stechiez/agree/mstatus

Publish the topic from controlling node and ESP32 will subscribe for the topic

stechiez/agree/motor

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.

Schematic

SmartAgree_bb.jpg

Code

Tutorial

IoT Based Smart Agriculture System | Smart Gardening | MQTT Protocol | IoT Projects Ideas