2 minutes
Bistrobot: Orchestrating cat food dispensing with Raspberry Pies
Problem
I live with two cats:
cat 1
, who has food anxiety and can meow for hours if his eating schedule is disrupted;cat 2
, who eats faster than his own shadow.
To fix cat 1
’s food anxiety, we purchased two food dispensers on Amazon (each has a different branding but they are exactly the same product). These “robots” are simple, non-connected devices. Current time, meal sizes and schedules are manually configured through a rudimentary interface.
As a result of this manual setup, it is near impossible to have them perfectly synced, and even if achieved, they get out of sync quickly.
This leads us to the second problem:
- If both robots dispense the scheduled meal even just a second apart,
cat 2
will gulp the first dispensed meal and rush to the second robot to eat the other meal, leavingcat 1
dumbfounded and hungry (bringing us back to square 0).
Solution
To perfectly synchronize the two robots, I gutted them and replaced the internals with a Raspberry Pi Zero W each.
Both robots are now ntp
synchronized, and they pilot the motor for the dispensing mechanism through GPIO.
Scheduling is done through a crontab
on each RbPi, which I push using ansible
.
This solution also permits remote one shot meals for emergency through ssh
/ansible
.
3 GPIO pins are used:
- One
input
: the position trigger sensor for the dispenser wheel; - Two
outputs
:- one for the transistor triggering the motor which rotates the dispenser wheel;
- one for a buzzer to “announce” meals to the cats.
Side effect
The python GPIO initialization appears to be driving a slight current during initialization, which is inaudible to me, but allows the cats to anticipate the actual buzzing: they now rush to their respective feeder before the buzzer even announces the upcoming meal.
Happy Ending
With both robots perfectly synced, cat 1
and cat 2
now enjoy their meals worry-free.