proximity sensor only activated by certain things

Okay, so I’m very new to arduino but I know that this can be done. I have five cats. Three of them can eat normal food, and two can only eat expensive urinary tract food. My goal is to build a two automated feeding stations. One for each type of food. That part seem straightforward, just a servo set to a some sort of timer. My problem is that I would have to find a way of keeping the cats out of the food that doesn’t belong to them. I’m thinking something like a small transmitter on the collar that, when the signal is received by the arduino, will slide a cover over the bowl with another servo or something. I just don’t even know how to search for that. I’ve looked into bluetooth but everything I found required an arduino for both transmitting and receiving. Though it would be cute, I’m sure my cats wouldn’t like wearing a little backpack with an arduino in it. To sum it up, the auto feeding part seems straightforward, and so does the bowl covering. I just dont know how to get the signal from the cat to the arduino to signal the bowl covering. I would need two separate bands of communication (IDK if I’m even using this terminology correctly) to allow one group of cats to eat at one station but denying the other group and vise versa. Any help would be greatly appreciated. Whoever contributes the most will have their name written on the back of the project. It’s a very honorable award. Thanks in advance.

Edit: I would really like it if the power required by whatever is on the cat to be small. The receivers can be plugged in, but i would like to use as small a battery as possible on the animals.

Awesome goal.

Where I live (The netherlands) most domestic cats are chipped with a RFID tag. You can get cat doors and feeding stations that only work on your own cat and leave that pesky cat-from-next-door out!

If your cats have a RFID tag, read the RFID-tag and build a system around that. Putting a RFID chip in there collar would also be an option.

A RFID tag doesn't need a power supply!

This sort of thing is done with RFID tags in the collar, it is used normally so that only your cat gets through the cat flap. But you can use that for your feeding station.

I have made a similar solution for a cat flap for my three cats. I use 125khz RFID tags that they have i their neck collar. Sensing distance is between 50..100 mm so its an almost perfect distance. There are no powering requirements on the tag itself.

Oh cool! Thanks for the reply. I guess I was under the impression that rfid was only super close proximity, like basically touching. Would rfid work with a 1-3 foot radius from the receiver?

Edit: sorry for asking about proximity right after you posted about it, nilton61. I was in the process of asking the question when you posted.

No that is too far. You can get about 18 inches max with some RFID readers. You will need one reader per feeding station. Note that two tags in range results in no reading.

Is there any way to get past that no read with two tags in range? Will it read if there are three? I could use multiple rfid readers per arduino, couldn't I? I'm thinking three on one board and two on the other to solve the "no read with two tag" problem.

There are RFID readers for multiple tags but these are expensive. Yes three is the same no read as two.

It depends on the sort of output your RFID reader has. If they use serial then it is best to use an Arduino mega as that has four serial ports.
If you want to use a UNO then you need a reader with a Wiegand output.

I am on my iPad at the moment so I can’t post a link but I have a project on line where I attach three Weagand readers , just google the words
Myzen crazy people
To find it. It explains what Weagand is and how to interface to it.

Thanks so much . I'll do some research in that direction.

tercelkisor:
Oh cool! Thanks for the reply. I guess I was under the impression that rfid was only super close proximity, like basically touching. Would rfid work with a 1-3 foot radius from the receiver?

Edit: sorry for asking about proximity right after you posted about it, nilton61. I was in the process of asking the question when you posted.

Possible solution: Put the RFID tag on the bottom of the collar and the antenna on the floor. Unless you have giant cats it’ll be in range.

I did use 2 rfid readers on a nano. But that forced me to write my own serial receive routine. Here comes an exerpt(the code is written using my SM state machine library if you wonder about some of the constructs):

#define PACKETSIZE 14
byte packet[PACKETSIZE];

State idleB(){//continuous idle state
  if(!digitalRead(INCOMING)) Flap.Set(check_incoming, Nop);
  if(!digitalRead(OUTGOING)) Flap.Set(check_outgoing, Nop);
}//idleB()

State check_incoming(){
  readTag(INCOMING, packet);
  Serial.print("Incoming tag:");
  PrintTagCRC();
  Serial.println("....");
  //...
}//incoming

State check_outgoing(){
  readTag(OUTGOING, packet);
  Serial.print("Outgoing tag:");
  PrintTagCRC();
//....
}//outgoing


#define INITDELAY 130//time for startbit + 1/2 bit - time för reading bits in us
#define BITDELAY 98//time for 1 bit - time for reading in us

byte recByte96_1_8(int pin){//receive 1 byte with 1 startbit and 8 data bits
  byte r = 0;//for storing returnvalue
  delayMicroseconds(INITDELAY);//wait for 1,5 bit
  for(int i = 0; i<8; i++){//8 bits
    r = (r>>1)+128*digitalRead(pin);//bits come in with lsb first
    delayMicroseconds(BITDELAY);//bit time 
  }//for(int i)
  return r;
}//Receive(int pin)

void readTag(int pin, byte data[]){
  for(int i = 0; i < PACKETSIZE; i++){
    while(digitalRead(pin));//wait for startbit
    data[i] = recByte96_1_8(pin);
  }//for(int i)
}//readTag(byte *data);

I'm seriously a novice so please don't stone me. I've really only done blinking lights and potentiometers and even those were tutorial things. I've found this http://www.instructables.com/id/Reading-RFID-Tags-with-an-Arduino/ and It seems super simple. He says towards the end that you can move your serial pin to digital once it's set up. Wouldn't that free me up to use multiple readers per arduino? This probably shows my ignorance, but i don't even know how a rfid tag code could be digital. doesn't digital only have two states? does the reader take care of the analog, interpreting it into a digital signal of high or low? I realize that this project is over my head, but i think it will be a good learning experience. I appreciate whatever patience afforded me.

I just read what grumpy_mike said about types of output from different readers. Anyone know of good, cheap readers with digital output?

I've come to the conclusion that with 125khz or 310(?), the range with probably be right for my construction, and will be small enough to fix the multiple tag problem.

What do you do if your feeder correctly identifies a cat and dispenses food and then another cat comes along? You still have the problem of keeping the cats out of the food that doesn't belong to them.

Don

The food will be dispensed on a schedule, like every 8 hours. The rfid is to trigger a noise and to move a cover over the open bowl when a cat attempts to eat at the wrong station.

The problem is that there will be two bowls at one station and three at the other. I think having a reader per bowl is the right way to go but i don't want to have to have an arduino on each reader.

Also, what is a better reader? the parallax 28140 or the id-20la. Those two seem to be most widely used and after all costs will be about the same for me. Is there another alternative? The nice thing about the 28140 is its size, which is a good thing in my application, and the fact that the keyfob things are sold from the same store (only $1) so I know they will work.

I've found this http://www.instructables.com/id/Reading-RFID-Tags-with-an-Arduino/ and It seems super simple. He says towards the end that you can move your serial pin to digital once it's set up. Wouldn't that free me up to use multiple readers per arduino?

OK what you have to learn is that most instructiables are written by idiots.

On a Uno you can use at the most two RFID readers that use serial.

but i don't even know how a rfid tag code could be digital. doesn't digital only have two states?

Because it sends a pattern on high and low in a burst. There can be over 80 changes in the state to read one token. Your Arduino has to look at those changes and make them into numbers. This is called Asynchronous communication. http://en.wikipedia.org/wiki/Asynchronous_serial_communication This is hard work for the computer so the Arduino has some hardware built in to do some of the heavy lifting on this. Because of this you can have one reader being fed into this hardware and one other being looked at by software. But you can only have one other. On a Mega there are four lots of hardware that do this so it is easy to have four serial readers attached.

However, because you might want to use the serial monitor on the IDE to look at things while developing and debugging then you can use the software way of reading things and then switch back to the hardware way when you have finished, thus freeing up the input / output pin you used when you were connecting it by software. That is what that comment means.

Most hobby RFID readers use this serial method of outputting the code it reads. However, in the commercial world the Wegand interface is used a lot, which is easier to use if you want to monitor a lot of readers from a Uno.

Hope that helps.

Okay. I think I get it. I’ll probably choose the mega route. Wiegand seems a bit daunting. I’m going to order one or two readers to start fiddling with the code. Which would you recommend? I’ll be buying five so a low price would be awesome. I think I would need about five cm of reliable range, though my design might have the tag touching the reader when a cat tries to eat, so theres a bit of wiggle room there, I suppose. So far these are the ones I’ve looked into.

1.MF522 -<$10
2.Parallax 28140 -$45
3.ID-20 -$35+$2 for the breakout board.

I would love to hear great things about the MF522. Thanks for the help.

Sorry I have not had any first hand experience with those readers. As I used to design RFID readers I never have the need to actually buy one.

For the ultimate in low cost have you seen this page:- http://playground.arduino.cc/Main/DIYRFIDReader

i appreciate all the help. I ended up purchasing a sunfounder rc522 reader. I found some code that will write the UID to the serial monitor. It was only $12, so I’m just experimenting at the moment. Here’s my issue. I know that the reader uses uart but I’ve only found a way to use spi so far. If I’m remembering correctly, I can’t use more than one spi at a time, so I’m wondering how I would set up the uart. I’ll post one of the functioning codes that I’ve found as well as some pictures for reference. Thanks for all the help.

/*
 * Dump block 0 of a MIFARE RFID card using a RFID-RC522 reader
 * Uses MFRC522 - Library to use ARDUINO RFID MODULE KIT 13.56 MHZ WITH TAGS SPI W AND R BY COOQROBOT. 
 ----------------------------------------------------------------------------- 
 * Pin layout should be as follows:
 * Signal     Pin              Pin               Pin
 *            Arduino Uno      Arduino Mega      MFRC522 board
 * ------------------------------------------------------------
 * Reset      9                5                 RST
 * SPI SS     10               53                SDA
 * SPI MOSI   11               52                MOSI
 * SPI MISO   12               51                MISO
 * SPI SCK    13               50                SCK
 *
 * Hardware required:
 * Arduino
 * PCD (Proximity Coupling Device): NXP MFRC522 Contactless Reader IC
 * PICC (Proximity Integrated Circuit Card): A card or tag using the ISO 14443A interface, eg Mifare or NTAG203.
 * The reader can be found on eBay for around 5 dollars. Search for "mf-rc522" on ebay.com. 
 */

#include <SPI.h>
#include <MFRC522.h>

#define SS_PIN 10    //Arduino Uno
#define RST_PIN 9
MFRC522 mfrc522(SS_PIN, RST_PIN);        // Create MFRC522 instance.

void setup() {
        Serial.begin(9600);        // Initialize serial communications with the PC
        SPI.begin();                // Init SPI bus
        mfrc522.PCD_Init();        // Init MFRC522 card
        Serial.println("Print block 0 of a MIFARE PICC ");
}

void loop() {
        
        // Prepare key - all keys are set to FFFFFFFFFFFFh at chip delivery from the factory.
        MFRC522::MIFARE_Key key;
        for (byte i = 0; i < 6; i++) key.keyByte[i] = 0xFF;
        
        // Look for new cards
        if ( ! mfrc522.PICC_IsNewCardPresent()) {
                return;
        }

        // Select one of the cards
        if ( ! mfrc522.PICC_ReadCardSerial())    return;
        
        Serial.print("Card UID:");    //Dump UID
        for (byte i = 0; i < mfrc522.uid.size; i++) {
          Serial.print(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " ");
          Serial.print(mfrc522.uid.uidByte[i], HEX);
        } 
        Serial.print(" PICC type: ");   // Dump PICC type
        byte piccType = mfrc522.PICC_GetType(mfrc522.uid.sak);
        Serial.println(mfrc522.PICC_GetTypeName(piccType));
         
        byte buffer[18];  
        byte block  = 0;
        byte status;
        //Serial.println("Authenticating using key A...");
        status = mfrc522.PCD_Authenticate(MFRC522::PICC_CMD_MF_AUTH_KEY_A, block, &key, &(mfrc522.uid));
        if (status != MFRC522::STATUS_OK) {
           Serial.print("PCD_Authenticate() failed: ");
           Serial.println(mfrc522.GetStatusCodeName(status));
           return;
        }
        
        // Read block
	byte byteCount = sizeof(buffer);
	status = mfrc522.MIFARE_Read(block, buffer, &byteCount);
	if (status != MFRC522::STATUS_OK) {
	    Serial.print("MIFARE_Read() failed: ");
	    Serial.println(mfrc522.GetStatusCodeName(status));
	}
        else  // Dump data
	for (byte index = 0; index < 16; index++) {
	    Serial.print(buffer[index] < 0x10 ? " 0" : " ");
	    Serial.print(buffer[index], HEX);
	    if ((index % 4) == 3) Serial.print(" ");
	}
        Serial.println(" ");
        mfrc522.PICC_HaltA(); // Halt PICC
        mfrc522.PCD_StopCrypto1();  // Stop encryption on PCD
       
}

https://drive.google.com/file/d/0B3jzHUCT-iFVN0NjaF9YemZrOWs/edit?usp=sharing (monitor)

https://drive.google.com/file/d/0B3jzHUCT-iFVUHdocjVMcF94OUk/edit?usp=sharing (pins)

I have it wired just how the beginning of the code says, and it does what it’s supposed to. How would i go about utilizing the tx/rx hardware which I assume has something to do with uart?