Skip to content

Reviving My Cat's Automatic Feeder - Part 1

Like many people, I sometimes enjoy travelling on my time off. Visiting family, seeing sights, getting out of my comfort zone for a bit is always good for me. However, the last time I decided to take a trip away from my house, my husband updated the settings on the automatic cat feeder to feed twice a day instead of once while we were gone. Normally, we'd give our cat wet food in the morning and the feeder takes care of her at night, but a few days of just dry food wouldn't hurt.

When we came back from our trip, we were surprised to see that all of the food in the automatic food dispenser had been released! This automatic feeder being years old at this point, barely responsive, and definitely not intuitive, I decided I would just replace the computer entirely. The whole process ended up taking 3 or 4 days, but ultimately I've got a product that works better than the old one, and can be expanded further as I go.

 

automatic-feeder

Figure 1: My cat Milk eating from her automatic feeder

 

Starting out, my task was fairly simple: take it all apart and clean it really well. This feeder pre-dates my relationship, and the collection of grossness inside certainly showed, as it isn't really typical of someone to take it all the way apart and clean it like this. However, after I pulled it all apart and got it clean, I was a really simple set of pieces. There was a big tank shaped like a funnel for the food, an elevator to raise the food up from the bottom of the funnel, and a stepper motor to power that elevator.

 

@codewonderland

 

♬ original sound - Alice Easter

 

The motor in particular was probably my favorite part of this machine, as it's a great visual representation of what a stepper motor is and does. There is a simple motor with a star shaped plastic piece attached to the shaft. That star piece then rotates with the shaft and closes a button circuit at regular intervals to calculate how far we've gone.

Since I had figured out how everything works at this point, I started coming up with a prototype circuit for everything. The motor itself ran off of 12v DC power, and the microcontrollers I use run off of 3.3 or 5 volt power, so I need to add in something to regulate the power for both of these. What I used was actually an old car charger. After ripping it apart, I had a place I could solder on 12v input and get 5v out of it.

 

@codewonderland stepping down voltage with recycled tech! #engineering #techtok #electronics #hardwarehacking ♬ original sound - Alice Easter

 

Once I got the power regulation in place, I needed to add in a relay module to turn power to the motor on and off. Finally, I needed a micro-controller to control that relay. Ultimately, I wanted to be able to control this system from my smart phone or smart watch, so I went with the Raspberry Pi Pico W, sourced from Adafruit. After figuring out all of the parts, I could pull it all together into a single device.

 

@codewonderland more progress on my pet food dispenser hacking! #electronicsengineering #electronics #techtok #hardwarehack #circuitpython #engineering #adafruit ♬ original sound - Alice Easter

 

Getting all the hardware together here was only half the battle though, the other challenge was the software to control everything. First I had to write some code to turn the relay on and off, then expand on that to create a Stepper Motor class that could turn the relay for the motor on and off based on the number of steps given. This part was fairly simple, and in theory I could just set this to run every 24 hours and call it a day, but I wanted to make this system a bit more dynamic than that.

There were a few bigger coding challenges that I had to address: The system needed to connect to a network to set the system time to EST initially, it needed a way to read and write data to itself to keep track of feedings, and it needed a way to be interacted with externally to update things and check on the system.

Setting the system time didn't end up being too hard, it's basically just connecting to Wifi and cross referencing with a server on what time it currently is. The reading and writing data from disk ended up being a bit trickier. I didn't have any way to connect an SD card to the system on hand, so I needed it to write to the same place where the code was stored. The difficulty with this is doing so makes it so we can't write to the micro-controller over USB if it's set to write to itself. As such, I added in a check to see if the micro-controller is currently connected over USB, and if it is then the write functionality of our Storage Protocol is disabled.

Having the system connected to Wifi and writing data to itself was huge, but there was still a lot left to be done. Next, I had to add in a method of updating the system from my phone. Initially, I wanted to do this over bluetooth, but it turns out that the Pico W isn't capable of that yet. The wireless chip on the device is capable of bluetooth, but the software doesn't support it yet. This caused me to pivot to doing everything over wifi instead, which did at least make everything easier to code.

I spun up a web server on the micro-controller to manage all of the network connections. First I made a simple homepage that pulled in some data from the system, including system time and feeding time. This also required that I added endpoints to pull the system time and feeding time data. Then I added in a page to update everything, and an endpoint on the server to accommodate writing a new feeding time. After, getting the essentials in place, I added in one more route to the server to manually trigger a feeding and viola!

 

@codewonderland My cat shall be fed by a robot again!! #techtok #engineering #adafruit #circuitpython #hardwarehacking #electronics #electronicsengineering ♬ original sound - Alice Easter

 

The system certainly isn't perfect, but it works for now and it's for my own cat so it doesn't have to be. As I have time to work on it, I also still plan on building out the mobile and smart watch apps, as well as adding in the functionality for multiple scheduled feedings in a day. For now though, this was a fun project, and I learned a lot doing it.

What could we build together?

If you're interested, reach out! I'm open to new contracts unless this website says otherwise, so I'd love to get connected with you and see what we can create!