I’ve been looking for an automated cat feeder, and haven’t been very happy with the options. I need it to dispense a very small amount, and only when the cat is present, to avoid it piling up and letting her eat too much at once. (Bad things happen then.) The closest thing I found was the Wireless Whiskers feeder, but I just wasn’t inspired to spend $150 and then fuss with programming it on a tiny screen. And then @bitsandhops posted this:
At some point this cat is going to starve - “Automated cat feeder powered by Node.js” https://t.co/cMM4UzrMT4— Richard Bishop (@bitsandhops) December 1, 2015
I knew I wanted to use Elixir (of course!) so I went with a Raspberry Pi starter kit, and then discovered that the RPi doesn’t really do servos, so I added the Servo HAT. And a proximity sensor, etc., etc. Once it works I’ll do a post with all the details and a parts list.
Not having done anything with hardware since college (that course where I spent hours and hours in a windowless basement sticking Motorola chips into breadboards…) I started with the “Hello World” of the embedded space: blinking an LED.
(Actually I first wired it directly to power, which is what you see above. Later I moved that red wire over to GPIO pin #4 as described here.)
The elixir_ale library even exports the pin you want to use to make it available, which is described in this blog post. Under the covers this uses
sysfs which entails writing a value to a file, after which Linux does the right thing.
Having conquered blinking an LED, I turned to the servo. This meant soldering the header and some pins onto the HAT. I watched:
I spent a frustrating afternoon trying to reverse engineer the Python example code that Adafruit provided, and (after reading more blogs and asking more questions) I figured out that I was supposed to have a Datasheet to work from.
With it all plugged in and working:
The code is here: Spinny.
For our last trick, it’s back to the LED, this time with the VCNL4010 proximity sensor wired up.
Here is the code that makes it work.
This was a matter of connecting the right pins from the sensor to the RPi, as shown in in the Adafruit example project and the Datasheet. @fhunleth explained that the SDA and SCL pins are what put something “on the i2c bus” so it can be addressed and written to / read from.
Next up I’ll need to get both the servo and the proximity sensor attached at the same time, so that instead of turning on a light when something is near, I can spin the servo. As soon as the next box from Adafruit arrives, I’ll have the additional parts I need to make that happen.