Smart Goat System Design and Construction in IoT-Based Goat Pens using Nodemcu ESP8266

Modern agriculture requires innovative approaches in farm management to improve efficiency and security. This thesis aims to design a smart goat system in a goat pen equipped with an anti-theft security system will based on the IoT. This system uses a ultrasonic sensor to monitor the condition of the goat's drinking water needs. In addition, it is equipped with anti-theft technology that utilizes magnetic sensors on the cage door to detect people entering around the cage if the system is activated in real-time. The collected data is integrated into the blink server to allow remote monitoring by the farmer. A mobile application was also developed as a UI that makes it easier for farmers to manage and monitor the barn effectively. By combining aspects of smart cages and anti-theft systems, this research aims to provide a comprehensive solution that can enhance farm security and optimize productivity simultaneously. The tool used in this research is Nodemcu ESP8266


INTRODUCTION
In this sophisticated era, technology has developed rapidly and has reached almost all aspects of human life.One example of its development is the existence of an automation system, which works without human assistance and can perform all tasks independently.Current technology can interact with each other through the internet network, which allows for the distribution and receipt of data automatically.Users can track the performance of automated systems through the Internet of Things (IoT) capabilities to provide real-time information [1,2,3].
In goat farming, providing regular feed is the farmer's obligation to ensure that the goats do not starve.The cleanliness of the pen as a place for the animals to live must also be considered regularly.Cleaning the pen and providing water takes a long time and is often inefficient [4,5,6].Guarding the goats can also be constrained, especially because the distance between the farm location and the farmer's house is usually at least 200 meters.Therefore, the application of IoT to automate the filling of water in the goat pen can make this process more practical and increase security from the risk of theft [7,8,9].
Based on the problems that occur, the author will create an automatic system in the goat pen using a microcontroller as the main tool.In this system, IoT is used as a monitoring medium between users and devices, so that users can more easily automate remotely.The design of this system uses an ultrasonic sensor to measure the distance of water and a door magnet https://doi.org/10.56211/hanif.v2i1.29 Siti Nur Hidayah 39 sensor that can detect open doors.This study uses ESP8266 as the main microcontroller and as a communication tool with a database and can be connected to a wifi network [10,11,12].

Arduino IDE
Arduino is an open source platform that is widely used to create electronic prototypes and IoT applications.Arduino can also be programmed using a special language called Arduino IDE.Another meaning of Arduino is software used to program and develop microcontrollers [13,14,15].Because Arduino IDE is open source, users can easily change or develop it according to their needs and the source code can be accessed by the public.In the Arduino IDE software, there are many tools with different functions.There are file, edit, sketch, tools and help menus as shown in the picture below.

NodemCU ESP 8266
NodeMCU is a microcontroller created and manufactured by Espressif Systems, equipped with an ESP8266 module and all computer components, including CPU, RAM, WIFI and a more advanced SDK.NodeMCU is similar to Arduino, but has the advantage of having WiFi which makes it ideal for Internet of Things applications [16,17].

Water Pump
The water pump used in this study is a submersible pump.A submersible pump is a water pump designed to be placed directly in a water source, such as a well, tub, pond, or other container.By using a voltage of 220-240V DC, this pump is able to flow water from one place/container to another and can be controlled by an electronic system, including those based on the Internet of Things (IoT).Submersible pumps connected to the IoT system make it easy for users to control them using a smartphone [6,7,8].
IoT is used to activate or deactivate pumps, set operating schedules, or monitor water conditions.Submersible pumps work on the principle of converting electrical energy into mechanical energy to flow fluids.

RESULTS AND DISCUSSION
At this stage, a system circuit test is carried out to find the accuracy of the sensors used and check the data flow from the sensor to the microcontroller and then to the blynk platform.Running the system for a long period of time to ensure that the system functions quickly and very efficiently.The image above is a display of the smart goat user interface that uses the blynk application on a cellphone.This display is connected to the NodeMCU ESP8266 which has been programmed using the Arduino IDE software.In the display above, it is not yet connected to wifi so the system is not yet active.The image above is a series of all the tools that have been designed and started to test whether the tool works according to the design so that it can be known if there are any problems that occur when the tool is applied to the cage.The hardware series consists of ESP8266, ultrasonic sensor, magnetic sensor, 2 channel relay module, 16x2 LCD, buzzer, socket, submersible pump.In figure 8 shows the display of the active application when connected to wifi it will be green as a sign that the device is connected.

Figure 9. Relay 2 is active
If the device is connected to wifi, the blynk application and LCD display will be active.Figure 8 shows that the system mode button has been activated (ON), then the ultrasonic sensor will detect the distance of the water level in the container, if the water is less than 30 it will display a volume of 0%.This will automatically activate relay2 (change color to red) which functions to flow electric current to the water pump.If the water condition has reached 100%, relay2 will be automatically deactivated and the relay 2 light will turn off.If the ultrasonic sensor detects a water level distance of less than 3cm from the sensor, it can be said that the water level is full or in 100% condition in the application.This is done to find out the water level distance to make it easier to fill water over long distances.
The LCD also displays a log of water level data that has been detected by the sensor, the water level data on the LCD and the application are the same because they are programmed so that the data displayed is accurate.The image above is a notification from the blynk application that goes into the email to save data and provide warning information or status that occurs in the system.When the device is connected to wifi and active, the application is online and the magnetic sensor detects an open door, then the active status of the system will save the data history to the email.

CONCLUSION
Based on the results of the research and testing of this smart goat system, it can be concluded as follows: When testing the ultrasonic sensor, there is no difference in error.This means that the sensor reading is in accordance with the actual distance.No differences were found when testing the door sensor circuit and the blynk application.Overall, it can be said that the system has been tested and functions well under the conditions and circumstances designed for the system.All monitoring data for the water filling system and door security will be sent to the NodeMCUpESP8266 via the serial communication system and stored in the blynk cloud database, so that it can be monitored using the Blynk application and email.

Figure 6 .
Figure 6.Complete set of tools

Figure 10 .
Figure 10.Full Water Level