Implementation of Smart Agriculture System using IoT on ThingSpeak cloud and MATLAB

Today the use of advanced technology such as IoT devices in the field of agriculture is inevitable. There were no conventional methods to accurately predict the temperature changes or to detect the presence of an intruder in the field or to detect if a fire had broken out in the field. But with the advancement of various sensors in IoT, it has become very easy to acquire the data, analyze the data, or even take some immediate action like sending the notification to the user about any particular event. In this paper, a novel approach has been implemented to acquire and analyze the temperature data. An experimental model showing the interfacing of three sensors TMP36, PIR, and Gas sensor with Arduino has been presented. The transfer of data to the ThingSpeak cloud has also been done with the help of ESP8266 and further the analysis of data is done using MATLAB. This hardware interfacing ensures a small and cost effective design that is easily portable.


Introduction
There has always been an increasing demand in agricultural commodities with a rapid surge in demand seen especially during the time of pandemic.With the increase of population, the pressure on the farmers has increased to produce the best yield possible and that is accomplished by the use of best farming practices combined with the latest technology.The innovation in IoT technology has given various new techniques which can be very beneficial in the agriculture sector.A variety of different IoT devices and technologies can be employed to automate different processes in the agricultural system.Various sensors like temperature sensor, motion sensor, gas sensor, soil sensor, etc can be used in agriculture to gather the data that can be used to give an analysis of data or can be used as a training set to predict future outcomes.The data acquisition from sensors plays a very important role in the sustainable development of improved farming techniques by providing a way to do some critical analysis on the data.When combined with machine learning algorithms, this data acquisition from the sensors can be used to create datasets that can be utilized to train any prediction model.The temperature data can be analyzed to predict the crop yield and hence can be used as a precautionary measure in the future season.The gas sensor can sense the harmful emissions and can be proved very crucial equipment in alerting a user in case of a fire.The motion sensor can be used to find the presence of any intruder, cattle or any other animal especially during night time.It can be positioned at some height and can detect the motion within a few meters.The use of soil sensor can help in finding the moisture level in the soil which can be very useful in the draught seasons to find the water content in the soil.There are very other useful sensors that can be used in the agriculture sector that can help IOP Publishing doi:10.1088/1755-1315/1285/1/012022 2 the farmers to predict the right time for sowing the seeds so that the proper yield can be attained.In this paper, we have demonstrated the use of such sensors to acquire the data and then transfer it to the cloud to do the useful analysis.Such a system can be designed at a very low cost and can be easily managed when further modifications are required.

Related Work
Zhijin Qiu et al. ( 2017) [1] proposed the novel approach to data acquisition using the advanced middleware that can work with multifarious data input sources.Data can be acquired from different sensors in different formats and needs to be fed as input to other sensing devices or needs to be pushed to the cloud for further analysis.So the idea to acquire the data from the middleware combined with the heuristic method to increase the efficiency can be proved surprisingly fecund to open new areas of data acquisition optimization.Hence the heterogeneous data can be easily acquired and processed.
Syed Wali et al. (2018) [2] shows the usage of a low cost data acquisition efficient device that can help lay hold of the analog or the digital data.Arduino as the microcontroller takes the input from the sensors and combined with Raspberry Pi enables the computation of various parameters efficiently.The range of the sensing devices is improved by the usage of an amplifier to make a cost effective prototype.The usage of Python scripts purposefully helps in the management and analysis of the results for further study.The proposed system also increased the power management and proves less expensive than the previous methods of data acquisition.
Souvik Banerjee et al. (2018) [3] solves the problems of medical practitioners by introducing a system that acquires the data in the form of beats from the smart sensing devices and outputs the results that helps in the continuous monitoring of the patients through the use of IoT devices and various machine learning algorithms that helps in analyzing the already processed data and interpolate the results of the similar future inputs.The data acquired from the smart medical sensing devices helps in finding the correlation of the symptoms and reduces the expenditure in terms of the infrastructure required by any medical professional.The oxygen level of the patients, the blood pressure and various other parameters related to the health of a patient can be continuously monitored by sensing the beats and a numerical analysis for this will help in identifying the various health risks that can occur in different age groups and therefore can help in predicting the precautionary measures required to keep the patient's health regularized and free from any diseases and thus helping the patient to have a healthy life.
Manjunath Kondamu et al. (2020) [4] pointed out the various concerns for the road safety of the rider which are otherwise neglected by the rider's own part as by over speeding and not properly focusing on the road.The proposed work introduces a digital speedometer that will help the riders to track various parameters and will also enable them to see the important notifications coming on their mobile on the instrumentation cluster of the bicycle avoiding them to distract themselves from the usage of mobiles while driving.The calorie tracker setup will precisely provide the input to the microcontroller and will then display the information to the rider to keep track of the miles they have covered and how many calories they have burned.This setup is very cost efficient even when compared to a smart watch and can work up to a week on a single charge.
Harsh Singh et al. (2020) [5] proposes the capturing of signals in terms of voltage and current from the renewable energy sources and using the IoT technology helps in designing the power optimization techniques.The hydro power is generated from the water pressure and can be used to provide the electrical signals.The wind energy getting produced from the strong winds also generated the electrical signals.The solar energy gathered from the solar panels also generates the electrical energy required as input.A continuous power can be gathered from these sources and an automatic relay 1285 (2024) 012022 IOP Publishing doi:10.1088/1755-1315/1285/1/0120223 switch helps in the load scheduling in a better way.Further the analysis of the results obtained from these natural sources of input can help in determining the power intensity in different seasons.

Research Methodology
A variety of applications can be designed using IoT.The power of incorporating the use of IoT with automation has helped to design smart systems that can help ease our work significantly.From the agriculture point of view, the analysis of temperature data can be a very crucial factor in deciding various farming techniques in a particular season.In this paper we are primarily focusing on the analysis of the monthly temperature data gathered from the hardware sensors and then passed to the Arduino microcontroller which further transfers the data to ESP for pushing it to the ThingSpeak cloud.The option of MATLAB analysis is also provided on the cloud that can be used for the generation of any kind of graphical data that helps to easily visualize the data outputs.To detect the temperature, the TMP36 sensor is used.

•
The sensor supplies the input to Arduino in the form of analog signals.

•
Arduino works on 5V power supply and it places the data on its Tx pin to transfer it to the ESP wireless device.
• A voltage divider circuit is used to stabilize the voltage because the sensors, microcontrollers, and ESP operate at different voltage levels.
• The Rx pin of the ESP device takes a 3.3V input signal.So the 5V output of the Tx pin of Arduino is converted to 3.3V input for the Rx pin of the ESP.

•
After receiving the data, the ESP device transfers it to the ThingSpeak cloud for further analysis.
• A Smart Agriculture channel is created on ThingSpeak cloud where the data will be stored and processed.

•
On the ThingSpeak cloud we can do the analysis of data using MATLAB commands and can also visualize the data in the form of various types of graphs.

Fig. 2 Flow of data from the input to the analysis phase
The above figure gives a clear understanding of the methodology adopted to gather the data from the sensors and transferring to the Arduino microcontroller which can further transfer the data to ESP from where we can easily put the data on the cloud and carry out the analysis.

Experiment Setup and Results
The figure shown below in 3(a) shows the TMP36 sensor to sense the temperature.This sensor operates on 2.7V to 5.5V power supply and provides the analog output that can be seen as the qC temperature and hence can be easily used with Arduino.The ground pin of the sensor is attached to the GND pin in Arduino and the signal pin can be attached to any analog pin of the Arduino.The Passive Infrared Sensor (PIR) shown above in 3(b) is used to detect the motion of an object that comes in its range.The engagement of the sensor starts when an object comes in the range of the sensor and it detects the heat energy radiating from that object.In agriculture, the PIR sensor can very useful in the detection of any animals like cow, goat, etc at night time [8].The gas sensor shown above in 3(c) is another very useful sensor to detect the emissions of harmful toxic gases that may be able to occur in case fire.This sensor can be used by the farmers to easily detect if a fire breaks out in the field.The open source Arduino microcontroller provides a hardware platform to integrate different types of sensors on its board [6].In our study the TMP36 sensor provides the input signal on the analog pin of Arduino.Along with the analog and digital pins, Arduino also provides some Pulse Width Modulation (PWD) pins for the variable output such as in case of increasing or decreasing the fan speed.We have also connected a buzzer to Arduino to simulate the sound effect.The buzzer also has an input pin and a ground pin that are connected to Arduino digital pins.Every time the 1285 (2024) 012022 IOP Publishing doi:10.1088/1755-1315/1285/1/0120225 temperature rises above 40 qC, the buzzer starts buzzing.Every system designed in Arduino requires two functions to work i.e. the setup() and loop().The syntax of these functions is shown below void setup(){} void loop(){} The code in the setup() function runs first whenever the Arduino system powers up.The code inside the loop() function runs repeatedly until a certain condition is met or the system turns off [7].

Fig. 4 Arduino Uno R3
From the Arduino we need to transfer the data to the ESP8266 device.The transfer and receiving of data on Arduino and ESP is done using the Tx and Rx pins.In order to transfer the data we connect the Tx pin of Arduino to the Rx pin of ESP and in order to receive the data we connect the Tx of ESP to the Rx of Arduino [9].Since the Tx pin of Arduino works at 5V power supply and the Rx of ESP works at 3.3V, we cannot directly send the data between these two.So to transfer the data we need to convert the Tx output of Arduino to 3.3V.For that we use the voltage divider circuit to convert the 5V voltage to 3.3V voltage.The above figure shows the complete experimental setup that interfaces the various sensors on Arduino.The TMP36 and Gas sensor provides the analog input to Arduino.The PIR sensor on detecting an object provides the digital input to Arduino.A buzzer is also interfaced with the PIR sensor which will buzz whenever the sensor detects any motion.The Gas sensor on sensing any emissions in case of fire will generate the analog signals that will be sent to the Arduino microcontroller.A DC motor is also interfaced with Arduino for the power supply.The voltage divider circuit takes care of dividing the voltage between Arduino and ESP.The output of the voltage divider circuit is 3.3V that is consummate to the ESP device for its proper working.Now the data needs to be pushed to the cloud by the ESP device.The results from the MATLAB analysis can be used in making the future predictions about the weather using a Machine Learning algorithm.The smart agriculture concept can be further enhanced by the integration of some more sensors that can give an insight on different aspects of the captured data.

Fig. 1
Fig. 1 Functional flowchart of the research methodology

Fig. 3 (
Fig. 3 (a) TMP36 Temperature Sensor (b) PIR Sensor (c) Gas Sensor Voutput is the output voltage required by the Rx pin of ESP to operate and the value is calculated as 3.3V.R1 and R2 are the values of the resistors and V_input is the input voltage of the Tx pin of Arduino.

Fig. 6
Fig. 6 Experiment setup demonstrating the interfacing of TMP36, PIR Sensor, and Gas Sensor on Arduino and its connection to ESP on Tinkercad