Automated Irrigation System using STM32 and Modbus RTU Protocol

Download Full-Text PDF Cite this Publication

Text Only Version

Automated Irrigation System using STM32 and Modbus RTU Protocol

Mr. Mahadev Prasad B

M.Tech Student

Electronics and Communication Engineering DECS, VTU PG Center, Mysuru

Karnataka, India

Mrs. Pushpalatha S

Assistant Professor

Electronics and Communication Engineering DECS, VTU PG Centre, Mysuru

Karnataka, India

Abstract Irrigation is the practice of watering farmland to make it ready for agriculture. It allows to agriculture crops, maintain landscapes in less rainfall areas. Agriculture land in India was about 60.45% in 2016 according to World Bank. Water usage from ground water is about 65% for irrigation. This project is focused on efficient use of ground water without wastage or overflow of water on farmland using moisture sensor connected to microcontroller. STM32 a 32 bit ARM cortex-M3 microcontroller is used which is more efficient compared to other microcontroller. Also Modbus RTU protocol is used to cover wide area of farmland for monitoring. Moisture sensor value is sent to cloud for remote monitoring and analysis of data using GSM Module. This system reduces the risk of low crop yield due to shortage of water. Automated irrigation system can be used for analysis of the different crop water consumption and also nature of the soil.

Keywords Automated Irrigation; Modbus RTU protocol; Moisture sensor; SIM900 GSM module; STM32F103C8 IC; ThingSpeak IOT platform.

  1. INTRODUCTION

    The automated irrigation system refers to the system with no or minimum of farmer involvement except some urgent need when there is a failure in system and no need of water in some situations. Growing of crop with good yield improves farmers life and as well as availability of large amount of raw materials for textiles, jute, sugar, tobacco industries. Need for large quantity of food is required to feed large population in India. To meet this requirement quantity and yield of crop is very important. Quantity and yield of corps and soil productivity depend on quantity and quality of water for irrigation. Suitability of water for usage in agriculture is determined by factors such as PH, Salinity, Carbonate and bicarbonates, Toxic anions, Nutrients. Sources of water for irrigation are rainwater, lakes and rivers (surface water). Other sources of water are reuse of municipal wastewater and drainage water which must be tested before using it to irrigation. Automated irrigation system reduces efforts of farmers. Disadvantage of surface irrigation is over flow of water from agriculture land which is not utilized for growth of crops. Using automated irrigation system manual turn on or off the ground water pump is avoided in which farmer can monitor water for more crops without any risk, saving of underground water from unnecessary wastage and avoiding loss of soil structure and nutrients.

  2. LITERATURE SURVEY

    Xin Fang[1] has published the paper in which STM32 is used to control the pressure of water flow to the

    residential area buildings. Pump set is controlled through variable frequency device or frequency converter. Frequency inverter control the motor speed to which in turn decides water outflow from the pump set and to the buildings. Komal Kumar N[2] proposed the system in which MH Sensor series KY-033 with moisture sensor is used to check amount of water present in the soil and moisture content parameters can be modified according to the crop in which farmer grow in his land. Aurdino Nano is used as a controller. Indranil Banerjee[3] developed a project in which Si7021 moisture sensor and PH sensor data is uploaded to cloud or server. There are three main blocks such as nodes, hub and server or cloud. Nodes has Aurdino Uno and it is connected to Pump, moisture sensor and PH sensor for detecting moisture or water content level in the soil and soil fertility. Wenzhu[4] You proposed the system with embedded Modbus gateway which has ARM5708 processor. Project has STM32F103VC controller which is connected to DHT11 digital temperature and humidity sensor, MQ-2 and MQ-7 gas sensors used for gas detection in buildings. Shivang Raj[5] proposed a project with different farmland in city which is used for government to visualize the requirement of water for different types of crops. By this analysis supply demand problem can be solved. This project has several sensor networks connected to the local IOT network. Dataset collected from each crops and climatic conditions. For this dataset K-Nearest Neighbors (KNN) algorithm is applied to find out the top three crops which is best suited for the particular farmland.

  3. PROPOSED METHODOLOGY

    1. Block diagram

      The proposed system as shown in Figure 1 consists of water level sensor, 16*2 Display, GSM Module, DC motor, STM32 board, MAX485 Module, Aurdino Uno board, solenoid value and moisture sensor as shown in the figure. In this project STM32 and Aurdino boards are used to control the flow of water to the crop based on the condition of moisture sensor value. Basically STM32 is considered as a master device that receives moisture sensor data from three slaves which are Aurdino Uno boards connected with moisture sensor and solenoid valve placed in different locations. Solenoid value is used to control the flow of water. If solenoid valve is ON, water flows to the crop. If solenoid valve is in OFF condition, water flow will be stopped representing that the water in crop is sufficient for its growth. This ON and OFF signal to valve is given by the Aurdino board according to the moisture sensor value which is in

      contact with the crop representing volumetric water content in the soil. The moisture sensor data collected by Aurdino board or slave is sent to master or STM32 through the protocol called Modbus protocol. This system can be implemented in poly house.

      Fig. 1. Block Diagram of Proposed Work

    2. Flow chart

      Fig. 2. Flow chart of Aurdino Uno

      As shown in Figure 2 ,Initialize GPIO pins for indicating Modbus data communication, initialize UART for receiving Modbus query and sending the response/ reply for corresponding request from STM32. Check volumetric moisture content in the area of land where slaves are placed. If moisture level is low, pour water to particular area of land

      through solenoid valve. If solenoid valve is energized, valve will be opened and water flow will start. If solenoid valve is de-energized, valve will be closed and water flow stops. If moisture level is high then stop flow of water. Receive query message from master and send reply using Modbus protocol. Modbus protocol initially checks for the particular slave specified in the query message format. Also query message has function code, no. of data to be accessed, address, and total query message checksum. Reply message has function code, no. of data sent, Moisture sensor data and checksum.

  4. SYSTEM IMPLEMENTATION

      1. Modbus protocol

        Master sends a request with function code and data request and Slave responds with the same function code and corresponding data response with certain action performed based on request. Master receives a response. If there is an error detected in request from Master. Slave sends an exception code along with its function code to Master. Table I represents Function Codes with its definition.

        Table I. Function Codes with its definition

        SI No.

        Function code

        Definition

        1

        01

        Read coils

        2

        02

        Read discrete inputs

        3

        03

        Read holding registers

        4

        04

        Read input register

        5

        05

        Write single coil

        6

        06

        Write single register

        7

        15

        Write multiple coils

        8

        16

        Write multiple registers

      2. MAX485 Module

        Fig. 3. MAX485 Module

        MAX485 on-board chip as shown in Figure 3, it is a slew rate limited transceiver used for RS-485 communication. It consumes low power for its operation. It works at 300µA current rate and +5v power supply. It supports half-duplex communication to apply the function of converting TTL level into RS-485 level. It can send data at maximum transmission rate of 2.5Mbps. This module draws supply current between 120µA and 500µA. Driver outputs can be put at a high impedance state through the thermal shutdown circuit with limited short circuit current. Receiver input of Max485 Module has a fail-safe feature which guarantees logic high output if the input is open circuit.

      3. Moisture Sensor Module

        Amount of water present in soil can be identified by moisture sensor YL-69 or HL-69 by connecting it to Aurdino. Moisture sensor has two hardware components: one is the electric board and other is the probe with two copper pads that detects water content by calculating conductivity between them. Electric board has two analog (A0) and digital (D0) output signal pins. LEDs for indicating power input to

        the board as well as digital output threshold level. Moisture sensor Module is shown in Figure 4.

        Fig. 4. Moisture sensor electric board and Moisture sensor probe

      4. STM32 Development Board

        Fig. 5. STM32 Development Board

        STM32 Development Board (Blue Pill) is shown in Figure 5. It has 32-bit CPU and ARM Cortex M3 architecture. KEIL µVision5 IDE is used to program STM32 board. These boards are cheap and the hardware is open source. STM32F103C8T6 is the microcontroller present on top of it. The board has 8 MHz crystal for CPU clock and 32 KHz for RTC clock. Microcontroller can operate in sleep mode which is suitable for battery related applications. Red color LED is used for power indication and Green color LED is connected to GPIO pin PC13.

      5. Aurdino Uno board

        Fig. 6. Aurdino Uno board

        Aurdino board is shown in Figure 6. It has fourteen digital input or output pins and PWM signals can be produced by six digital input or output pins among them. Also there are six analog input pins which could be configured as digital input or output pins. The pins discussed before are on top of the board with 2.54mm female header. It is open source hardware with microcontroller used especially for project purpose licensed under GNU General Public License (GPL). USB serial communication interface used for loading project program from personal computer.

      6. Solenoid valve

        Fig. 7. Solenoid Valve

        Solenoid valve is shown in Figure 7. SKU (stock keeping unit is unique numerical identifying number) of this valve is 2W-400-50-12V. Its position is normally closed, port size is 1-1/12 Female NPT (National Pipe Thread), it operates with 12V DC, Body material is Brass, components are of stainless steel, it can work in temperature range of 10oC to 120oC, flow rate is of 29 CV (valve coefficient representing capability of valve to flow a fluid), it consumes power of 40 Watts and 3.25 Ampere of current, coils inside valves are connected to lead wires, its response time is less than one second, its weight is of 4 lbs (pound) 14 oz (ounce one sixteenth of pound), height is of 6 inch and length is 4.33 inch port to port, width is 3.35 inches.

      7. Hercules SETUP Utility

    Fig. 8. Hercules SETUP Utility

    Hercules SETUP utility is shown in Figure 8. It is a serial port terminal i.e. RS-232 or RS-485 terminal, UDP/IP terminal and TCP/IP terminal. It is freeware and includes many functions in one utility. It can be installed in computer with windows 7, 8 and 10. Serial port terminal works with the virtual serial ports such as COM3. UDP mode in this utility finds devices on the network and can function only on a local segment of a network. In serial mode communication port is selected with default baud rate 9600, data size of 8 bits. Moisture data is sent through GSM using AT commands. It is done by STM32 microcontroller.

  5. RESULTS AND DISCUSSION

    Aurdino Uno (slave) send moisture sensor data to STM32 using Modbus protocol and it is displayed on LCD. In regular interval of time other moisture values are also displayed. The values displayed represent the digital value which is converted from 0-1023 range to 0-255 to reduce complexity of sending large amount of data. Moisture content in the soil depends on the intensity of sunlight in a day, type of soil and plant. In this project for trial, red soil is taken in a pot and garden graphs are shown in Figure 9 and Figure 10. The same can be implemented inside poly house for growing different crops. Moisture sensor valves are noticed in hourly basis using LCD display are tabulated and plotted as shown in Table II below:

    Table II. Moisture sensor Values for a day

    SI No.

    Hours

    In pot

    In garden

    1

    0

    60

    43

    2

    1

    61

    50

    3

    2

    62

    56

    4

    3

    62

    58

    5

    4

    63

    64

    6

    5

    64

    69

    7

    6

    68

    72

    8

    7

    71

    74

    9

    8

    72

    76

    10

    9

    75

    78

    Fig. 9. Moisture values noticed in pot for a day

    Fig. 10. Moisture values noticed in garden for a day

  6. CONCLUSION

Automated irrigation system is implemented using STM32 microcontroller as master device and Aurdino as a slave device. Communication is established between master and slave using industry level protocol i.e., Modbus RTU protocol which is based on request and reply protocol. Irrigation is performed according to water requirement. Moisture sensor data is uploaded to ThingSpeak website using GSM Module for remote monitoring from farmer as well as company service provider. This project allows conservation of water with reduction of farmer intervention for irrigation. Also message regarding fault in system is sent to service provider to get quick service.

ACKNOWLEDGEMENT

We express our sincere thanks to teaching and Non- teaching staffs of Electronics and Communication Engineering department, VTU PG Center,Mysuru and Pecsol technologies, , Mysuru for suggestion and support.

REFERENCES

  1. Xin Fang, Kunao Zhang. Design and Implementation of Constant Pressure Water Supply Monitoring System Based on STM32. 2017 17th IEEE International Conference on Communication Technology.

  2. Komal Kumar N, Vigneswari D, Rogith. C. An Effective Moisture Control based Modern Irrigation System (MIS) with Arduino Nano. 2019 5th International Conference on Advanced Computing & Communication Systems (ICACCS).

  3. Indranil Banerjee, Supratim Tribady, Sayan Mukherjee. Automated Irrigation System Using Arduino and Cloud. 2019 International Conference on Opto-Electronics and Applied Optics (Optronix).

  4. Wenzhu You, Haibo Ge. Design and Implementation of Modbus Protocolfor Intelligent Building Security. 2019 19th IEEE International Conference on Communication Technology.

  5. Shivang Raj, Saksham Sehrawet, Nikhil Patwari Sathiya Kumar C . IoT based model of automated agricultural system in India. Proceedings of the Third International Conference on Trends in Electronics and Informatics (ICOEI 2019) IEEE Xplore Part Number: CFP19J32-ART; ISBN: 978-1-5386-9439-8.

  6. Kayode E. Adetunji, Meera K. Joseph. Development of a Cloud-based Monitoring System using 4duino: Applications in Agriculture. 2018 International Conference on Advances in Big Data, Computing and Data Communication Systems (icABCD).

  7. Monica M , B.Yeshika , Abhishek G.S , Sanjay H.A ,Sankar Dasiga. IoT Based Control and Automation of Smart Irrigation System. Proceeding International conference on Recent Innovations is Signal Processing and Embedded Systems (RISE -2017) 27-29 October,2017

  8. Vaishali S, Suraj S, Vignesh G, Dhivya S and Udhayakumar S. Mobile Integrated Smart Irrigation Management and Monitoring System Using IOT. International Conference on Communication and Signal Processing, April 6-8, 2017, India.

  9. Chanda Rajurkar1, S R S Prabaharan2, S.Muthulakshmi3. IoT Based Water Management. 2017 International Conference on Nextgen Electronic Technologies: Silicon to Software (ICNETS2).

  10. Kshitij Sirohi, Aastha Tanwar, Himanshu, Poonam Jindal. Automated Irrigation and Fire Alert System based on Hargreaves Equation using Weather Forecast and ZigBee Protocol. 2016 IEEE 2nd International Conference on Communication, Control and Intelligent Systems (CCIS).

Leave a Reply

Your email address will not be published. Required fields are marked *