loading
Picture of Closable Food Dish with Twitter Notification

Hello! Welcome to my first Instructable! Here I'll be showing you how to make my homemade closable food container that sends a Twitter notification every time your pet goes to eat.

 
Remove these adsRemove these ads by Signing Up

Step 1: Materials

Picture of Materials
photo 2 (1).JPG

Here's what you need in order to make this work. Now, this project is very flexible, so you can substitute some parts out. Here's what I used:

Arduino Uno

Rfid tag and sensor

Ethernet shield

Some jumper cables

An old DVD player, or anything with a DC motor, and keep it's other insides.

Cardboard and any material that you want to house your pet feeder in

A bowl for the food

An ethernet cable

A 9v plugin that's compatible with the Arduino. (So that you can just plug this device into the wall after you get done coding)

Step 2: Preparing the DVD player

Picture of Preparing the DVD player
IMG_1018.jpg
photo 2 (1).JPG

Basically, just take apart all of the inner components of the DVD player. I had worked with a rather large one, so I recommend working with one that's a little smaller. Figure out which buttons work the CD tray, and reuse them as your buttons that you'll push to open and close the tray whenever you need to.

This part is pretty self explanatory, just make sure that you "trim the fat" with hardware that you don't need, but salvage anything that you need to keep that CD tray working.

You can see that I saved the power supply cord, the on/off button, the CD tray, and the long circuit board that had the button that opens and closes the tray.

Step 3: Wiring up Everything

Picture of Wiring up Everything
photo 1 (2).JPG
photo 1 (3).JPG
IMG_1037.jpg

Now to just plug everything in!

Connect your ethernet shield to the arduino.

Connect the ethernet shield to your router via ethernet cable.

Connect your arduino to your computer

Breadboard the rfid sensor like in this tutorial:

http://www.instructables.com/id/Arduino-and-RFID-f...

Also, be sure that you follow the above tutorial completely. It will show you how to get your tag's unique ID number so that your rfid will be able to accept it and do something with it.

Step 4: The Code

Picture of The Code

Now go into your Arduino sketch and paste this code, be sure to change your IP address on the code from mine, along with anything else that is specific to your computer.

The above is the twitter that was notified about my cat eating

These tutorials help immensely, and I highly recommend reading and studying them.

http://tronixstuff.com/2013/12/04/arduino-tutorial...

http://tronixstuff.com/2013/12/06/arduino-tutorial...

(to get your twitter token) https://dev.twitter.com/docs/auth/tokens-devtwittercom

and now for the code:

#include <spi.h><br>#include <ethernet.h>
#include <twitter.h>
#include <softwareserial.h>
SoftwareSerial RFID(2, 3); // RX and TX
byte mac[] = {   0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; // create MAC address for ethernet shield
byte ip[] = {192,168,1,144}; // choose your own IP for ethernet shield
Twitter twitter("2602202863-kZu53ICKT3Cx9VjgnG4R5O6XnHB0inzUTLFhOph"); // replace my token with your token
char* Saying[] = {"Time for food.", "I'm having a snack", "I'm at my bowl", "What time is it? Food Time!", "Lunch sounds good", "Eating", "Fooooood", "I'm eating", "Le Feeeding Time", "Om nom nom", "Le Noms", "Time for feeding", "Food Time!", "FOOD!", "Time to Pig Out"};</softwareserial.h></twitter.h></ethernet.h></spi.h></p><p>int data1 = 0;
int ok = -1;
int yes = 13;
int no = 12;</p><p>// use first sketch in <a href="http://wp.me/p3LK05-3Gk" rel="nofollow">  http://wp.me/p3LK05-3Gk  </a> to get your tag numbers
int tag1[14] = {2,48,51,48,48,52,70,52,70,50,50,50,49,3};
int tag2[14] = {2,52,48,48,48,56,54,67,54,54,66,54,66,3};
int newtag[14] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0}; // used for read comparisons</p><p>void setup()
{
RFID.begin(9600); // start serial to RFID reader
Serial.begin(9600); // start serial to PC
pinMode(yes, OUTPUT); // for status LEDs
pinMode(no, OUTPUT);
delay(5000);
  Ethernet.begin(mac, ip);
  Serial.begin(9600);
}</p><p>boolean comparetag(int aa[14], int bb[14])
{
boolean ff = false;
int fg = 0;
for (int cc = 0 ; cc < 14 ; cc++)
{
if (aa[cc] == bb[cc])
{
fg++;
}
}
if (fg == 14)
{
ff = true;
}
return ff;
}</p><p>void checkmytags() // compares each tag against the tag just read
{
ok = 0; // this variable helps decision-making,
// if it is 1 we have a match, zero is a read but no match,
// -1 is no read attempt made
if (comparetag(newtag, tag1) == true)
{
ok++;
}
if (comparetag(newtag, tag2) == true)
{
ok++;
}
}</p><p>void tweet(char msg[])
{
  Serial.println("connecting ...");
  if (twitter.post(msg))
  {
    // Specify &Serial to output received response to Serial.
    // If no output is required, you can just omit the argument, e.g.
    // int status = twitter.wait();
    int status = twitter.wait();
    if (status == 200)
    {
      Serial.println("OK.");
    } 
    else
    {
      Serial.print("failed : code ");
      Serial.println(status);
    }
  } 
  else
  {
    Serial.println("connection failed.");
  }
}
 </p><p>void readTags()
{
ok = -1;</p><p>if (RFID.available() > 0)
{
// read tag numbers
delay(100); // needed to allow time for the data to come in from the serial buffer.</p><p>for (int z = 0 ; z < 14 ; z++) // read the rest of the tag
{
data1 = RFID.read();
newtag[z] = data1;
}
RFID.flush(); // stops multiple reads</p><p>// do the tags match up?
 checkmytags();
}
// now do something based on tag type
if (ok > 0) // if we had a match
{
Serial.println("Accepted");
digitalWrite(yes, HIGH);
delay(1000);
digitalWrite(yes, LOW);
long randNumber = random(15);
tweet(Saying[randNumber]);
delay(10000);
ok = -1;
}
else if (ok == 0) // if we didn't have a match
{
Serial.println("Rejected");
digitalWrite(no, HIGH);
delay(1000);
digitalWrite(no, LOW);</p><p>ok = -1;
 }
}
void loop()
{
  readTags();
}

Step 5: Put it all Inside Your Container / Final product!

Picture of Put it all Inside Your Container / Final product!
photo 2 (4).JPG
photo 3 (2).JPG

Just like it says, put it all inside the container, put in the food bowl, position the rfid so that it is next to the food bowl, place the tag around your pet's collar, and then just let them have at it! My cat took to it right away.

I hope this tutorial was helpful! This project is very open to modification, but this is the "low budget" version!

Enjoy!

Here's a Youtube video showing the cat eating from the dish, and the dish sending a signal to Twitter to let me know that he's using it:

https://www.youtube.com/watch?v=IqLA4sHT9eU

IMG_1042.MOV(516x290) 16 KB
seamster11 months ago

Cool! Nice first project. Keep it up!