Internet of Things workshop - Pet Feeder

Class Household
Led by Prof. Sivan Toledo
CPU Raspberry Pi 2
Contributors Eyal Greif
Inbar Shulman
Shaked Feldman
Uri Goodman

The pet feeder 2.0 is an automatic feeder for cats and dogs. It enables you to manage feeding times, portion sizes, food supply and assure that your pet’s food is eaten by YOUR pet.

Using our Raspberry Pi and many other hardware components we were able to create an all encompassing suite for taking care of your pet. Both feeding it and filling your pet’s drinking bowl, among other features, guarantees that your pet is receiving utmost care and that all of its needs are being taken care of. Combining our feature-filled UI with data telemetry supported by the cloud, streamlines the process of taking care of your pet.

Problems we encountered

Construction

Construction was much more difficult thanwe originally expected.

The difference between operating each component separately and having a working product is enormous. Whether it is building the surrounding framework which encapsulates a component or positioning said infrastructure in relation to the other components in a reasonable way - It all takes time and effort.

Another pothole we had to avoid was two of our components’ need of an external power supply and the obvious need for a water supply. These two demands made testing a difficult as we approached the later stages of production.

A major hurdle which we had to overcome was the relative weakness of the stepper motor, this meant that our original plan of using a cereal dispenser would not work.

Communication

Our system communicates in three different channels: UI - server, server - RP2 and RP2 - components.

The first two function through Azure IOT hub and took much time to understand and configure, further exacerbated by the support problems.

The third connection was more complicated.

Some components are easily controlled by connecting them to an output pin and pulling it high/low or to an input pin and reading the pin value when necessary. On the other hand, other components demand a more complicated communication scheme.

We had two such components, one which communicated in SPI and the other in UART. In order to use these two communication protocols we needed to research and understand them in depth and then figure out how to use them in this context.

Lastly, we had a minor issue with reading our pressure sensor’s input, given that it was analog data and the RP2 does not support Analog to Digital conversion.

We circumvented this problem by using an A2D chip. It took some effort to make the necessary adjustment, both physically and codewise, but the end result works.

Support

While writing the program we encoutered multiple bugs in windows IOT and we were unable to resolve them. In particular, during remote debugging on the rasbperry pi any error which waas raised would not reveal any information relating to the location of the falty code. This led to many an hour spent debugging thin air, in addition to the time wasted in deploying which took time.

Any attempt to report this error was met by a non-existent page error, which leads us to our next problems. Many support pages on microsoft support for a product we needed were unavaliable, such as the Azure SDK page for C# on windows or the Serial Sample page which ceased to exist for a month.

On the serial sample page, a Pi with pins connected is shown. However in all of the examples on the page, a USB to TTL device is used, rendering this example useless.

Server

The server was built using Microsoft Visual Studio and was written in C#. It runs multiple threads that perform work on incoming tasks. The server has a queue in which messages that are waiting to be sent out are stored, and a similar queue for messages that were received and not yet processed. It also has a queue for pending SQL queries. The server uses the Azure IOT hub system to communicate with the user interface app and with the Raspberry Pi.

The server saves the data it receives from the Raspberry Pi in a SQL table that is hosted on the cloud. For example, there is a table in which every row contains the amount of water and food that was that the product dispensed at a specific date.

The code is written in such a way so that it is easy to scale up. This can be seen in the fact the data is saved on the cloud and the fact that the work is split amongst several workers.

In the product’s next version, the server will use a weather API to gather information regarding heat and humidity at the product’s area. By analyzing this information, the system will be able to update the product’s water ration accordingly. It will also use Machine Learning utilities from the cloud for research on the feeding habits of pets and by doing so, be able to recommend a suitable diets for the specific pet, among other things.

User interface

The user interface is run from a C# wpf form application, providing you control over how much food and water your pet receives and allows you to control times.

By using this telemetry, you may identify irregularities in the data that you’re collectingand using that information, provide your pet with better care or continue with the current plan. Both of these options are provided by our pet feeder in this application.

Graph

Using the Oxyplot library for c# we are able to present information regarding the product’s activity. The information regarding the pet, such as food and water consumed, is displayed as a graph over time. The user can select which timeframe he would like to view and the application will request the information from the Azure server.

Ration control

The user can decide how much food and water is to be dispensed in every serving. Additionally, an upper limit can be put on the amount of food dispensed throughout a single day.

This enables you to have an active role in controlling your pet’s diet and fit the product to its specific needs.

Remote feeding

The pet feeder also supports remote food dispensing.

A button click in the UI will dispense food or water, given that the daily limit has not been surpassed.

Hardware devices

Raspberry Pi 2

The Raspberry Pi 2 is a credit card sized mini personal computer that lets software developers dive right in and start coding - no additional components needed. Raspberry has its roots in education but should be considered for any purposes where you would otherwise use a PC.

In our product, the RP2 acts at the brain: it is responsible for giving out commands to the various components and communicating with the cloud and through it, with the user.

Solenoid[1]

An example of a solenoid valve, similar to the one we used.
A solenoid valve is an electromechanically operated valve. The valve is controlled by an electric current through a solenoid. We used a 12V power supply controlled by a MOSFET. In our project the solenoid releases water to the pet’s liquid container whenever the buoy sends a signal of “low level water” and the pet is in the area (by the rfid) or when the owner puts in a special request throught the UI. The solenoid releases water until a signal is recieved from the buoy in order to avoid overflowing the liquid container.
Technical Details:

RFID[2]

Radio-frequency identification uses electromagnetic fields to automatically identify and track tags attached to objects. The tags contain electronically stored information. Passive tags collect energy from a nearby RFID reader's interrogating radio waves. Unlike a barcode, the tag need not be within the the RFID reader’s line of sight, this allowed us to put the chip on the pet’s collar so the antenna can detect whenever it is close.

An RFID module which consists of a reader and an antenna is connected to our RP2. The communication between the two is done over the UART protocol.

We utilize the RFID module in order to sense when the pet enters the vicinity of the feeder. This is done in order to dispense food and water only when necessary (that way the food doesn’t dry up).


Features:

Weight sensor[3]

The circuit constructed for measuring how much food is in the bowl.

The FlexiForce weight sensor is an ultra-thin, flexible printed circuit. In our case, using a Nature Valley box, we were able to funnel all of the weight of the food onto the small round scale which supports the food plate.

In our project the sensor serves a dual task, both to ensure that the amount of food released is indeed the correct amount and to signal the dispenser to cease releasing food and to weigh how much food and water were consumed by the pet (later we analyze the data and output the weekly and monthly amounts).

In order to use the data supplied by the sensor, the data is transformed twice. First, in passes through an Analog to Digital converter before reaching the RP2. That is because the RP2 does not support A2D conversion on its own. The RP2 communicates with the A2D chip over the SPI protocol.

After being converted, the data is interpolated using a linear interpolation in order to obtain it in the wanted form. Analysis of the data gathered by the weight, when looked over a daily, weekly and and/or monthly time frame, may give indication of the pet’s appetite and physical condition.
Physical Properties

Buoy[4]

The buoy is actually a water-level activated switch. It consists of a plastic cylinder and a foam ring encircling it. When the foam ring is located at the top of the cylinder, the sensor outputs HIGH, otherwise, LOW. The buoy is put in a container and attached in such a way that the water-level and foam ring are raised and lowered concurrently, that is, the one moves the other. Thus, the sensor outputs HIGH and LOW according to the water level in the container.

Stepper motor[5]

Illustration of how a stepper motor works.
A stepper motor is a brushless DC electric motor that divides a full rotation into a number of equal steps (in our case it is 200 steps of 1.8 degrees). The motor's position can then be commanded to move and hold at one of these steps without any feedback sensor. The motor spins fast in one direction or another. It is possible to change the speed with the amount of power given to the motor. In our project his task is to control the released amount of food. It works the same as a cereal dispenser system except that it is electronically controlled by our program, using a driver[6] (which supervises that the pet doesn’t eat more or less than the desirable amount of food).
Technical Details:

Video

References