Twitter Controlled Pet Feeder
by amandaghassaei in Circuits > Arduino
70811 Views, 230 Favorites, 0 Comments
Twitter Controlled Pet Feeder
![main.jpg](/proxy/?url=https://content.instructables.com/FAU/9ZIW/H4ZN4RAW/FAU9ZIWH4ZN4RAW.jpg&filename=main.jpg)
![IMG_3303 copy.jpg](/proxy/?url=https://content.instructables.com/FI3/ZYMU/H1JUJB9K/FI3ZYMUH1JUJB9K.jpg&filename=IMG_3303 copy.jpg)
![peanut.jpg](/proxy/?url=https://content.instructables.com/FMC/39Q4/H461X1TJ/FMC39Q4H461X1TJ.jpg&filename=peanut.jpg)
A great project for busy pet owners. This Twitter-Controlled pet feeder automatically dispenses food in response to activity on your Twitter account. The project is controlled by an Arduino and uses the Arduino Ethernet shield to receive data from Twitter. I hacked this automatic Pet Feeder from Amazon to build this project, but you could easily modify your own motorized feeder to work.
Parts List:
(1x) Automatic Pet Feeder Amazon
(2x) 10K Ohm 1/4-Watt Carbon Film Resistor (1 package) Radioshack #271-1335
(1x) Arduino Ethernet Shield Radioshack #276-130
(4x) CdS Photoresistors 5 pack (1 package) Radioshack #276-1657
(1x) Grid-Style PC Board Radioshack #276-147
(2x) White Super-bright LED Indicator Radioshack #55050633
(1x) Male Header Pins 40 Position Jameco #160882
(4x) "D" Alkaline Batteries (1 package) Radioshack #23-865
(2x) 4.7K Ohm 1/4-Watt Carbon Film Resistor (1 package)
(2x) current limiting resistors, see the sample calculation below
from the specs of the LEDs I used:
"Continuous forward current: 30mA"
"Forward voltage: 3.6V"
using the following relationship:
V(volts) = I(amps) * R(ohms)
rearranged to:
R = V / I
we can calculate the resistance as follows:
voltage across resistor = 5V - 3.6V = 14V
1.4V / 0.03A = 47ohms
I used 100 ohm 1/4W 5% Carbon Film Resistors Radioshack #271-1311 so that the LEDs wouldn't be operating at their maximum ratings. Check the datasheet of the LEDs you use to calculate these values.
Additional Materials:
drill
Solder Radioshack #64-013
22 Gauge Wire Radioshack #278-1224
Open Pet Feeder
![IMG_3103 copy.jpg](/proxy/?url=https://content.instructables.com/FTI/Q5NH/H1ERNBKQ/FTIQ5NHH1ERNBKQ.jpg&filename=IMG_3103 copy.jpg)
![IMG_3104 copy.jpg](/proxy/?url=https://content.instructables.com/FZL/J673/H1IMOUOQ/FZLJ673H1IMOUOQ.jpg&filename=IMG_3104 copy.jpg)
Unscrew Pcb
![IMG_3111 copy.jpg](/proxy/?url=https://content.instructables.com/FVP/HDF1/H1ERNBKV/FVPHDF1H1ERNBKV.jpg&filename=IMG_3111 copy.jpg)
![IMG_3117 copy.jpg](/proxy/?url=https://content.instructables.com/F8A/VAUY/H1HMDQVI/F8AVAUYH1HMDQVI.jpg&filename=IMG_3117 copy.jpg)
Schematic
![Screen shot 2012-05-04 at 5.11.57 PM.png](/proxy/?url=https://content.instructables.com/F5L/RTL6/H1PITAQG/F5LRTL6H1PITAQG.png&filename=Screen shot 2012-05-04 at 5.11.57 PM.png)
![Screen shot 2012-05-04 at 5.36.44 PM.png](/proxy/?url=https://content.instructables.com/FM2/O2IX/H1LWQFX3/FM2O2IXH1LWQFX3.png&filename=Screen shot 2012-05-04 at 5.36.44 PM.png)
The schematic is shown above, I've also attached a fritzing document for your reference. This feeder is programmed to manually dispense food when the "set" and "volume" buttons are depressed at the same time. By wiring light sensitive resistors across these buttons we can simulate the mechanical pushbutton action as follows:
When the photoresistors are not exposed to light their resistance will be very high and the processor in the feeder will think that the buttons aren't being pressed. By telling the arduino to light up some LEDs near the photoresistors, the resistance will decrease low enough for the feeder's processor to think that the buttons are being depressed.
I've also attached two pushbuttons in the circuit so that I could manually turn the LEDs on for troubleshooting purposes. These buttons are not essential to the project (but useful).
I also be diverted some power from the feeder's four D batteries to power the arduino.
Downloads
Drill Holes in Pcb
![IMG_3127 copy.jpg](/proxy/?url=https://content.instructables.com/F6F/RQ7F/H1EN74AZ/F6FRQ7FH1EN74AZ.jpg&filename=IMG_3127 copy.jpg)
![IMG_3124 copy.jpg](/proxy/?url=https://content.instructables.com/FF5/CFH7/H1ERNBL6/FF5CFH7H1ERNBL6.jpg&filename=IMG_3124 copy.jpg)
![IMG_3133 copy.jpg](/proxy/?url=https://content.instructables.com/F2R/Y1PS/H1ENCCPH/F2RY1PSH1ENCCPH.jpg&filename=IMG_3133 copy.jpg)
Solder Wires to Pcb
![IMG_3123 copy.jpg](/proxy/?url=https://content.instructables.com/F1K/UFR1/H1EMI58J/F1KUFR1H1EMI58J.jpg&filename=IMG_3123 copy.jpg)
![IMG_3135 copy.jpg](/proxy/?url=https://content.instructables.com/FNY/NA06/H1EN74BP/FNYNA06H1EN74BP.jpg&filename=IMG_3135 copy.jpg)
Screw Pcb Back Onto Enclosure
![IMG_3140 copy.jpg](/proxy/?url=https://content.instructables.com/FJX/RGRO/H1HMDR3H/FJXRGROH1HMDR3H.jpg&filename=IMG_3140 copy.jpg)
Solder Header Pins on Protoboard
![IMG_3141 copy.jpg](/proxy/?url=https://content.instructables.com/FCU/DOQI/H1JU6KVE/FCUDOQIH1JU6KVE.jpg&filename=IMG_3141 copy.jpg)
![IMG_3142 copy.jpg](/proxy/?url=https://content.instructables.com/FPG/D4OF/H1JUGHAI/FPGD4OFH1JUGHAI.jpg&filename=IMG_3142 copy.jpg)
The protoboard will house the circuitry that allows the arduino to interface with the feeder's control pcb. This board will attach directly to the pins on the arduino ethernet shield. Solder header pins to the protoboard so that it can snap into the power, analog, and digital 0-7 pins on the arduino ethernet shield.
Solder White LEDs and Current Limiting Resistors
![IMG_3146 copy.jpg](/proxy/?url=https://content.instructables.com/F1W/LBYQ/H1JUDY1L/F1WLBYQH1JUDY1L.jpg&filename=IMG_3146 copy.jpg)
![IMG_3145 copy.jpg](/proxy/?url=https://content.instructables.com/FAO/W2R6/H1JU3OB0/FAOW2R6H1JU3OB0.jpg&filename=IMG_3145 copy.jpg)
![IMG_3148 copy.jpg](/proxy/?url=https://content.instructables.com/FR6/HJDY/H1JU3NCL/FR6HJDYH1JU3NCL.jpg&filename=IMG_3148 copy.jpg)
![IMG_3149 copy.jpg](/proxy/?url=https://content.instructables.com/F2H/7REL/H1JU3NCO/F2H7RELH1JU3NCO.jpg&filename=IMG_3149 copy.jpg)
![IMG_3152 copy.jpg](/proxy/?url=https://content.instructables.com/FDQ/IFD9/H1JUGHCH/FDQIFD9H1JUGHCH.jpg&filename=IMG_3152 copy.jpg)
![IMG_3153 copy.jpg](/proxy/?url=https://content.instructables.com/FP9/0Q88/H1JUDY1Y/FP90Q88H1JUDY1Y.jpg&filename=IMG_3153 copy.jpg)
![IMG_3155 copy.jpg](/proxy/?url=https://content.instructables.com/FEO/JEXG/H1JUA1KX/FEOJEXGH1JUA1KX.jpg&filename=IMG_3155 copy.jpg)
![IMG_3154 copy.jpg](/proxy/?url=https://content.instructables.com/FCA/8DLH/H1JUA1KW/FCA8DLHH1JUA1KW.jpg&filename=IMG_3154 copy.jpg)
Solder Resistors and Photoresistors to Protoboard
![IMG_3158 copy.jpg](/proxy/?url=https://content.instructables.com/FT6/QDN0/H1JUA1KY/FT6QDN0H1JUA1KY.jpg&filename=IMG_3158 copy.jpg)
![IMG_3156 copy.jpg](/proxy/?url=https://content.instructables.com/FW8/ETWV/H1JUGHD1/FW8ETWVH1JUGHD1.jpg&filename=IMG_3156 copy.jpg)
![IMG_3159 copy.jpg](/proxy/?url=https://content.instructables.com/FE7/SSK0/H1JUA1KZ/FE7SSK0H1JUA1KZ.jpg&filename=IMG_3159 copy.jpg)
![IMG_3160 copy.jpg](/proxy/?url=https://content.instructables.com/F03/GH50/H1JUGHD2/F03GH50H1JUGHD2.jpg&filename=IMG_3160 copy.jpg)
![IMG_3161 copy.jpg](/proxy/?url=https://content.instructables.com/FYI/F4LW/H1JUA1L1/FYIF4LWH1JUA1L1.jpg&filename=IMG_3161 copy.jpg)
![IMG_3162 copy.jpg](/proxy/?url=https://content.instructables.com/FXP/RBY3/H1JUI5N5/FXPRBY3H1JUI5N5.jpg&filename=IMG_3162 copy.jpg)
![IMG_3163 copy.jpg](/proxy/?url=https://content.instructables.com/FLH/93XP/H1JU6KW0/FLH93XPH1JU6KW0.jpg&filename=IMG_3163 copy.jpg)
![IMG_3164 copy.jpg](/proxy/?url=https://content.instructables.com/FG6/I83I/H1JUI5NC/FG6I83IH1JUI5NC.jpg&filename=IMG_3164 copy.jpg)
Solder one large and one small photoresistor (from the set of five) in series on the protoboard (make sure they are on the same side as the LEDs). Bend the leads of the photoressitros so that they are pointed directly at one of the LEDs. Solder a 4.7kOhm and 10kOmh resistor in series with these two photoresistors (fig 4).
Repeat these steps for the second LED.
Attach to Feeder PCB
![IMG_3165 copy.jpg](/proxy/?url=https://content.instructables.com/F0O/OKA9/H1JUDY2S/F0OOKA9H1JUDY2S.jpg&filename=IMG_3165 copy.jpg)
![IMG_3166 copy.jpg](/proxy/?url=https://content.instructables.com/F1N/VLQR/H1JU3ND7/F1NVLQRH1JU3ND7.jpg&filename=IMG_3166 copy.jpg)
![IMG_3167 copy.jpg](/proxy/?url=https://content.instructables.com/F46/4FG2/H1JU3ND9/F464FG2H1JU3ND9.jpg&filename=IMG_3167 copy.jpg)
![Screen shot 2012-05-04 at 5.11.57 PM.png](/proxy/?url=https://content.instructables.com/F5L/RTL6/H1PITAQG/F5LRTL6H1PITAQG.png&filename=Screen shot 2012-05-04 at 5.11.57 PM.png)
Attach Control Buttons
![IMG_3168 copy.jpg](/proxy/?url=https://content.instructables.com/F4L/OLLS/H1JUGHD4/F4LOLLSH1JUGHD4.jpg&filename=IMG_3168 copy.jpg)
![IMG_3170 copy.jpg](/proxy/?url=https://content.instructables.com/FDL/8NWR/H1JU6KW1/FDL8NWRH1JU6KW1.jpg&filename=IMG_3170 copy.jpg)
![IMG_3171 copy.jpg](/proxy/?url=https://content.instructables.com/F3K/70RF/H1JUDY40/F3K70RFH1JUDY40.jpg&filename=IMG_3171 copy.jpg)
Wire Power
![IMG_3177 copy.jpg](/proxy/?url=https://content.instructables.com/FUM/41R4/H1JUDY4E/FUM41R4H1JUDY4E.jpg&filename=IMG_3177 copy.jpg)
![IMG_3179 copy.jpg](/proxy/?url=https://content.instructables.com/FBL/BYJ1/H1JUA1L6/FBLBYJ1H1JUA1L6.jpg&filename=IMG_3179 copy.jpg)
Attach Arduino and Ethernet Shield
![IMG_3175 copy.jpg](/proxy/?url=https://content.instructables.com/FXD/M347/H1JU3NDG/FXDM347H1JU3NDG.jpg&filename=IMG_3175 copy.jpg)
![IMG_3172 copy.jpg](/proxy/?url=https://content.instructables.com/F3C/ES9L/H1JUI5OD/F3CES9LH1JUI5OD.jpg&filename=IMG_3172 copy.jpg)
![IMG_3173 copy.jpg](/proxy/?url=https://content.instructables.com/FGU/KLQW/H1JUDY41/FGUKLQWH1JUDY41.jpg&filename=IMG_3173 copy.jpg)
![IMG_3174 copy.jpg](/proxy/?url=https://content.instructables.com/FVE/P78J/H1JUGHDU/FVEP78JH1JUGHDU.jpg&filename=IMG_3174 copy.jpg)
Stack arduino, ethernet shield, and protoboard on top of each other.
Drill Holes in Enclosure
![IMG_3294 copy.jpg](/proxy/?url=https://content.instructables.com/F32/U5RK/H1QML969/F32U5RKH1QML969.jpg&filename=IMG_3294 copy.jpg)
Connect USB and Ethernet
![IMG_3296 copy.jpg](/proxy/?url=https://content.instructables.com/FNN/SEAB/H1QML96B/FNNSEABH1QML96B.jpg&filename=IMG_3296 copy.jpg)
![IMG_3297 copy.jpg](/proxy/?url=https://content.instructables.com/FGA/15DZ/H1PIT5ZQ/FGA15DZH1PIT5ZQ.jpg&filename=IMG_3297 copy.jpg)
![IMG_3298 copy.jpg](/proxy/?url=https://content.instructables.com/F2G/12RE/H1JUJB6A/F2G12REH1JUJB6A.jpg&filename=IMG_3298 copy.jpg)
Plug a usb cable and an ethernet cable to the ports on the arduino and the ethernet shield. Thread cables through the holes you've just drilled in the project enclosure.
Reassemble Enclosure
![IMG_3302 copy.jpg](/proxy/?url=https://content.instructables.com/FSX/5K8J/H1PIT66W/FSX5K8JH1PIT66W.jpg&filename=IMG_3302 copy.jpg)
Batteries
![IMG_3180 copy.jpg](/proxy/?url=https://content.instructables.com/FJR/CYK0/H1JUA1L8/FJRCYK0H1JUA1L8.jpg&filename=IMG_3180 copy.jpg)
Firmware
![arduino_logo1.png](/proxy/?url=https://content.instructables.com/FEZ/NFAO/H1JUIJ22/FEZNFAOH1JUIJ22.png&filename=arduino_logo1.png)
This firmware will read incoming twitter data so that if you tweet "feed me!" from the username omnomnom the arduino will light up the two LEDs attached to pins 2 and 3 for 1 second, causing the food delivery sequence to start.
I am using Arduino 1.0 for this project, I recommend downloading this version (or later) for this project. If you do not want to use the new version, make sure you have the following Arduino libraries (they are bundled with v1.0):
- Ethernet (for the Ethernet Shield)
- EthernetDHCP (for self-configuring the IP address is you use DHCP at home)
Turn on the power switch on the bottom of the feeder, the LCD should flash 12:00 and the motors should run through the food delivery sequence once. Refer to the manual if you would like to set the clock or set additional food timers, this won't be necessary for the project. Press the rec button and record a personalized message for your pet, this will play at the end of each food delivery sequence.
Here is the Firmware:
<pre>/* Twitter Client with Strings This sketch connects to Twitter using an Ethernet shield. It parses the XML returned, and looks for <text>this is a tweet</text> You can use the Arduino Ethernet shield, or the Adafruit Ethernet shield, either one will work, as long as it's got a Wiznet Ethernet module on board. This example uses the DHCP routines in the Ethernet library which is part of the Arduino core from version 1.0 beta 1 This example uses the String library, which is part of the Arduino core from version 0019. Circuit: * Ethernet shield attached to pins 10, 11, 12, 13 created 21 May 2011 by Tom Igoe modified by Amanda Ghassaei June 2012 https://www.instructables.com/id/Twitter-Controlled-Pet-Feeder/ This code is in the public domain. */ #include <SPI.h> #include <Ethernet.h> //variable to prevent overfeeding boolean justFed = 1; // Enter a MAC address and IP address for your controller below. // The IP address will be dependent on your local network: byte mac[] = { 0x00, 0xAA, 0xBB, 0xCC, 0xDE, 0x01 }; IPAddress ip(190,298,34,132); //<<< ENTER YOUR IP ADDRESS HERE!!! // initialize the library instance: EthernetClient client; const int requestInterval = 60000; // delay between requests = 1min char serverName[] = "api.twitter.com"; // twitter URL boolean requested; // whether you've made a request since connecting long lastAttemptTime = 0; // last time you connected to the server, in milliseconds String currentLine = ""; // string to hold the text from server String tweet = ""; // string to hold the tweet boolean readingTweet = false; // if you're currently reading the tweet void setup() { pinMode(2, OUTPUT); pinMode(3, OUTPUT); // reserve space for the strings: currentLine.reserve(256); tweet.reserve(150); // initialize serial: Serial.begin(9600); // attempt a DHCP connection: if (!Ethernet.begin(mac)) { // if DHCP fails, start with a hard-coded address: Ethernet.begin(mac, ip); } // connect to Twitter: connectToServer(); testing(); } void loop() { if (justFed){ if (client.connected()) { if (client.available()) { // read incoming bytes: char inChar = client.read(); // add incoming byte to end of line: currentLine += inChar; // if you get a newline, clear the line: if (inChar == '\n') { currentLine = ""; } // if the current line ends with <text>, it will // be followed by the tweet: if ( currentLine.endsWith("<text>")) { // tweet is beginning. Clear the tweet string: readingTweet = true; tweet = ""; } // if you're currently reading the bytes of a tweet, // add them to the tweet String: if (readingTweet) { if (inChar != '<') { tweet += inChar; } else { // if you got a "<" character, // you've reached the end of the tweet: readingTweet = false; Serial.println(tweet); if(tweet == ">feed me!"){ digitalWrite(2, HIGH); digitalWrite(3, HIGH); Serial.println("LED ON!"); delay(1000);//turn on for 1 sec digitalWrite(2, LOW); digitalWrite(3, LOW); justFed = 0; } if(tweet != ">feed me!"){ digitalWrite(2, LOW); digitalWrite(3, LOW); Serial.println("LED OFF!"); } // close the connection to the server: client.stop(); } } } } else if (millis() - lastAttemptTime > requestInterval) { // if you're not connected, and two minutes have passed since // your last connection, then attempt to connect again: connectToServer(); } } else if (millis() - lastAttemptTime > 14400000){//if four hours has passed since last feeding justFed = 1; } } void testing(){ digitalWrite(2, HIGH); digitalWrite(3, HIGH); delay(1000); digitalWrite(2, LOW); digitalWrite(3, LOW); } void connectToServer() { // attempt to connect, and wait a millisecond: Serial.println("connecting to server..."); if (client.connect(serverName, 80)) { Serial.println("making HTTP request..."); // make HTTP GET request to twitter: client.println("GET /1/statuses/user_timeline.xml?screen_name=nomnomnomfeeder&count=1 HTTP/1.1"); client.println("HOST: api.twitter.com"); client.println(); } // note the time of this connect attempt: lastAttemptTime = millis(); }
You will need to make a two edits before this firmware is ready to use.
1. Insert your IP address in the following line at the top of the firmware:
IPAddress ip(190,298,34,132); //<< ENTER YOUR IP ADDRESS HERE!!!
if you don't know your IP address open File>>Examples>>Ethernet>>DhcpAddressPrinter, upload this code to your arduino with the ethernet shield plugged in (and ethernet cable connected), and open the serial monitor Tools>>SerialMonitor
2. Change the username of your twitter account in the following line (from the function connectToServer():
client.println("GET /1/statuses/user_timeline.xml?screen_name=nomnomnomfeeder&count=1 HTTP/1.1");
Upload firmware on your arduino board, plug in the ethernet modem/router. Tweet "feed me!" from your twitter account and you should see your pet feeder dispense food in a minute or less. The feeder will not receive any further tweets for four hours (to prevent over feeding), during this time, tweet another message to replace "feed me!" as your most recent message.
Try It Out
![peanut.jpg](/proxy/?url=https://content.instructables.com/FMC/39Q4/H461X1TJ/FMC39Q4H461X1TJ.jpg&filename=peanut.jpg)
Set up a Twitter account and tweet the password you set in the firmware. Within a minute you should see the pet feeder dispense food.