Chickens & RFID

This is an ongoing project to track the laying and other activity of my chickens. Their coop is already wired with cameras that sometimes work, but we have a problem that some of the hens eat the eggs that have been laid. The only solution for this is to get rid of the offending chickens before the behavior spreads. [If anybody knows of other approaches, then I'd be interested to hear about them.]

There are other people who are trying to do similar things -- for example this project in the UK. I have also found a diagram that shows integration of chicken tracking with a digital scale so that you can track the weight of the chickens.

There are a number of components to the system, which are described below.

Web Application

I haven't really thought about this yet.

Data Storage

This will be a MySQL database and will record (at least) events when a chicken is detected and which detector triggered. There will also be a secondary table that shows the location of the chicken immediately prior to the detection. It may be possible to guess the current location (afer the detection), but there is always a direction ambiguity.

Network Interface

This unit will take the data from the front end (USB) and send it over the network to the data storage system. My barn is a fair distance from the house, and I use a Wifi router (WRT54G) acting as a bridge client in the barn to provide wired network connectivity there. Currently there are two systems which serve video. One is a four port NTSC camera capture device, and the other is a GuruPlug which has a bunch of webcams attached. The webcams are much higher quality, but they tend to flake out and need resetting. I think that the solution is to power cycle the whole system evry 24 hours or so.

Data Acquisition

This will be an Arduino which talks to the individual RFID reader modules. The protocol between the RFID modules and the Arduino is the standard Wiegand 34 protocol. This is fairly easy to decode on the Arduino, and I think that I can decode the 12+ channels at the same time, and then send the decoded data over the USB to the network interface. For various reasons, I'm going to use a Teensy++ as the main processor as it has lots of IO capability and is dirt cheap. This will be mounted on a custom PCB which has lots of terminal blocks to terminate the connections to the RFID readers. Since I am paranoid about lightning induced failures (I have been burnt by this a number of times), the RFID readers will be optically isolated from the Teensy. All the RFID readers will be connected to each other (at least the +5V and GND lines).

The code to read the Wiegand protocol has a timer interrupt that runs at 20kHz or so. This grabs all the relevant IO lines and records the current state, but latches low (the wiegand protocol is active low). Then the intrrupt handler processes a few readers and sees if a bit has been detected. The base level waits for a complete message to be received, validates the parity and then transmits it down the serial interface. It also handles timeouts and other failed reads.

RFID Reader

This is a small module from China. It will be mounted on a small PCB that has a couple of terminal blocks (one for the antenna and one for the wire back to the data acquisition unit). The PCB will also include an LED (to show when a tag is detected). There are a couple of options on these modules, and I will probably bring these out to jumpers.

The reader only returns 32 bits of the 40(?) bits of the tag number. However, it appears that the reader returns the least significant bits, and that a single order of tags comes from a limited range of ids. I don't forsee this as being a problem in real life.

RFID Antenna

The antenna to read the tags is a non-standard shape. My experimental antenna is about 3cm x 30cm. This will fit across the front of a nest box and the chicken will (hopefully) have to come within detection range to get into (or out of) the nest box. The spec of the RFID reader module is for a 650 µH coil. Finding a formula to convert turns into inductance was difficult as I couldn't find one that dealt with multi-layer coils. Anyway, 33 turns led to 440µH. This was too low, so I tried 53 turns which ended up at around 1020µH. At this point, I realized that the inductance is square law in the number of turns. 41 turns is around 670µH. However, only the original, 33 turn, coil would actually read the chicken leg rings. Even the stock coil (which was 630µH) would not read the chicken rings.

At this point, I wondered if the lower inductance was increasing the frequency (from the 125kHz) to maybe something closer to 132.5kHz, and maybe the rings were actually 132.5kHz. Anyway, a quick email to my Chinese supplier indicated that they really were 125kHz. I pulled out a monstrous HP frequency counter and measured the frequency -- it came in at 124.5kHz and it didn't depend on the coil. Thus it is a different effect that controls whether the chicken ring can be read.

I need to do more experiments with different numbers of turns to see what gives me the best read range.

Leg Rings

The first component is the leg ring that is worn by the chicken. These are surprisingly difficult to obtain. There are lots of people prepared to sell pigeon rings (I guess that these are for pigeon racing), but the larger size needed for chickens are hard to find. The nominal size for the 'hole' is 18mm. I have now found a supplier in China and have purchased an initial sample order of 5 rings. Preliminary testing indicates that they work.

Development Notes

I'm intending to design the two PCBs so that I can fit two copies of the RFID Module carrier and one copy of the data acquisition / Teensy++ carrier on a single 10cm x 10cm board. Seeed Studio can make 10 of this size board for very little.

I suspect that trying to integrate the network interface onto the data acquisition board is not worth the effort. I already have the GuruPlug running in the barn and this can easily grab the USB/Serial traffic, timestamp it, and then send it into the central logging system. It might also be possible to grab an image at the appropriate instant as well.

It seems that there are lots of cheap USB scales that could be used to measure the weight of a chicken. A square antenna would be used to measure when a chicken was standing on the scale, and then the current weight could be recorded. There are a bunch of issues around auto-zero, and how to deal with the cruft that will build up on top of the scale. It is also unclear how to keep the dust and wood chips out of the scale mechanism. It appears that the scale might be a cheap way to start. It appears that you can get the scale (and a bunch of other stuff) for $10 from

I'm also intending to support some dry contacts on the doors. This will allow logging of when somebody goes into the coop to collect eggs, provide food and/or water.

The Teensy++ board will also have a couple of relay closure outputs. These will be used to control the 'automatic' chicken door. This is the door from the outside into the coop, and is controlled by a linear actuator that I got off ebay. This actuator came from a hospital bed and is immensely powerful. It could easily crush a chicken flat, but, so far, their survival instincts have served them well! [An alternative, and possibly more likely, approach is to use another arduino-like device as a standalone control system. This does have a certain attraction....

Philip Gladstone