From “IoT Automated Pet Feeder with Beaglebone Green” by Ryan Jones, 2017
This automated IoT pet feeder will send you an email when your dog or cat takes a treat. See how it works in the video below!
- Seeed Studio’s Beaglebone Green Wireless Google IoT Kit
- Grove Cape
- Grove PIR Sensor
- Grove Pushbutton
- Grove OLED Display
- 1N4001 Diode
- 2N3904 Transistor
- 5V Relay
- 12V Power Supply
- 220Ω Resistor
Lately, I’ve been out of the house more than usual so I’ve been feeling a little guilty about my pets being home alone. To ensure their health and wellness, I attempted to build a Beaglebone Beagle-Feeding device. I’m not much of a mechanical engineer, so it ended up being more of a treat dispenser since this prototype couldn’t handle very much food.
Nevertheless, your pet doesn’t have to be alone, either! This model includes an OLED display that asks your pet if they’re hungry. All you have to do is send them away to pet boarding school to learn to read English, and they’ll be on their way to home automation!
The Beaglebone Green Wireless Google IoT Kit comes with a “Grove Cape” that allows for easy connection between the Beaglebone and the components. The Grove Cape can be connected without any extra components to the included Grove mini-PCBs, like the PIR sensor, pushbutton, and OLED display. This allows the project to come together quickly.
Before moving forward with our program and circuitry, we have to make sure our board is updated and includes everything we need to run our program. We will be using Python within the included Cloud 9 IDE. We just need to execute a few commands within Cloud 9’s terminal in the following order:
apt-get install links
apt-get install libssl-dev tcltls swaks
Okay, let’s jump right in and plug the PIR sensor into GPIO 115, the pushbutton into GPIO 117, and the OLED into any of the I2C connectors. You will need to place the PIR sensor at the front of the device, and locate the OLED display for easy reading. You should place the pushbutton underneath an elevated platform.
When the PIR detects motion it will print “Are you hungry?” on the OLED display. If your pet determines that it is, in fact, hungry and steps onto the platform, the pushbutton engages and a solenoid is triggered to release food into the bowl. Then the OLED prints “Enjoy, Hal!” and an email is sent to your account informing you of your pet’s eating habits.
While the Grove connections work great for most of our project, we do not have a signal capable of driving a solenoid. Instead, we will create a custom relay circuit and connect it to GPIO 51. Though we could have used a transistor to directly actuate the solenoid, I didn’t have one with an adequate collector current rating, so instead the transistor drives a relay coil, and the relay controls the solenoid.
In general, NPN transistors need a base-to-emitter voltage of at least 0.6V to leave the cutoff region and allow current to flow from collector to emitter. The resistor is used to limit the current flowing into the transistor’s base (too much current could cause damage).
With the transistor out of cutoff, our 5V supply connected to our relay coil has a path to ground through the BJT’s collector and emitter. The diode protects the transistor from dangerous voltage spikes that occur when a transistor interrupts current flowing through an inductor.
When current flows through the relay coil, the relay’s switch contact moves from the normally open terminal to the normally closed terminal. This allows current from the 12V power supply to flow through the solenoid’s coil, and this in turn causes the plunger to move.
The plunger is attached to some sort of apparatus that allows treats to fall into your pet’s dish. You should receive an email notification within seconds that your pet is chomping away! For more information on sending and receiving emails, check out this tutorial from EasyEngine.
You can make a feeder contraption out of just about anything, so you’ll have to get creative. This is just a very, very rough prototype. The Beagle Feeder can be greatly improved with a better feeding mechanism controlled by a servo motor, or even with a webcam that lets you check in on your pets to be sure they really are eating! The possibilities are endless.
import pyupm_grove as grove
from subprocess import call
#import oled display module
import pyupm_i2clcd as upmLCD
#parameter 1 means that we are using I2C_2 , and 0x3c is the address of OLED Display
myLCD = upmLCD.SSD1327(1, 0x3c)
pir = mraa.Gpio(73)
button = mraa.Gpio(71)
relay = mraa.Pwm(62)
# Nothing to do here
x = pir.read()
y = button.read()
if (x == 1):
elif (y == 1):
myLCD.write(" Hal! ")
#call("swaks -4 --server smtp.gmail.com:587 --from email@example.com --to firstname.lastname@example.org -tls --auth LOGIN --auth-user email@example.com --auth-password your-password --header \"Subject: Hal got himself a snack!\" --body \"He loves his snacks\"",shell=True)