August 28, 2023

Making Smart Home Devices Even Smarter

Written by
Eliot Horowitz
CEO & Founder

Smart machines have the power to solve major problems in the world, whether it be battling climate change, fighting forest fires, or cleaning oceans. The same technology that will enable big things like those to happen will also have the potential to make simpler problems dramatically easier to solve. Before starting Viam, I had always wanted to tinker with small home automation projects, but each time I tried I found it too hard. Getting rid of the bottleneck that prevented some of these seemingly trivial problems from being solved was definitely a major goal for me when starting Viam. I’ve been doing a lot of hacking this summer on home projects, and am going to try to start blogging about them. My goal is for the blogging piece of that to be harder than the projects themselves. (And no, ChatGPT will not be writing these blog posts.)

The first project I started working on was for a recent new addition to my life, a cat. My cat Lexi gets a combo of wet and dry food on a variety of schedules. I bought an automatic dry food feeder to help manage things, and to make sure she never goes hungry!

The Challenge

The feeder is definitely nice, but has some major flaws, and the flaws are pretty common to this category of home machine. They promise the convenience of automation, but can’t fully deliver on that promise for one reason or another. First, to program this cat feeder, you have to press a button on a tiny screen in a bunch of different ways. This is particularly frustrating because configuring on a phone or browser would have been so easy to do! Second, for some reason, the time function was prone to somehow drifting, causing hilarious problems like waking me up in the middle of the night. I don’t suppose ‘a clock’ is exactly a cutting edge technical concept, so it definitely needed to do better there. Third, it doesn’t have the ability to tell me when it runs out of food. Functionally, this means that instead of worrying about remembering to feed the cat, I have to worry about remembering to feed the cat feeder. Not great! Finally, I would love to keep metrics on how often Lexi eats and how much, but there is no built-in way to do this.

The Process

On a random Saturday afternoon, my son and I decided to solve this problem. We took the cat food feeder apart, down to the guts, and decided to replace everything electronic but the motor. We connected the motor to a Raspberry Pi, first with a simple relay (I had one lying around), and then with a Pi-HAT motor controller. Then we added a webcam on the top, pointed at the bowl. All the components we added were about $80 (including the Pi).

With the right components in place, it was time to make this nice but slightly stupid cat feeder smart. To Viam-ize it! This was thankfully super-simple, as I wanted my son to be able to help and not get bored :) We installed Viam on the Raspberry Pi, configured the webcam and motor, and then tested, turning the motor on and making sure the food got dispensed. Success! 

Then we had to make it feed Lexi automatically. The first thing we wanted to do was to have it add some food if the bowl was empty. So we enabled data capture on the camera, and started labeling images as empty, little, or full. We then trained on a model on those images and attached it to the configuration. Then, using a simple Python script that runs every hour via Cron, we could determine the status of the bowl. If empty, a little food would be added within a limit we could set. 

While we haven’t finished everything we want to do yet, the modifications we made are already a huge improvement over what was there before. The entire project took about two hours. In addition, all the data is being captured, so whenever I get around to doing the analytics side of this project, it’s ready to go. There’s a trope in tech about eating your own dog food. I’m sure there is something clever to say about cat food here, but I’ll just end by noting that it was super-satisfying to be able to really quickly and easily use my software to feed my cat, entertain my kid, and make my life a little bit less complicated by making a machine a little bit smarter.

If you have any questions or want more information, reach out on Viam’s discord channel, Twitter, Instagram, or LinkedIn.

on this page

Get started with Viam today!