Log Your Pet's Weight, and Get a Text When They Are Out of Food!



About: Phidgets make your ideas real. Reliable sensors, motor controllers, relays and more connect computers and technology to the real world. Applications include robotics, data acquisition, monitoring, automation...

Create your own pet monitoring system!

  • Make a weight scale using load cells, some plywood, and Phidgets!
  • Log your pet's weight over time
  • Get a text when your pet is running out of food

Step 1: Skills Required

This project may seem like it has a lot going on, but don't worry!

Every step is explained in detail, and all of the code is already written. All you need is access to some basic tools, a bit of programming knowledge, and some free time!

If you are interested in modifying the code, then you will need some basic coding skills in the following areas:

  • C
  • JavaScript/HTML

Step 2: Hardware/Component List

Here is everything you will need to make this project:

Step 3: Building a Weight Scale

The first thing to do for this project is build the weight scale!

We chose 1/2" plywood, but you can use whatever you have around, just make sure there is enough room for the load cells to flex and that the material can withstand the load.

You will need one scale for the weight bowl, and one for the food bowl, and one for your pet. We made the food bowl scales 12" x 12" and the pet scale 24" x 24".

Step 4: Wiring the Weight Scale

After building the scale, the next step is to wire it up.

Step 5: Software

This project has two main software components:

  • A simple C program running on the Phidget SBC4
  • A basic webpage (HTML/Javascript)

The C program will run on the Phidget SBC4 and perform the following tasks:

  • Connect to the PhidgetBridge 4-Input (or Wheatstone Bridge Phidget) and monitor the weight of the food/water bowls and the pet.
    • If the food/water weight drops too low, it will send a text message.
    • It will store information about the pet's weight to a file.
  • Connect to a Phidget Dictionary in order to pass information to the webpage

The webpage will perform the following tasks:

  • Display the current values for the weight/food bowls
  • Allow user to input phone numbers that should be texted when food gets too low
  • Display pet's weight overtime on a graph.

Step 6: Setting Up the SBC4

If you have never used a Phidget SBC before, first follow this getting started guide before you continue reading.

You will need to do a few things to your SBC before getting started with this project.

  • Create a PhidgetDictionary (see picture above)
  • Create a project (see picture above)
  • You will need access to the terminal in order to compile the C program, so you will need to enable SSH. You can see how to do that here.
  • Install C/C++ packages. You can see how to do that here
  • You may have noticed the data folder in the project directory in the image above. We will be logging information about the pet's weight to a file and that is located in the data folder. You will have to create a link to this folder from the webserver docroot location (/var/phidgets/www), so that the webpage can access the information. Here is how to do it using WinSCP.

Step 7: Writing the C Program

If you don't plan on writing any C code, you will simply have to modify some numbers in order for the project to work for you. If you open petmonitor.c , there will be code comments that tell you what to do.

Here is a list of things that need to be changed:

  • Serial numbers (these need to match your Phidgets and your Dictionary)
  • Channel numbers (these need to match the channels that your scale is connected to)
  • Email (we use email-to-text feature in order to send a text message, so you need to provide your email login. Note: we recommend creating a separate email for this part, and just sending it from that.)
  • Load cell calibration values. This article and this article are good resources for this part. If you have any more questions, please leave a comment!

You will also need to compile the C program, which can be done by entering the following command into the SBC terminal:

gcc petmonitor.c -o petmonitor -lphidget22 -lcurl

If you are interested in learning more about the code, we will go over some of the key parts of petmonitor.c here, and if you have any further questions, please leave a comment!

  • At the top of main, we define four objects:
    • A PhidgetDictionary, which is used to pass information between the C program and the webpage.
    • A PhidgetVoltageRatioInput for water, one for food, and one for the pet's weight.
    • It is important that you address these Phidgets correctly in your code. For more information, check out this video.
  • After opening the three objects, we get into the main while loop of the code. Here we do a few things:
    • Get the current weight of the water bowl and food bowl and update the dictionary so that the webpage can display the information.
    • Check if there was a dictionary update. If there was, a phone number was added, so we should add that number to our phone number list.
    • Check if the current weight of the water and food bowl is too low (<5% full). If it is too low, we try to send a text message.
    • Go to sleep for 5 seconds.
    • The way we handle monitoring the pet's weight is slightly different. We use a data event, instead of using a get call. In the event, if the weight we are measuring is above 5 lbs, we can assume the pet is on the scale. Next, we make sure that we have been weighing the pet for at least 30 seconds (to avoid errors), and if so, we will average the data we collected and log it to a file.

That's all there is to the code. If you would like more information about how sending emails work, check out this project.

Step 8: Creating the Webpage

If you don't plan on writing any webpage code, you will simply have to modify some numbers in order for the project to work for you. If you open petmonitor.html, there will be code comments that tell you what to do.

If you are interested in learning more about the code, we will go over some of the key parts of petmonitor.html here, and if you have any further questions, please leave a comment!

  • After connecting to the Phidget server, we start with the runCode function. Here we connect to the Phidget Dictionary channel that we created on the SBC.
    • We register for some events, the most important being the onUpdate event. This update code will run when a key-value pair in the dictionary has been updated.
    • The keys waterSupply and foodSupply will be updated by the C program, and we will display the values when they change.
  • Next, we create a graph using vis.js to display the pet's weight information.

  • Finally, we build a table for the phone number list to live in.
    • If a user adds a new phone number, we will update the phonenumbercount key in the dictionary, and we will add the new phone number to the dictionary. If they remove a number, we will decrement phonenumbercount and remove the phone number from dictionary.

Step 9: Complete!

You now have a pet montioring system that will log your pet's weight, and send you a text when they are low on food. If you liked this project, let us know!

Automation Contest 2017

Runner Up in the
Automation Contest 2017



    • Fandom Contest

      Fandom Contest
    • Sensors Contest

      Sensors Contest
    • Beauty Tips Contest

      Beauty Tips Contest