Design and Implementation of IoT based Automated Tomato Watering System Using ESP8266

Tomatoes need a proper watering system in order to grow and provide optimal yields. The factors that must be considered in watering the tomatoes are soil moisture and air temperature. The soil moisture needed for planting tomatoes is between 60% to 80% with a temperature rate between 24 to 28 degrees Celsius. We propose to implement an IoT based agricultural technology innovation to address the problem of precise watering system based on soil moisture and air temperature rate, which can be controlled remotely via internet connection. This system was designed and assembled using ESP8266 with soil moisture sensor and DHT11. This system was also programmed to be controlled using the Telegram Messenger application. The data read by the sensor could be seen through the Telegram Bot and do watering the plants automatically or manually. Based on several experiments conducted in this study, the system could do watering as well as maintain and control soil moisture and air temperature properly. By using this system, it will be easier for farmers to control and maintain tomato plants from anywhere and anytime through the Telegram Messenger.


Introduction
Tomato (Lycopersicum Esculentum) is one of the horticultural products that must be ensured in Indonesian household needs. The demand for tomato commodities in the household market reached 631.290 tonnes in 2019 [1]. However, this high level of demand was not followed by a high level of production. There are various factors that influence the low production of tomatoes, one of them is the agricultural sector in Indonesia still applies conventional systems and rarely implements technology, such as utilizing Internet of Thing technology for precise agriculture Currently, there are several factors that become obstacles in using IoT for smart agriculture especially in Indonesia. Firstly, software development for IoT-based applications, such as irrigation for agriculture, is not yet fully automatized. Furthermore, advance IoT software platforms are still missing, for automating part of the process and integrating different technologies such as IoT, big data analytics, cloud computing and fog computing to deploy applications for smart watering management. The next issue is the integration of heterogeneous and advanced sensors requires adequate standards and information models [2]. Tomato plantation watering process is a very important activity in order to avoid crop failure. One components that must be considered is soil moisture, because it plays role in the process of transferring nutrients and other compounds from the soil medium to plants, maintaining plant temperature and  [5]. Tomato plants must have optimal soil moisture between 60% -80% so that the soil is not too dry or wet [6]. Air temperature also plays an important role in the tomato growth process. The ideal temperature for tomatoes to grow properly is 24-28 degrees Celsius. If it is too high, the growth and development of flowers and fruit is not optimal, tomatoes will tend to be yellow. If it is too fluctuated, growth will be low and stunted, and tomatoes will not ripen evenly [7]. Soil moisture and air temperature are two aspects that can be used as the basis for creating a precise watering system. Sensors that are placed in the ground will be connected to a relay using an effective communication protocol and provide a very low duty cycle [3].
In general, farmers in Indonesia do watering manually by providing water according to schedule. If the plants get water at the proper time then it helps to increase the production from 25 to 30 % [8]. We need an automatic system that can water plants and monitor soil moisture for the maintenance of tomato plants. Through this system, the farming process is expected to be more precise, thereby reducing the risk of crop failure in tomato farming. In addition, the use of a precise watering system will reduce the waste of fresh water. The agriculture sector consumes a major portion of the freshwater. Due to lack of cost-effective intelligent irrigation systems, developing countries are consuming more water in contrast to the developed countries for achieving the same yield. For example, India has approximately 4% of world's freshwater resources to serve 17% of the world population; however, it takes 2-4 times more water for some of its major agri-produce in comparison to the other countries like China and USA [9].
Various studies have been conducted to design automatic plant watering system. Gunawan [10] used soil moisture, room temperature and pH controls for tomato plants watering system. Nath et al. [11] used a soil moisture sensor and a DHT11 sensor with Arduino control, with data presentation via LCD in building automatic watering system. However, there are still gaps in these studies that the automatic watering system can only be controlled and seen at close range by the user. It would be better if the system can be controlled remotely by utilizing Internet of Thing technology which is experiencing rapid development recently. Therefore, in this study we will design an automatic tomato watering system that can be controlled remotely through an android application which is easily accessible and widely used by the public today, namely the Telegram Messenger application.

Methods
In this research, we designed an automatic watering system based on the block diagram as shown in Figure 1. Based on Figure 1, there are several components that are used in automatic watering systems. The explanation of each component is as follows.

ESP8266
This watering system uses ESP8266, which is a Wi-Fi module so that the system can be connected directly to Wi-Fi and can be connected to TCP/IP. ESP8266 can be used stand alone or by using an additional microcontroller such as Arduino as the controller. This module requires low power consumption, only requires around 3.3v of power so it is widely used in the latest IoT devices [12].

Router/Wi-Fi
The system requires a Router in order to connect with the Telegram Messenger Bot API via the internet. API (Application Programming Interface) is a technology that allows programmers to exchange data through several different devices via internet. By using an API, a device that does not have a dedicated IP Public can communicate with other devices by using API secret code. The watering system will be connected to Telegram Messenger application which can be accessed by using Android devices, so that users can monitor the plant anywhere via Telegram. We can also program an alarm or notification as needed, for example if the soil is too dry, the telegram bot can display a notification via telegram chat that the plant is experiencing drought so that the water pump will be activated.

Soil Moisture Sensor
Soil Moisture Sensors are used to measure the water content in the soil. On this sensor there are two conducting plates, if the two plates are exposed to the conducting medium, in this case water, the electrons will move from the anode to the cathode, producing an electric current which will cause a voltage. The movement of these electrons is used to detect whether there is water in the ground or not [13].

DHT11
DHT11 consists of two sensors, a capacitive humidity sensor and a thermistor. DHT11 can measure temperature and humidity at the same time. Data from these two sensors is processed in the IC controller [14]. The IC controller will generate a single wire bi-directional data output which is then inputted into an automatic flushing system. If the humidity and temperature data reach the specified threshold, the system will send a notification to the user via Telegram. Besides the affordable price, the advantages of this sensor module compared to other sensor modules are the quality of sensing that is more responsive in measuring objects of temperature and humidity, and the sensed data is not easily interfered with. When data received from DHT11 and Soil Moisture Sensor reach the specified threshold value, the relay will become as automatic switch to turn on or off the water pump. The pump works for supply water to plants. Sensor data will be displayed on the system via LCD 16x2. Users can monitor their plants remotely via Android which displays the data to the user through the Telegram Messenger.

Result and Discussion
The components used in this study were ESP8266, Soil Moisture sensor, DHT 11 sensor, LCD, buzzer active and jumper wires. While the other tools needed are Telegram Messenger and Arduino IDE. The device used as the control center for this automatic plant watering system is the ESP8266. ESP8266 is a System on Chip (SoC), this device can store and transfer data. The ESP8266 will be programmed using the Arduino Integrated Development Environment (IDE) together with other supporting components. Later, the tools will run based on command messages that we send via telegram by using the Botfather feature on Telegram. In the circuit scheme as shown in Figure 2, we used two sensors, namely the DHT11 sensor to detect room temperature, and a soil moisture sensor to detect soil moisture rate in tomato plants. These sensors are very helpful for alerting the humidity level of plants or monitoring soil moisture. This system is connected directly to telegram chat via the Telegram Bot feature.

Figure 2. Schematic of Automatic Tomato Plant Watering System
The final device that had been assembled based on the schematic design above can be seen in Figure 3. Telegram has a feature called "Bot Father". To start building a bot, the first step is to type "Bot Father" in the search field in Telegram application. Then on the first page, type /newbot. The botfather will automatically send an automatic message containing certain information. Then provide a name for the IoT program that has been designed with the specified format. The botfather display on Telegram can be seen in Figure 3.

Figure 4. Telegram Bot Registration
Bot father will send the API code as the identity of our system. The code will be entered into the Arduino IDE program, as shown in Figure 4. The Telegram bot that has been created is connected to Arduino via the ESP8266 Module which is connected to Wi-Fi by entering the SSID and Wi-Fi password. The program must enter the token that has been provided by Bot Father and enter the Telegram ID, so that users can access the bot via their Telegram account. The workflow of the automatic tomato plant watering system can be seen in Figure 4. First, the experiment was started with the initialization process, the goal was to recognize several connected devices and the data needed to be processed by the microcontroller. The next step is to carry out the data reading process. There are two sensors involved, namely DHT11 sensor to detect room temperature and a soil moisture sensor to detect soil moisture content in tomato plants. After the sensor data are received by the microcontroller, it will be used to determine the activation of the relay connected to the water pump. The pump will be activated if the input value is in accordance with the parameters that have been set, and the pump flows water to water the tomato plants. If the input value has not reached the parameter to stop, the pump will continue to be active. If it matches the terminate parameter, the pump will automatically stop. This system can stabilize the input parameters to match the parameters that have been set.
This system is also integrated with android via the Telegram Messenger application. When all the circuits and components are ready, the sensor parameters will be read by the microcontroller. Then the data will be sent via Telegram application to the user. By using Telegram application, user can monitor their plants remotely and monitor the sensor parameter values. If the sensor parameter value is less than predetermined setpoint value, there will be no action and it is only monitoring. If the parameter value is more than or equal to the setpoint, the microcontroller will send a notification to android to perform watering action or the tool will automatically flush itself. If the user wants to do watering right away, the tool will immediately do the watering even though the parameter value is less than the setpoint. The test was conducted several times to test all components involved in the system had already worked properly in accordance with the program that had been made. Tests were also carried out to determine the sensing results of each sensor. The output data from the sensor devices will become input data which is then processed and becomes a reference for monitoring the need of water in tomato plants. Testing results of soil moisture sensor in this system can be seen in Table 1.