RFID Cat Door

236,730

470

100

Introduction: RFID Cat Door

This is a cat door/flap that can only be opened by the animal that wears the appropriate RFID tag. Arduino controls the process. It features a custom made antenna large enough to function as a gate, which makes it easy for the animal to activate and quite reliable. Some methods and techniques are borrowed from my previous project, the RFID cat feeder. Whereas the feeder controls access to a food bowl, the door controls access to an entire room. The latest code can also distinguish between tags to allow the system to behave differently for different individuals.  


How it works:
1. In the beginning the door is locked, cat is outside
2. Cat walks up to the gate, RF tag gets read within about 4 inches
3. Door unlocks and a light comes on. 
4. Timer ensures that door stays unlocked long enough to give cat a chance to respond
5. Cat pushes open the flap and enters
6. Flap falls back, activates Hall effect sensor, and the door locks
7. Going from the inside out, an infrared proximity sensor detects the presence of an animal if within about 10 inches and unlocks the door.

Most animals will quickly learn to push the flap in response to the click (lock) and the light. Make sure that the edges of the door and the doorway are padded with soft material for when the tail gets caught! A few painful experiences may be enough to make the cat never want to go in there again. 

 The electronics are shown without enclosure, but it is advised to put an enclosure around the electronic parts once you're done. It is not further discussed in this Instructable however.  


Step 1: Parts List

- Arduino Duemilanove
- 5V RF reader module (Seeed Studio 125Khz UART or equivalent. Most readers come with a small antenna. To use the custom made antenna discussed here, you need a reader that allows connecting an external antenna)
- RF tag (I used these 35mm disc shaped ones)
- About 86 feet of 24 gauge magnet wire (longer than the piece shown in the photograph)
- Sharp GP2D12 infrared proximity sensor
- Two 12V electronic cabinet locks (Nordson electronic). Solenoids, basically.
- One 12V DC power supply
- Two TIP120 Darlington transistors
- One Hall-effect sensor
- One or more magnets to activate Hall-effect sensor over a range of about 2cm
- One 100 Ohm resistor
- Four 2 KOhm resistors
- Two pushbuttons
- One LED
- One hinge (one that moves easily but without much lateral movement, for precision)
- One 6" x 9" piece of 1/8" thick Plexiglas and perhaps another piece of about 6" x 3"  to mount the locks
- Hookup wire, including about 27" extra thin (26 AWG or thinner)
- Nuts, bolts and serrated washers
- Rubber isolation strip or other soft material for padding the edges of the door and door post

The system comprises several 'modules' (solenoids, RF reader, and so on). One of the pictures here shows the basic plan with the modules connected to the Arduino (the electronics). In the next steps the mechanical parts and each of the modules will be discussed in detail. 

Step 2: Make the Door

The door is a Plexiglas flap hanging on a hinge. At the bottom, the doorpost will have two solenoids, one on each side of the flap, to block unauthorized animals from getting in. Pretty straightforward. Just a few things to keep in mind: 

Make sure that in the resting state, the flap is centered in between the two solenoids. In the picture that is in the red area around the dotted line down the middle. To achieve this it helps to have no heavy things hanging on one side, and to use a hinge with little friction. 

It helps to have a hinge without much lateral movement (sideways movement within the plane of the wall). This will help to make the hall-effect sensor (a magnet-actuated switch) work. I will discuss this more in detail in step ... 

The door needs to be rigid but light-weight so that it is easy to push it open and doesn't hurt when a tail gets caught. Make the corners smooth and add padding on the edges and the door post to minimize tail tribulations. 

Step 3: Make an Antenna

The antenna is nothing more than a coil of magnet wire connected to the RF reader. Most RF readers come with an antenna, but some allow the use of an external antenna. For this project I made a square antenna of 10 x 10 inches by winding 24 gauge magnet wire 24 turns around a sawed off bucket to make it sturdy. The distance between turns has to be as small as possible. I mounted the thing on the plywood with two pieces of wood as spacers to make it stand off from the wall a bit so the cat could activate it farther from the wall. The 35mm disc tags that I use are read up to 4 inches of the plane of the coil. The RF reader and antenna are powered with the 5v from the Arduino. Even though the Arduino works fine with just the USB cable, the RF reader works better when the Arduino is plugged into the wall with the 9v power adapter

More info about coil antennas:
Microchip Inc. Antenna circuit design for RFID applications (pdf)




Step 4: Hook-up the RF Reader

This project consists of several 'modules' that you need to hook up to the Arduino and test in advance. First hook-up the RF reader. You can use the 5v output of the Arduino to power it, and a digital port (I used 2) to get the signal. The RDM630 that I used also has pins for a led that I don't use. It also has an RX pin to send info back to the RF reader, but I don't use that either. Hook-up your antenna, get a tag and use the serial monitor of the Arduino to see if it's detected. Now you can also start working on improving the antenna by trying adding or removing turns, trying different shapes et cetera. Power the Adruino with the 9v power supply, not just USB because at least in my case that didn't work. You can download the file named 'rfid3.pde' to test. The code requires NewSoftSerial.h which can be obtained here

Step 5: Add Solenoids

Hook-up the solenoids up to the Arduino as in the schematic: connect the TIP120s to digital ports 5 and 6 with 2k resistors in between. One pin goes to ground, the other goes to the solenoid, with a diode across it (make sure you get the polarity right), and to the 12v supply in the end. The other wire of the power supply is ground. Connect that to the other grounds. Just connect all grounds of all components including the Arduino together. Over here you can download code to specifically test the two solenoids. 

Step 6: Add Hall Effect Sensor

The Hall effect sensor is for detecting whether the door is in the center, i.e. within the range that closing the locks makes sense. There are other solutions possible, such as mechanical/optical rotary encoders, contact sensors, beam break sensors. The main reasons for choosing a Hall effect sensor were that it does not add friction, it can be covered entirely, and I also was just curious how they work.

I did not want to put magnets on the door because that would make it heavier, so instead I put the switch on the door and the magnets in the door post. I had to use thin, very flexible wire otherwise the rigidity of it would push the flap off center. The sensor and wire is simply taped to the Plexiglas. I have two little magnets in the door post. At the closest point the sensor and magnets are 5mm apart. The range is about 3cm.    

Connect the signal pin of the Hall sensor to pin 4 and to through a 100 ohm resistor to 5v. Connect ground pin to the other grounds and the vcc pin to 5v. Add an LED to digital pin 7 with the appropriate resistor (used a green one with a 220 ohm resistor). 

Download Hall_effect.pde to test this part of the system.

Step 7: Add Proximity Sensor

For this system I only cared about which cat enters, and any creature may exit. Thus, I only needed RFID on one side. The door should open to any animal that approaches from the other side. An IR proximity sensor works well. 

Connect the out-pin of a Sharp GP2D12 to Analog port 0, the ground pin to the other grounds and the vcc pin to 5v. 

Download IR_test_analog.pde to test this part of the system

Step 8: Add Two Buttons and Load Final Code

Finally you can add buttons to open the locks manually (see schematic). .

In the final code downloadable here, I stored the value of two tags worn by the our animals, one with and one without access. When the animal without access tries to get in, the door is locked immediately.   

byte goodcode[6] = {0x1C, 0, 0xFC, 0xB2, 0x90};
byte badcode[6] = {0x16, 0, 0x78, 0xE7, 0xFE};

You have to find the code of the tags you are using and put those values into the arrays 'goodcode' and 'badcode'. The values are hexadecimal which need '0x' in front of it in this programming language. 

If you don't want to tag the other cat, shortening the open time (smaller value for variable 'open_time') can help, although that puts the burden on the cat with access to respond faster.   

It is a good idea to put an enclosure around the electronics, but that will not be discussed in this instructable.  

On a final note, if your antenna has a large range extending into the secured area, you may need to calibrate the positioning of the antenna and the proximity sensor a bit to make sure the RFreader is not activated from the inside. If the cat is inside and wants to go out, the proximity sensor has to detect the cat first. Once that happens, it is okay because in that part of the program, the RF reader is not checked. 


Microcontroller Contest

Second Prize in the
Microcontroller Contest

Be the First to Share

    Recommendations

    • Battery Powered Contest

      Battery Powered Contest
    • Plywood Challenge

      Plywood Challenge
    • Plastic Contest

      Plastic Contest

    100 Discussions

    1
    lizzmikl
    lizzmikl

    Question 5 weeks ago

    The link to the code doesn't work. Is there a way you could make it available? I am trying to make my own smart cat door, and it would be really helpful in compiling my overall code. Thanks!

    0
    reinhardtsmit
    reinhardtsmit

    5 months ago

    Even though this post is years old, I'd like to give something similar a try. I want to make an RFID-activated doorbell. which I want to put behind my door (on the inside). I've played around with a raspberry pi in the past, but it seems Arduino is more than enough for that, but I'm not sure which Arduino to get nowadays, there are so many different ones. What's the cheapest one that will be enough to make such a thing?

    0
    Isla09
    Isla09

    5 months ago

    good job

    1
    mkleino
    mkleino

    Question 8 months ago

    Anyone have photos of the actual connections between the arduino and each item?

    2
    mkleino
    mkleino

    Question 10 months ago

    could you repost the links to the code?

    1
    CopiousZoid
    CopiousZoid

    11 months ago on Step 8

    Is it just me or are the links to the final code returning a 403 Forbidden error. It appears the supporting code linked to are not avialable. Does anyone have access to the code? Very interested in trying this out.

    0
    CopiousZoid
    CopiousZoid

    Reply 11 months ago

    This is perfect, thanks so much!

    2
    Jarnbu
    Jarnbu

    Question 1 year ago on Step 3

    Hi, I’m trying to replicate your antenna exactly as this is the size I need, however I am unable to get a read with an antenna any larger than about 4”. Anything over this just doesn’t seem to energise the the tag.

    I am using the the RdM6300 reader

    Any learnings to share that might help a fellow hackster out ? :-)

    0
    wbp
    wbp

    Answer 1 year ago

    Make it 10" by 10" and use an RDM630, NOT and RDM6300. Otherwise it won't work. Been there...

    2
    Stealthspy589
    Stealthspy589

    1 year ago

    Does anyone still have the file with the code/able to provide it? I'm new to microcomputers, that's the only thing stopping me.

    0
    wbp
    wbp

    Reply 1 year ago

    Have you done any programming? If not, go to Adafruit.com, by an Arduino Uno and try out some of their excellent tutorials. The actual program you need will depend on how you decide to make the door. I chose to use a vertical slider instead of flap, because my poor cat just stares at cat flaps and refuses to open them (and we tried everything to teach him). Besides, programming is fun!

    0
    wbp
    wbp

    Tip 1 year ago

    I am working on one of these and discovered a few things I think others might find helpful. For one, make the antenna 10" by 10" just as he describes. I tried making it smaller but RF is not simple, and eventually I gave up, bought some wood dowels and a bit of plywood, and made one 10x10" with 24 gauge wire, and it works. (see picture) Secondly, do not bother with the RDM6300 boards available on Amazon or elsewhere. As he says, the RDM630 works better, lots better. Lastly, I learned something VERY interesting about the tags - bought a bag of 10 in assorted colors from Amazon. Picked the dayglo green one to test with as we thought it would be good on our cat's color. Had all kinds of trouble getting enough distance. In desperation started trying all of them, and discovered that the black and grey ones have excellent range, and all the other colors are far worse. Something in the pigment that detunes them? Or just random luck? 4 out of 6 seems to be more than just chance... Hope this helps some of you!

    IMG_20191108_130327cr.jpg
    0
    joseangel19.lol
    joseangel19.lol

    Question 1 year ago

    Does anyone still have the file with the code/able to provide it? I'm new to microcomputers, that's the only thing stopping me

    2
    gbarnes27
    gbarnes27

    1 year ago

    Was searching to figure out how to build a automatic door for my robotic mower for my fence. Thinking this would work but just wondering if any new code is out there?

    0
    mattcrisafulli
    mattcrisafulli

    Reply 1 year ago

    I am on the same search. I need a automatic door for my robot mower, but need to keep in the dogs. Any luck on building or buying something?

    0
    mikeusa02
    mikeusa02

    Question 2 years ago on Introduction

    Hi ! I am doing a senior project using 125KHz RFID reader, Arduino Uno and one solenoid to implement a pet door. Can you indicate the parts of code I should be using? Thank you.

    0
    slarti.fartfast
    slarti.fartfast

    2 years ago

    Wouldn't it make more sense to put the magnet on the door and the Hall sensor by the solenoid? less wiring and no flexing.

    0
    art1212art
    art1212art

    Question 2 years ago on Step 3

    how to calculate parameter of your antenna RFID ?
    I dont have a knowledge in antenna

    0
    Kneedeep248
    Kneedeep248

    3 years ago

    Hi,

    I came across this site in my search ....

    I see the last comment of 2017-05-01 and I wonder if there has been any other updates that some may have done since then?

    I know nothing of the tech, but I would love to have a pet door that works with my pet microchip.... I get the feeling more may be need than what is here with this project.... a better microchip reader??? Just hoping...

    Thanks,