AgriAid V2: AI Self Managing Irrigation System
by ElectraFlame in Circuits > Electronics
87 Views, 0 Favorites, 0 Comments
AgriAid V2: AI Self Managing Irrigation System
A HUGE SHOUTOUT TO MY FRIEND @DarkFLAME who helped me make the 3d model of this project and made it possible to implement AI in this project in the first place.
this is the version 2 of my previous project AgriAID : IOT based smart irrigation system.
The main idea of this project is the same as the one above, refer to it for more info. This project focuses on enhancing irrigation by providing the farmer cost effective measure to produce a huge amount of yield in fields. this method of irrigation should be highly encouraged as it does not only provide irrigation to drip irrigation crops but also to sprinkler irrigating crops simultaneously all while utilizing a single water source. the project utilizes PREDICTION SYSTEM in an ANDROID APP that helps the farmer get a huge idea on the soil moisture conditions.
This project operates on two modes: AUTO mode and MANUAL mode, in auto mode, the farmer does not need to worry about watering the crops in time as this irrigation is automated, based on the moisture threshold set, the water is supplied to crops when the soil is dry. In manual mode the farmer has control over when to water his field, he can toggle on and off buttons that only function in manual mode. The modes of operation can be switched by the control on android app.
The android app function on API from openweathermap, which provide forecast for a particular city when given input. the android app also presents the farmer with forecast of weather in 3 consecutive days.
THIS PROJECT DEMONSTRATED HERE FOCUSES PURELY ON MODEL MAKING PERSPECTIVE. LARGE SCALE IMPLEMENTATION IDEA IS PROVIDED AT THE END.
Downloads
Supplies
Major supplies:
- Raspberry pi accesories and main requirents. [ eg: keyboard, mouse, monitor etc. ]
- arduino UNO
- hardware requirements - Wires, pump, relay, SM sensor, pipes and batteries
- cardboard
- thick foam
- hot glue gun
- pastel sheets [ to cover the cardboard ]
- sprinkler setup - a container with holes in it to perform sprinkler irrigation
- water container
- mobile [ to operate the irrigation setup ]
- tulsi leaves - to create the look of a crop
- soil
- grass weeds for creating a field like feel.
Planning the Functionality
The functionality of the project is described in the above image, refer to it for getting the base idea on how to implement it.
Making the Circuits
developing the circuit
- Connect the arduino UNO to the raspberry to create a serial communication using a usb.
- connect the SM sensor and relay + pump to arduino as given above
- use batteries to power the relay module
- connect the SM sensor to arduin Wifi module.
- finally connect the camera module to raspberry pi.
REFER TO THE CIRCUIT IMAGE PROVIDED ABOVE.
Coding the Arduino UNO
WE need to program the arduino UNO board in order for it to perform operations on controlling the pump. the code is provided below.
The above code is controlling relay based on moisture levels ONLY IN AUTO mode. the dependency of it from switching into auto and manual mode is from the serial command given by the raspberry pi in either 0 or 1. which i will later provide in this instructable.
it is also sending data to raspberry pi in format [ soil moisture level, pump state -on / off ].
Programming the Raspberry Pi
Now we need to program the raspberry pi to create a server to send data to android app. Creating the android app is given in the next step. in order to do so, we need to provide a port for this communication.
In order for the raspberry pi to receive the serial messages sent [ soil moisture, pump status - on/off ] we need to enable it to create a communication panel for the arduino connected to amc/usb xyz port of the raspberry pi.
the code is as follows, however this is the COMPLETED code for raspberry pi which also includes the MACHINE LEARNING part and also the process of receiving data from server.'''
The above code contains installing libraries that cannot be installed by normal pip, either use a virtual environment or put the library files in your directory. The code deals in both sending and receiving data from the kivymd app in mobile. it sends the soil moisture and pump status, simultaneously waiting for a response from kivymd app. the kivymd app here sends the operation of modes in this project. it also sends the data of targeted value to predict soil moisture. the raspberry pi then uses ML to analyze a dataset from your directory and then sends back the soil moisture predicted value. Now the raspberry pi sends the value in format :
[ soil moisture, pumpstatus ]
[ predicted value - by default 0 ]
This way it establishes a two way communication between the server and client.
Making the Android App
To make the android app, first we need to develop the GUI. I am using KIVYMD framework in python to develop this app. I advice first developing this in PYDROID3 for gui convenience. developing it in a laptop and then implementing git to a mobile device might scatter the gui. however if you need to proceed with developing the app in laptop, specify your screen size according to your needs.
The app shall contain 5 tabs:
Tab1: It contains the data received from raspberry pi regarding sm data and pump state. it presents the soil moisture level in a linear graph as well as in a label.
Tab2: It contains the pump control, it first contains 2 buttons, allowing the user to switch between manual and auto mode. and again two buttons that only act if manual mode is on to start and stop the pump according to will. at the bottom it has a label that showcases the pump state if its on or off as received from raspberry pi.
Tab3:
THANKS TO SBDEVELOPER for this tab's layout and coding the functionality.
https://www.youtube.com/watch?v=CRj39iFiI1E
It contains the info from API that shows the humidity, moisture, windspeed and temperature of a city when inputted.
Tab4: This is the main prediction tab that predicts the soil moisture value. it contains inputs for the the assisting values, windspeed, and moisture or any two values of your choice according to the database you have.
Tab5: This is the last tab that has the forecast for three consecutive days when entered a city name. it uses api to get the value from google.
The coding for this app is as follows, make sure to have these libraries installed. the code given is the whole code for this app and contains the coding of sending data too.
Hardware Setup
Making the hardware setup for this project is ez. divide your whole project into 3 segments on a cardboard or a thick foam. gluegun the cardboard above it to make it stable. now enclose this setup with cardboard such that they form boundaries. now make the segments as follows:
Segment1: Circuitry segment: as the name suggests this segment is dedicated to putting all the circuits in. make space for the hdmi, power, and soil moisture to stick out so that these are connected respectively.
Segment 2: Drip irrigation: this is the segment where drip irrigation takes pace, put soil here and then add a few leaves of coriander so that it makes a crop like feel. create poles for the pipe to stand on to perform drip irrigation.
segment 3: sprinkler irrigation: this is the segment where the sprinkler irrigation happens continue the pipe from drip irrigation till the middle of this section after which connect it's end to the sprinkler like setup you made. now place the setup of this pipe such that the sprinkler is standing. finally place soil and grass weeds to give a field like feel.
ALL SOURCE CODES:
The code for all three are given below kindly refer to it.
Large Scale Implementation
To implement this in a large scale envision that you are standing in your field, then take measurements for your division of fields into sprinkler and drip, making the circuits section is not necessary as adding the circuit directly anywhere near the tank can do the job. now implement the same functionality as the prototype.
Your filed since now divided into drip and sprinkler irrigation setups can function perfectly. however requirement of wifi or ethernet or sim is necessary for the board and the app to communicate.
Fell free to implement this project in a large scale.
Conclusion
In conclusion this COST EFFECTIVE project helps the farmer in many ways as it provides a good yield and conserves water utilizing both sprinkler and drip irrigation. this way farmer is not able to grow any one type of crop however also multiple. the android app adds to a layer of automation and control over the irrigation. the prediction systems satisfy the farmer when he has put the field in manual mode.