Internet of Things workshop - Pet Feeder
|Led by||Prof. Sivan Toledo|
|CPU||Raspberry Pi 2|
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 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.
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.
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.
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.
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.
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.
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.
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.
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.
- Working Pressure: 0.02 Mpa - 0.8 Mpa
- Working Temperature: 1 ℃ - 75 ℃
- Response time (open): ≤ 0.15 sec
- Response time (close): ≤ 0.3 sec
- Actuating voltage: 12VDC (but we found it works down to 6V)
- Weight: 4.3 oz
- Dimensions: 3" x 2.25" x 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).
- UART interface up to 115200bps
- I2C interface up to 400 KHz
- Complete read/write module excluding antenna
- 5V supply
- 2 general purpose outputs
- 2 general purpose inputs
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.
- Thickness: 0.203 mm
- Length: 191 mm
- Width: 14 mm
- Sensing Area: 9.53 mm
- Connector: 3-pin Male Square Pin (center pin is inactive)
- Pin Spacing: 2.54 mm
BuoyThe 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.
- Contact apacity: 70W
- Switching voltage: DC110V
- Switching Current: 0.5A
- Insulation resistance:> 10Ω
- Operating Temperature: -10 ~ 60 ℃
- Size:18*36 mm (D*H)
- Cable length:370 mm
- Net weight:8 g
- Unipolar stepper with 0.1" spaced 5-pin cable connector
- 513 steps per revolution
- 1/16.032 geared down reduction
- 5V DC suggested operation
- Weight: 37 g.
- Dimensions: 28mm diameter, 20mm tall not including 9mm shaft with 5mm diameter.
- 9" / 23 cm long cable
- Holding Torque: 150 gram-force*cm, 15 N*mm/ 2 oz-force*in
- Shaft: 5mm diameter flattened
- Approx 42 ohm DC impedence per winding
- SparkFun solenoid page, including links to datasheet.
- SparkFun SM130 RFID Module page, including links to datasheet and firmware updates.
- SparkFun Flexiforce Pressure Sensor - 1lb. page, including link to datasheet.
- Ebay page for Tank Pool Water Level Liquid Sensor Float Switch Switcher GOOD New with info on device.
- SparkFun Stepper Motor page, including link to datasheet and device information.
- SparkFun Big Easy Driver page, including link to datasheet.