Smart Pet Feeder System and Big Data Processing to Predict Pet Food Shortage

: Focusing on pet owners who have tight daily schedule or physically disabled, this project proposed a smart pet feeder system with big data processing to predict pet‟s food shortage. The project aims to help pet owners to regularly feed a correct amount of food to their pet as well as to predict the pet‟s food shortage. The components used in this system are hx711 load cell amplifier, ultrasonic sensor, infrared sensor and servo motor. The ultrasonic sensor and the servo motor will be connected to adafruit, an internet of things (IoT) platform which provide online dashboard to allow pet owners to retrieve data from the sensors as well as to monitor the system activities. The online dashboard will also be connected to ifttt maker, another IoT platform to enable notifications via telegram. Pet owner will be notified via telegram every time the food is dispensed from the pet feeder system and if the pet food level is low. The system will dispense pet food automatically either at pre-set time or when pet comes near the pet feeder. More, the system can also collect data of pet food level to be used for time-series prediction on food shortage. Time-series prediction will use parallel processing method in handling big data for data pre-processing. the of the the of to if is The to the


Introduction
Adopting pets have been very popular especially in this day and time. This is because pets make great companions, and they are very fun to play with. There are many types of pets that can be adopted such as dogs, cats and fish. However, having cats as pets are very popular because cats are allowed in public transport and more accepted in public generally (Baquero et al., 2017). However, in 2016 there were a total of 260,963 dogs registered as pets (Michel, 2008). The pet healthiness is very important. Regular feeding time is very important to keep the pet healthy. (Hanbury, 2019). However, this has created an issue to the owners who are busy and cannot make time to feed their pet on time with a correct amount of food.
A solution to these problems would be a smart pet feeder that could automatically dispense the correct amount of food when pets comes closer. It will also feature a notification on a mobile device. The purpose of the notification is to help owners to keep track of the smart pet feeder activities while they are busy (Bhargava & Kumar, 2017).
Data processing and forecasting help owners in maintaining their pet"s food, as they can assist owner in budgeting their pet"s food shortage and storage. (Horelu et al., 2016). Data analyzing and forecasting based on the pet feeder system are possible to be implemented as the data can easily be collected from the sensors attached to the system. While most of the time the data is only used for monitoring, it could be put to more use such as forecasting to provide even more information for the pet owners (Qureshi et al.,2016).
To overcome this, big data analysis and forecasting will be done based on the data received from the sensors to provide a time-series prediction on food shortage to help owners in preparing budget for their pet"s food. An algorithm using parallel programming method will be created to overcome this challenge to process the big data. The smart pet feeder will feature a data collecting method using IOT platform (Ismail et al., 2016), (Adarsh et al., 2016). The used of Arduino controller has been studied and used previously in the development of Child Safety Car Alert System Using Arduino and GSM Module (Hazizan & Lazam, 2019) Fig. 1 shows the flow of the smart pet feeder system from the beginning until the end. Fig. 2 shows the flow of data pre-processing from the beginning until the end. These will give the whole idea of the development processes on which process is to be done before initiating the other. The process flow of the system starts with detecting pet nearby and check measurement for pet"s food level. If there is no pet nearby, the system will loop back to the "start" until it detects pet. If there is a pet nearby the system will check the weight of the pet food bowl. If the pet food bowl weigh less than 0.1 lbs, it will dispense pet food until pet food bowl is weighted more than 0.5 lbs and notification will be sent to the owner via Telegram stating that the dispenser has released a certain amount of food into the bowl. By then it is assuming that their pet had been fed. Next, after the system checked the pet food level, it will send the pet food level data to Adafruit IO. In the case when the system detects the pet food level is low, it will notify the pet owner via Telegram. The whole system will delay for a pre-set time until it loops back and start again from the beginning. The process flow starts by reading the raw data of the pet food level CSV file. Next, unwanted columns that is not used for the time-series prediction is removed. Then, the string value "UTC" in the "created_at" column is removed. The "created_at" column data type is changed into date time format. The whole dataset is then resampled from every 1 minute into every 1 hour. Then "value" column is check for any Nan values. If there is Nan value, the row will be removed. Lastly, the cleaned dataset is saved into a new CSV.

Figure 3. Schematic diagram of Smart Pet Feeder
The main component in this schematic diagram is ESP32 where all the other components used in the system are connected to it. The ESP32 is connected to a power source and allow configuration of other components connected to it. The infrared sensor is connected to 5V power source for the VCC pin, ground for the GND pin and I/O port number 14 on the ESP32 for OUT pin. The infrared sensor is used to detect if pet is coming nearby to the pet feeder. For the ultrasonic sensor, the VCC pin is connected to 5V power source, ground for the GND pin, I/O port number 13 and 5 is ESP32 for the Trig and Echo pin respectively. The ultrasonic sensor will be used to measure the pet food level of the system. Now for the HX711, there will be 2 connections, to the load cell and ESP32. For ESP32, the VCC is connected to 5V power source, ground for the GND pin, I/O port number 25 and 26 in ESP 32 for the DT and SCK pin respectively. For the load cell, the A+ pin will be connected to the blue wire on the load cell, A-pin to the white wire, E-pin to the black wire, E+ pin to the red wire. The HX711 is used to measure weight readings of the pet food bowl in the system. All the 5V wire for the HX711, infrared sensor and ultrasonic sensor is connected to a common 5V which will be connected to the 5V port in ESP32. All the ground wire for the HX711, infrared sensor and ultrasonic sensor are connected to a common ground GND port in ESP32. The servo motor is connected to a separate 5V port in ESP32 for the red wire, separate GND port in ESP32 for brown wire and I/O port number 18 in ESP32 for orange wire. The servo motor is used to dispense the pet"s food in the system (Kaur & Pal, 2015) The prototype shows the position of the servo motor and infrared sensor. Also, it shows the position of the bottle that stores pet food. The infrared sensor is used to detect if pet is coming nearby and the servo motor is used to dispense pet food. The pet food bowl is attached to the load cell to allow the system to measure weight of the pet bowl. The ultrasonic sensor is placed on top of the pet food storage. The purpose of the ultrasonic sensor is to measure the pet food level in the pet food storage.

Figure 5. Serial Monitor Reading for Ultrasonic Sensor
It is shown that the ultrasonic sensor is being tested by putting an object close to 30 cm in front of it and the sensor was able to measure the distance correctly based on the results from Fig. 5. This shows that the ultrasonic sensor is working properly and able to measure the distance precisely. It is shown that the infrared sensor is being tested by putting a hand close to 7 cm in front of it and the sensor was able to detect the hand correctly based on the results from Fig. 6 as it prints "no pet" when there is no hand near the sensor and "pet" when the hand is near the sensor.

Figure 7. Serial Monitor Reading for HX711
It is shown that the HX711 is being tested by putting an object of which weighs 0.5 lbs or 200 grams on it and the load cell was able to measure the weight correctly based on the results from Fig. 7

Figure 8. Telegram notification
Notifications on Telegram from the IFTTT bot notifying the pet have been fed and the pet food is low.

Time Series Prediction
The Python library is using FBProphet. This library is chosen due to its automated forecast function and robustness to yearly, weekly, monthly and daily data. Which means the trend of the prediction will not be affected much by the amount of data gathered.
.  9 shows the source code of the time-series prediction using FB Prophet library in Python. From the source code, the first process after reading the cleaned CSV file is to assign the column names to "ds" and "y". The input for FBProphet is a column of "ds" which stands for data stamp and "y" which is the measurement from sensor. The next step is to do a log transformation on "y" column. The log transformation is important when the normal data do not follow the normal distribution bell curve, where the mean, mode and median do not have the same value. Thus, using the log transformation will help to make the data as close as a normal distribution. Next, a new variable is needed to call the FBProphet function. After that, the future data frame prediction needs to be set based on frequency and period. The frequency is determined by time units and the period will be determined by the value based on the time unit set on the frequency. Once the future data frame is set, predict function is used to plot the graph to get the output as in Fig. 10. The graph shown on Fig. 10, shows the prediction for 10 days ahead of the original data.
From the results gained, the output for the time series prediction shows that the prediction follows the pattern of previous events since the data only consist of 1 variable which is the pet food level, and no other variable that contribute to the result. However, by changing the frequency for the future data frame in the source code will result in different output. But since the data is resampled into every 1 hour, the most suitable frequency for this dataset would be "hour".

Conclusion
In conclusion, this project proposed a Smart Pet Feeder System with Big Data Processing to Predict Pet Food Shortage to help pet owners to feed their pet whenever they are not around as well as to provide a prediction on pet food shortage. The components used in this system are HX711 load cell amplifier, ultrasonic sensor, infrared sensor, and servo motor. The system will dispense a correct amount of pet food automatically at pre-set time when the system detects a pet come near the pet feeder system. The system will notify the owner every time their pet is fed and if the pet food level is low. The system can also collect the data of pet food"s level to be used for time-series prediction. The system used parallel processing method in handling big data and the output will be used for data pre-processing. The system runs on the main controller that is Arduino.