Twittering Cat Door

I just read “Making Things Talk” by Tom Igoe , and wanted to have a go at a physical computing project.

I thought I’d make our cat door “twitter”.  Ok, it’s not original, there are a few projects already done and published out there, but I thought it provide a fairly easy path into several topics I’ve not explored before :

I’m not complete on this project yet, but you can read how I’ve got on after the break…


To detect when the cat enters the house through the cat door, and post an “I’ve just come in” event to twitter. Similarly, when she goes out, to post a “I’ve just gone out” event to twitter.

All this must be done with low power consumption, and cheap components (no RFID detector, or web cam, as I don’t want to power a laptop 24 hours a day, and pay for the juice).


catdoorphoto1 (no idea why it’s come out on it’s side 🙂

Overall, a normal catflap. This one happens to be a magnetic one which lets the cat in only if she has a collar. We’ve had neighbours cats coming in and eating food before we got this one.

The additions I’ve made are two reed switches, top and bottom, with wires which connect them to the arduino. These are stuck-on with Blu-tak right now.

In the middle of the door, there is a taped-on magnet. I’ll explain what that’s for next…


So the magnet taped to the door triggers the “coming in” sensor at the top of the unit, and the cat triggers the “going out” sensor at the bottom of the unit.

These switches are connected to the arduino +5v and via a pull-down resistor arrangement, to pins 0 and 1.

The arduino code can then hook interrupts from those pins to get a signal which fires on the “rising edge” of the switch state change, so there is no need to poll constantly for a switch state change.


Here you can see the circuit wired to the arduino on a breadboard, and the two reed switches.

The circuit has 2 LEDs attached also. The green one indicates that there is a connection to the broker which is working, the red one indicates that there is a problem with the connection to the broker.


Control logic on the arduino uses the arduino MQTT library, with the ethernet library, to connect to and post events to the broker.


I already had a damned small message broker installed on the slug, so it was an obvious choice to make the arduino publish a “cat coming in” or “cat going out” to the broker, and have a smarter program pre-process the events in the slug before sending them on to twitter.

Using a broker in this way also allows multiple programs to access the events, so a logger to a database can also be written, hooked up to a web page. I have left this for later as it’s an add-on to view historic events, just to prove how lazy our cat is.

The slug runs a java program using the “cvm” runtime, and subscribes to the broker topic so it can see the events from the door, selects one of the pre-canned phrases and posts that to twitter from there.


These kind-of speak for themselves…

A few were created by me with a hand-held magnet, just to get more traffic, as our cat is soooo lazy, and I didn’t want to wait getting the screen shot.



  • An arduino off cool components. I went for the beginners kit, which it turns out would have been cheaper at nuelectronics. Never mind.
  • A regulated, switched 9v (600ma) power supply. I don’t want to power a PC just to get a USB power connection to the arduino. This came from the most excellent Rapid Components, which seems to sell pretty much anything to do with electronics.
  • An ethernet shield, also from cool components, so I can connect the arduino to our home network.
  • A multi-meter, as I would need to test circuits. This was in the £7 area from Maplins. A simple handheld one which does volts, ohms and a few other things I’ve never used.
  • Two “reed switches” from Maplins, though they do sell them in the local D.I.Y store too. These are switches which are sensitive to magnetism, so when a magnet is near, the switch is “on”. They are commonly used on windows and doors and connected to burglar alarms.
  • A magnet, which I had already, stuck to the fridge door.
  • A few LEDs and resistors
  • A breadboard for prototyping
  • A cat door. We have a Staywell 32 magnetic door, which allows the cat to come in only if she has a magnet hanging from her collar.
  • One cat 🙂 Pretty obvious, but you need one of these to cause events to be generated, unless you use a magnet and do it yourself as above.

Next steps

  • Use the built-in pull-up resistors which you can turn on in software, instead of those I had to add, and use the falling-edge of the circuit to fire the interrupt.
  • Use vero-board rather than a bread-board, or get a proto-shield to mount the components onto.
  • Use a jack connector of some sort to plug the reed switches into the board.
  • Smarten it all up with a box, white wires so they are non-obvious, and screw it to the wall
  • Smarten-up the software so it recovers better when the connection to the broker fails (which it does sometimes with timeouts).

See how I did in other articles :

Enhanced twittering cat door

Packaging the twittering cat door


I’ve learnt a load of stuff doing this, and it’s given me a glimpse of what’s possible. Fantastic fun.

Feel free to follow @TipsyTheCat … I expect I’ll leave it all running for some time as I refine it.

This entry was posted in Electronics and tagged , , , , , , . Bookmark the permalink.

4 Responses to Twittering Cat Door

  1. Pingback: » Social Home Automation

  2. Pingback: Packaging the twittering cat door « Cobweb

  3. dumbified says:

    Nice read, may I ask what are the slugs and broker for? what do they do? from the diagrams it looks like they are 2 pieces of commercial hardware, some sort of a server or something, can you give me more details?

    • techcobweb says:

      The “Slug” is a slang name the linksys NSLU2 got from people who burn a linux variant onto it. Originally it’s a NAS box, very low power (speed and watts), but can run some server code when it’s been tweaked.
      A “broker” is a publish-subscribe server, software which gets messages/events on a topic, and lets programs register an interest in that topic, who then receive the events as they occur. It’s good for separating your consumers from producers, and lets you “listen” to the flow of events too. I used it for electricity monitoring also. Since this article, I took down the cat door monitor, and moved off the slug to an acer revo, running ubuntu and using 39 watts always-on. Loads more flexible than the Slug solution, but I still run a micro-broker.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s