Chicken Nest Box RFID Tagging System

Hello everyone,
This is not a school project :slight_smile: , it is for my small family business that I would like some feedback on.

What it is:
A nest box that can track whether an individual hen laid an egg that day and identify which egg it is. The nest funnels the eggs into a tube so that each egg is associated with the hen who laid it based on its position in the tunnel (see pic).

Each hen wears a 125 kHz RFID leg band that passes over the reader antenna when she enters the nest box. An infrared break beam sensor at the entrance to the tunnel detects whether she laid an egg during her stay in the box. When data needs to be transmitted for egg collection, the tags of the hens who laid eggs will be transmitted to either a laptop or smartphone for viewing.

Goals:
A system with potentially up to 30 boxes (located in different areas of the farm), that can transmit the tag numbers of hens who laid that day to either A) a smartphone app or B) my laptop. From there I can 'translate' the long RFID tag into something readable.

Storing the data so that I can see how many eggs a given hen lays over a year would be nice also, but that can come later :grinning:

What I have now:
A prototype nest box that works to keep the eggs in order. The infrared break beam and RFID reader work as they should... however I am having a little bit of trouble deciding how to store the tags in non-volatile memory. The box can currently only transmit data through the Serial Monitor.

What I need feedback on:

  1. Should I use EEPROM or an external SD card to store the tags? The list of eggs should be stored in involatile memory to prevent data loss during a power outage.
  2. Options for transmitting data. To get this actually operational, transmission has to be wireless. I can't haul out my PC and connect to every nest box when I need to collect eggs.

So far I have thought about using

  • WiFi to a server in the cloud, but that sounds complicated to me. What do you all think?
  • Or use nRF24L01 wireless modules which seems like (?) might be simpler to implement. In that case, one Arduino acts as the root or 'master' to gather data from all of the nodes (other nest boxes). The distance between groups of nest boxes would be at maximum ~12 meters, which should be well within the range of the nRF24L01's. The master Arduino could then communicate the list of eggs via Bluetooth or WiFi to my laptop or (possibly) a smartphone.

These are just two ideas, please suggest others if you have better ones in mind.

EEPROM has a limited number of reads and writes and the size is fairly limited (though enough for storing tags each day). The SD card seems to be a bit more work and requires more pins but maybe I'm just reading into it. Some feedback on this would be nice too :slight_smile:

Attached is a photo of the current nest box prototype. Please tell me if you need any more info. Thank you!

WiFi sounds good for the short distance you have. I'd have the nesting boxes transmit the hen ID for any it sees and an egg laid packet if appropriate.

The server receiving this can be whatever you fancy. In normal times, I'd say use a Pi, but you may find it hard or expensive to source one at the moment. Beaglebone's another possibility or it may be worth building a minimal PC with Linux.

Push the data into MySql or MaiaDb or whatever and you can do whatever analytics you like.

1 Like

That is a Great idea, I bet there will be a lot of copies in the next few months. I am a bit on the lazy side, a while back I purchased a bunch of 32Kx8 FRAM modules for just a few dollars, the ones I use are I2C. They can be gotten in SPI if you want. They are way faster then EEPROM and do not have the associated delays or wear out time. They will last for over 10 to 14th cycles. They remember for years without power. There are several FRAM libraries, most work nicely. The easiest way for you would be to generate a block (structure) with all the info you want to save then simply write that structure to FRAM. I think you can save several thousand blocks of information. They have a write protect if you want to use it. You can build it so you can remove the FRAM module and replace it with another. Then take it to your office or wherever and read the data.

1 Like

Depending on the separation, I would like to use Esp modules communicating with esp-now protocol and master Esp at base hosting webpage to show results. Data stored in eeprom to avoid data loss in case of reboot.
If distance is long, I would use another inexpensive radio, like RFM69, or nRF24 with PA.
I guess you already figured it out :grinning:

1 Like

A lot of design details to figure out. How do you correlate the hen/egg? Do you just use the last RFID when an egg is detected? Do you care/detect when a hen leaves the box?

It seems you want to use a star system where one receiver collects data for the boxes. The number of boxes is more then nRF24 or ESP-NOW support in a star configuration, so you will need a couple of levels. Can multiple boxes be connected to one processor/transmitter?

You need to think about the data. You need the hen ID. How about box ID (particularly if multiple boxes use one controller). Maybe a timestamp?

If you store the data on the high level collector as it is collected you only need one nonvolatile device. I would suggest an SD card and store the data in .CSV format. This will make it easy to import into a data base.

For a data base I would suggest looking at SQLite for a start. It is easier to use and has enough function for a start. There are a bunch of free tools that support it.

1 Like

Thanks everyone for all the responses. I'll definitely be looking into these options.

The distance isn't far, maximum 12 meters. I like the idea of having a webpage to show results - @wildbill, what do you think of @JBBOP's idea of using another ESP (instead of a PI) as a master? I'll check into MySQL and MaiaDB, thanks for the recommendations.

Thanks! Any advantages over a regular SD card for my application?

Yes, the correlation of hen to egg is just the last tag that was read when an egg is detected. A hen can go in and out of a box many times before laying an egg, and this takes care of that too. It doesn't matter when a hen leaves the box so that isn't recorded.

That's an interesting point, I hadn't actually thought about using one transmitter for several boxes. My initial thought was to handle hen ID after transmission, an example ID would be BO-24 or CL-49. If I use ESP, the box ID would be the same as board ID. I'm not sure if it's possible to have several boxes use one controller, because how would eggs from separate boxes be differentiated? I think I would only be able to tell that within the group, a certain hen laid an egg. (But maybe there's a way I'm not seeing here).

A timestamp would be nice, maybe add an RTC? It's a feature I've thought about before.

Nice, that eliminates a lot of memory storage devices or work getting it into EEPROM. Thanks for the suggestion.

I'll check it out, thanks!

I have been thinking about the communication and have been looking at the nRF24L01 in network mode.

https://nrf24.github.io/RF24Network/

The diagram toward the bottom of the page shows the multilevel tree configuration that could support your 30 boxes with three levels. The level 1 nodes would handle their own box and forward the data from 5 level 2 leaf nodes. Since the data is flowing one way from the boxes to node 0 the code should be fairly simple.

I would not put a box on the level 0 node. Use it for the record formatting and data storage. Add a RTC to only the level 0 node to add a timestamp to the records if desired.

I haven't used the nRF24L01 in years and never tried the network configuration. I have dug out my box of half a dozen modules and will give it a try in the next couple of days.

1 Like

You could certainly use an ESP to store the data, especially if you add an SD card. It comes down to availability and personal choice in the end.

I would use a Pi because I already have some so it's a no-brainer for me, YMMV.

1 Like

Thanks, I really appreciate your time :slight_smile: That diagram is useful, and I'm wondering if something similar can be configured with the ESP's. Looks like there's a limit of 10 modules to connect at a time. Maybe I can use the nRF24L01's for communication then host the final results to a webpage using an ESP (since I like the idea of being able to access it that way).

I see, thanks for clarifying :slight_smile:

I set up a 3 level tree with one nRF24L0/Arduino at each level and it seems to work as advertised. I need to find some more Arduinos (I have a nano and a Redboard someplace) to fill the tree out a bit. I even used an old Duemilanove. I just used the simple transmit and receive examples. For the level 2 leaf node I just changed the example node address from 01 to 011 and added a line in the receive node to print the header from address to verify it was working.

It appears that you could use an ESP module as node 0. There is documentation on using the library with an ESP8266 or ESP32. It is mostly setting up the SPI interface. I'll take one of my ESP8266 modules and try it.

[EDIT]
Just tried an ESP8266 and it works fine as the base node. I used the standard SPI configuration and used D3 as the CE. Not sure if the NRF24L01 and WiFi would interfere with each other. I haven't tried a simultaneous WiFi connection - it is a bit more work.

Sorry if I am hijacking your thread - I find the problem interesting. It gives me a reason to play with some of the stuff I have laying around.

1 Like

Lots of interesting ideas. I may as well shake up things too.

I disagree on wireless. You have not (or I did not see) your solution to powering the laying stations with DC? Solar on the roof of every hen house?
As such, I would suggest a PoE solution; set-up it up as a node-to-node.
A PoE PSE provides a maximum of 15.4 watts of power at 48vDC. A PoE+ PSE provides a maximum of 30 watts of power at 48vDC. A Hi-PoE PSE provides a maximum of 100 watts of power. Four pair cable is required by the IEEE standards.

So the above is your power budget.... you only need one PoE node until you max out the power, then you must add another. Yes, you must run CAT6, but that is a whole lots better than trying to run AC mains or deal with separate DC for each hen-house.

As far as aggregating the data and creating the website, an old PC running Linux and NodeRED with a decent back-up power solution is all you need. NodeRED creates a webpage (you can route that securely to the Internet if you like) or you can integrate it with your home/farm Internet service.

NodeRED was used to easily create an Arduino project that I consulted on a few years back.
https://www.stm32duino.com/viewtopic.php?t=959

Good luck... I guess you could also use QR coding to inkjet all the info right onto the egg immediately. No network needed :joy:

Ray

Blockquote

1 Like

If an "old Duemilanove" has an ATmega328, then there is nothing at all "old" about it. Maybe update the bootloader.

There will be very rare situations where a UNO is in any way more appropriate. The Nano - a more practical form factor in the vast majority of situations - is functionally equivalent to the "old Duemilanove".

Not hijacking at all, I'm really appreciating your input.

I disagree on wireless. You have not (or I did not see) your solution to powering the laying stations with DC? Solar on the roof of every hen house?
As such, I would suggest a PoE solution; set-up it up as a node-to-node.
A PoE PSE provides a maximum of 15.4 watts of power at 48vDC. A PoE+ PSE provides a maximum of 30 watts of power at 48vDC. A Hi-PoE PSE provides a maximum of 100 watts of power. Four pair cable is required by the IEEE standards.

Yes, solar was the initial plan. You have an interesting proposition. My only concern would be that it limits flexibility when adding nest boxes. A wired solution would require adding another cable everytime I want new boxes and it would limit movability. But in hindsight, solar would require adding another panel so it presents some of the same difficulties.

Just checked into NodeRED. The graphics abilities and flow design is really quite interesting - so I may yet look into using Ethernet.

I have thought of this - but I still need something to process the tags into something readable. I don't think an Arduino should do it and I would rather have the option of storing it for long-term use (e.g., how many eggs the hen laid in a year). Certainly, in the future I don't want to be hand marking them, so it's still on the radar :grinning:

Thanks for your response, much appreciated.

Let's keep this on topic. Probably @oldcurmudegon was just referring to a board they've had for awhile.

That would be unusual in the forum context. :rofl:

1 Like

Study PoE topology:
PoE Cabling Architectures and Applications | FS Community

1 Like

Thanks, that's helpful :slight_smile: I will definitely research it more.

Wondered if you could spray a bar code on the eggs or some other form of marking??

Sometimes if can be useful to know what data you really need and what you will do with it - A specification if you like .
Often this points to a simpler solution rather than looking from the technology angle and what it can do .

1 Like

The Duemilanove is old in the sense it has a older boot loader so needs a different board selection. It is also missing some of the extra pins on later variants - the function is there but no special pins. For example SDA and SCL you have to use the analog pins. Also the on board LED is not buffered.

I wasn't thinking about the power until some of the more recent posts. I was thinking that with lighting and ventilation there would be line power by the nest boxes. If you have to run wires for power POE would be worth considering. It is lower voltage and can combine signaling in the same cable. A zone system would probably be best if the nest boxes are in groups. The only experience I have with POE is a wireless access point where I plugged it in and it "just works". The only thing was to get the upstream and downstream connections on the adapter right, the instructions were quite clear on that.

If you are considering solar it can be a major undertaking. After you figure out your power budget double or triple it. Not to say the sellers tell lies, but they can be wildly optimistic or have strange ways to interpret the specs. I think they test solar cell on the equator mounted on a cold plate (they are less efficient at higher temperatures). My favorite is the 100 watt (in large bold type) solar panel. In the fine print it is 6V at 1A - don't know where the 100W comes, maybe the output for the whole day? Check the battery discharge curves - the end point voltage may be below a usable value unless you have a boost/buck regulator. Why yes, I have been fighting a solar powered project the last couple of years.

A thought on data collection - if you go with POE you should consider using a PC for the base node and put the data directly in a data base. A refurbished PC and monitor in the $250-$300 range should be more than sufficient.

1 Like

Hi, I just recently builded an over-sized chicken-house for our family (my oldest son wanted to get more in touch with farming). We only have 10 hens and 8 nests. I use some house-automisation tools to detect eggs - with a much to complicated self-printed 3D mechanism, that only pushes a button, when an egg is "falling" into the tube.
So far so good - I do get about 1-10 E-mails per egg :wink: depending on the hen, how often she is runnung over the hole and pushes down the "spoon" which releaves the egg into the tube.

I couldn't find any rfid solution that I could get that would detect the tags far enough.
So if you could give me some info on which hardware you use on the rfid side - that would be great.

I wanted to track our hens with two readers on the "entrance tube" wether they are inside or outside the "house".

what I could give as input (some parts where allready mentioned):

I actually have some D1 mini in use which are flashed with espeasy which to transfer different data over WIFI to a raspberry which runs nodered and influxdb to store the data. This runs quite well and is fairly easy to setup - actually no programming required. Just "configuration" and the logic could be done in nodered which would prevent running around and reflashing to many arduinos.

I even thought about a "tracking" with rfid key to allow opening our tubes (which are outside the house) so a neighbour could grab his eggs by himself. As soon as I have time to clear the data a little bit, I want to make those files available for free :slight_smile: ... just found no done picture ... need to update this later.

best regards
Antonio

Very interesting, yes I definitely would like some pics! I'm assuming you have power run out to your coop?

I used a 125 kHz RFID reader purchased from AliExpress, the tags are 21 mm diameter 125 kHz RFID leg bands also purchased from Ali Express.

It reads quite effectively actually. Each hen wears the band on her right leg and the reader is antenna is slightly placed to the right so that they tend to step right on it when entering the nest box.

I think I need to go with a mechanical method of detecting eggs though - the IR break beam has proven unreliable...