/Automated-Irrigation-System

Primary LanguageC++GNU General Public License v3.0GPL-3.0

Automated_Irrigation_System

Description

An Automated Irrigation System designed to optimize irrigation processes on the farm.

Features

  1. Irrigation control based on:
  • soil moisture
  • the amount of water in a tank
  • weather forecast (probability of precipitation)
  1. Remote monitoring and control of the system.
  2. SMS alerts to be triggered when the tank's water level is low or when the battery level of the node is low.
  3. Wi-Fi provisioning.

NB: Evening irrigation occurs at 6 pm and it depends on soil moisture and the amount of water in the tank.

Architecture

The system is split into 3 parts. These are:

  1. The master device,
  2. The node(s), and
  3. The water level detector.
    In order to reduce the cost of prototyping/development, the node and water level detector are merged into a single unit.

The master consists of the following:

  1. An HMI
  2. WiFi
  3. GSM
  4. Sub-GHz radio system (low power, long-range)
  5. A microcontroller.

The node + water level detector unit consists of:

  1. A moisture sensor
  2. A temperature & humidity sensor
  3. Sub-GHz radio system
  4. Solenoid valve
  5. Water hose
  6. Ultrasonic sensor
  7. A microcontroller.

The master performs the following:

  1. Sends sensor readings (taken by the node) to the cloud via MQTT.
  2. Communicates with the node (via Sub-GHz radio). It receives sensor readings from the node,
    as well as an alert from the water level detector (during critical conditions).
  3. Sends SMS alerts to the user's mobile phone whenever the water level is low.
  4. Retrieves weather forecasts online in order to aid irrigation decisions.
  5. Configures sensor thresholds within which the node determines when to irrigate.

The node performs the following:

  1. Obtains sensor readings (moisture and temperature) and sends them to the master
    wirelessly (via Sub-GHz radio).
  2. Controls irrigation via sensor readings and thresholds programmed into the master.
    These thresholds are sent wirelessly from master to node.

The water level detector simply checks the level of water in the tank. As explained earlier,
it is merged with the node. If there's a critical condition, a message is sent to the master wirelessly
(via Sub-GHz radio). The master will then send an SMS to the user.

Software architecture

ss_sl drawio

Mobile Application

The sensor data from the irrigation system is sent to an MQTT broker. The HiveMQ broker was used in this
project. The user can use a mobile application (MQTT client) linked to the broker to visualize the
sensor data. The MQTT Dashboard app from playstore was used. Details of the broker used are given below:

  • Broker name: HiveMQ
  • Address: tcp://broker.hivemq.com
  • Port: 1883

The application (MQTT client) is configured as follows:

  • Subscription topic: Same as the topic configured during Wi-Fi provisioning
  • Publish topic: Same as the topic configured during Wi-Fi provisioning
  • Start button: To enable irrigation. It publishes data (i.e. a payload of '1' to the Publish topic)
  • Stop button: To disable irrigation. It publishes data (i.e. a payload of '0' to the Publish topic)
  • Text box: To display data. It subscribes to the Subscription topic.

Tasks

  1. Getting weather forecast from OpenWeatherMap.org with an ESP32 [DONE]
  2. Testing moisture sensor [DONE]
  3. Setting up an RTOS application for the Master. [DONE]
  4. Setting up WiFi provisioning for the ESP32 using the following details: [DONE]
  • SSID
  • Password
  • City name + country code + API key to obtain a weather forecast and more.
  1. Testing the SIM800L library [DONE]
  2. LCD test [DONE]
  3. Keypad test [DONE]
  4. HMI [DONE]
  5. MQTT [DONE]
  6. Irrigation decision-making [DONE]
  7. Battery monitoring for the node [DONE]

Images of the prototypes

20230623_122500 20230623_122532 20230408_114212
20230408_114132
20230214_100111 20230214_100123 20230214_100029 20230208_085441
20230208_085742
MQTT dashboard
20230408_164155

Observation

  • The GND pin beside the 5v pin on some ESP32 boards isn't connected to the other GND pins because it's supposed
    to be the CMD pin. Hence this pin shouldn't be connected to the GND pin of other components without first performing
    continuity tests with a multimeter.
  • The Arduino Nano ADC doesn't work properly if the board is powered using Vin. This issue was solved by powering the board
    through the 5v pin.

Credits

  1. OpenWeatherMap.org: https://RandomNerdTutorials.com/esp32-http-get-open-weather-map-thingspeak-arduino/
  2. Firebase ESP32 Client: https://randomnerdtutorials.com/esp32-firebase-realtime-database/ [NOW DEPRECATED, MQTT is desired]
  3. MQTT with ESP32: https://microcontrollerslab.com/esp32-mqtt-client-publish-subscribe-bme280-readings-hivemq/
  4. OpenWeatherMap.org API calls (3-hour forecast): https://openweathermap.org/forecast5