SMART GARDENING SYSTEM

Based on iOT Technology

Introduction :

The world is changing as time and so on agriculture. Nowadays, People are integrating electronics in every field and agriculture is not an exception to this. This merging of electronics in agriculture is helping farmers and people who manage gardens.

In this article, we will see how to monitor and how to manage gardening and agriculture. We will use (Nodemcu) controlling module for IoT and we will update the data on the cloud and based on readings we will take the appropriate action.

Required Components :

NodeMCU

The NodeMCU (Node MicroController Unit) is an open source software and hardware development environment that is built around a very inexpensive System-on-a-Chip (SoC) called the ESP8266.

NodeMCU is an open source platform based on ESP8266 which can connect objects and let data transfer using the Wi-Fi protocol. 

Features 

  • Easy to use
  • Programmability with Arduino IDE or IUA languages
  • Available as an access point or station
  • practicable in Event-driven API applications
  • Having an internal antenna
  • Containing 13 GPIO pins, 10 PWM channels, I2C, SPI, ADC, UART, and 1-Wire

Relay Module 

The relay module is an electrically operated switch that can be turned on or off deciding to let current flow through or not. They are designed to be controlled with low voltages like 3.3V like the ESP32, ESP8266, etc, or 5V like your Arduino. On top of relay modules, you will see channels which are the black cube as seen above. You may see relay modules with more channels from two channelsfour channels to also eight channels.

Soil Moisture Sensor :

Efficient irrigation management can improve yields, grain quality, conserve water and energy, and reduce nutrient leaching. One of the easiest and most effective ways to improve irrigation efficiency is to implement soil sensor technology in irrigation scheduling. This article provides basic knowledge and practical recommendations for using soil moisture sensors for irrigation scheduling.

Soil moisture sensors measure or estimate the amount of water in the soil. These sensors can be stationary or portables such as handheld probes. Stationary sensors are placed at the predetermined locations and depths in the field, whereas portable soil moisture probes can measure soil moisture at several locations

Dth11 Temperature Sensor :

The DHT11 is a commonly used Temperature and humidity sensor that comes with a dedicated NTC to measure temperature and an 8-bit microcontroller to output the values of temperature and humidity as serial data.

LDR Sensor :

 An LDR is a component that has a (variable) resistance that changes with the light intensity that falls upon it. This allows them to be used in light sensing circuits.

Light Dependent Resistors (LDR) are also called photoresistors. They are made of high resistance semiconductor material. When light hits the device, the photons give electrons energy. This makes them jump into the conductive band and thereby conduct electricity.

Breadboard

A breadboard is a rectangular plastic board with a bunch of tiny holes in it. These holes let you easily insert electronic components to prototype (meaning to build and test an early version of) an electronic circuit, like this one with a battery, switch, resistor, and an LED (light-emitting diode).

OLED display :

2.44 cm (0.96 Inch) I2C/IIC 128×64 OLED Display Module 4 Pin – White Color is a precise small, White OLED module which can be interfaced with any microcontroller using I2C/IIC protocol. It is having a resolution of 128×64. OLED (Organic Light-Emitting Diode) is a self light-emitting technology composed of a thin, multi-layered organic film placed between an anode and cathode. In contrast to LCD technology, OLED does not require a backlight. OLED possesses high application potential for virtually all types of displays and is regarded as the ultimate technology for the next generation of flat-panel displays.

Connecting Wires

Transistor

Resistors

DC Water Pump

Working Principle

NodeMCU  controlling module is used for gathering the data from sensors like LDR(Light dependent Resistor), Temperature 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 temperature sensor to regulate the water on the crop’s root which will keep the crop fresh. NodeMCU  is gathering the data from all sensors and sending/publishing all the data to the MQTT server and subscribing to the motor control topic. 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 NodeMCU  will publish for the topic

stechiez/agree/light , stechiez/agree/temp , stechiez/agree/soil , stechiez/agree/mstatus

Publish the topic from controlling node and NodeMCU 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 NodeMCU 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, NodeMCU will send the collected data over mqtt.

Connection diagram for this project as follows. :

MQTT ( The Standard for IoT Messaging ) :

MQTT is an OASIS standard messaging protocol for the Internet of Things (IoT). It is designed as an extremely lightweight publish/subscribe messaging transport that is ideal for connecting remote devices with a small code footprint and minimal network bandwidth. MQTT today is used in a wide variety of industries, such as automotive, manufacturing, telecommunications, oil and gas, etc.

Reason to choose MQTT :

  • Lightweight and Efficient
  • Bi-directionalCommunications 
  • Scale to Millions of Things
  • Reliable Message Delivery
  • Support for Unreliable Networks
  • Security Enabled

Code Explaination :

We will assign the pins to respective sensors and motor as follows, the steps are as follow of that code :

Enter the SSID and Password so that NodeMCU will get connected to the mentioned SSID

Now Enter the MQTT server details like Server address, Port, Username and Password

In the Setup Function, we are initializing the Serial communication and Wifi Connection and trying to connect to the internet.

Now in the snippet we are reading the NTC Temperature sensor, we are averaging it and we are returning the value,

After that we are reading the Temperature sensor, we are averaging it and we are returning the value,

Now we are reading the Soil Moisture sensor, we are averaging it and we are returning the value,

Here are reading the LDR sensor, we are averaging it and we are returning the value,

Finally In the Loop function we are reading all the above three sensors and publishing the data to the MQTT server

NOTE : for getting complete code mail to me , here is just an idea about it ( (IEC2020089@iiit.ac.in)