element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Forget Me Not Design Challenge
  • Challenges & Projects
  • Design Challenges
  • Forget Me Not Design Challenge
  • More
  • Cancel
Forget Me Not Design Challenge
Blog [CaTS] ForgetMeNot - Week 9: RFID Cat detection and identification
  • Blog
  • Forum
  • Documents
  • Files
  • Events
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: fvan
  • Date Created: 27 Sep 2014 9:48 PM Date Created
  • Views 2256 views
  • Likes 1 like
  • Comments 10 comments
  • forget_me_not
  • design_challenge
  • openhab
  • tektronix
  • rpisoc
  • iot_pet_care
  • eclipse
  • internet_of_things
  • enocean
  • cats
  • raspberrypi
  • smarthome
  • challenge
  • iot
  • enocean_pi
Related
Recommended

[CaTS] ForgetMeNot - Week 9: RFID Cat detection and identification

fvan
fvan
27 Sep 2014

Previous posts for this project:

  • [CaTS] ForgetMeNot - Index
  • [CaTS] ForgetMeNot - Week 0: Project Description
  • [CaTS] ForgetMeNot - Week 1: EnOceanPi and Sensors
  • [CaTS] ForgetMeNot - Week 2: Elro CoCo and Pi Cam with OpenHAB
  • [CaTS] ForgetMeNot - Week 3: Data persistence and charts with OpenHAB
  • [CaTS] ForgetMeNot - Week 4: Arduino-OpenHAB communication
  • [CaTS] ForgetMeNot - Week 5: Getting familiar with EAGLE
  • [CaTS] ForgetMeNot - Week 6: Getting to know the TBS1052B-EDU oscilloscope
  • [CaTS] ForgetMeNot - Week 7: First tests with RPiSoC
  • [CaTS] ForgetMeNot - Week 7 (2): More testing with RPiSoC
  • [CaTS] ForgetMeNot - Week 8: Water dispenser and temperature
  • [CaTS] ForgetMeNot - 3D Printing: EnOcean sensor bracket
  • [CaTS] ForgetMeNot - 3D Printing: EnOcean rocker switch and magnet holder
  • [CaTS] ForgetMeNot - 3D Printing: Food dispenser prototype
  • [CaTS] ForgetMeNot - 3D Printing: Weighing scale
  • [CaTS] ForgetMeNot - Security: Some basic tips
  • [CaTS] ForgetMeNot - Minion: Dave, the gassy minion

 

  • Introduction
  • RFID
  • Arduino
  • Sketch
  • openHAB
  • Collars
  • Cover
  • Demo

 

Introduction

 

This week I've been working on detecting which cat eats or drinks and when. This can then be correlated with "how much".

 

To do this, I've used two SPI RFID readers which would read an RFID tag attached to the cat's collar. This post is about validating the idea by setting up the "cat detection" system and ensuring the data is available for correlation.

 

RFID

 

As stated in the introduction, I've decided to go with RFID tags attached to the cat's collar and an RFID reader placed in front of each bowl. The idea is that when the cat stands in front of a bowl to eat or drink, the tag is close enough to the reader in order to detect the cat's presence and identity.

 

I've used two simple RFID readers that work via SPI.

image

 

There are Arduino libraries available, which should make the development process easier image

 

Arduino

 

For this proof of concept, I've used an Arduino to test the idea of connecting two RFID readers and be able to detect two different cats at the same time.

I've used the library from Miguel Balboa and tested with a single RFID reader first, just to make sure the library works and it is capable of doing what I need.

imageimage

 

Using the example sketch, detection and reading the tags UID worked out of the box.

 

I then proceeded with a modified version of the example sketch to support two RFID readers, sharing all pins except the SS and RST pins.

I connected the second RFID reader, uploaded the new sketch and tried again.

imageimage

 

Success! Both RFID readers can report the detected tag and work simultaneously.

 

As I had done the exercise of passing serial data from Arduino to the Pi (and openHAB) earlier, I already had some knowledge on how to parse this data.

This is why I formatted the data of both RFID readers in a single string, with clear delimiters. This will make it easy to parse the string from openHAB.

 

In the example below, I tested different scenarios of presence, which seem to work properly:

image

 

Sketch

 

Below you'll find the sketch loaded on the Arduino. It checks for the presence of an RFID tag on both readers and returns the UID if present or "00000000" if not.

 

 

openHAB

 

Having tested the setup with the Arduino, I connected it to the Raspberry Pi via USB. Using minicom, I first verified the Arduino was correctly sending the data the to Pi.

image

 

With the data being received by the Pi, I configured openHAB to take in this data. To do this, I defined an item called "Arduino" which makes use of the serial binding.

I also created two additional items in order to display which cat is detected by which RFID reader.

 

String Arduino "Arduino [%s]" (arduino) {serial="/dev/ttyACM0"}
String Arduino_RFID1 "Currently eating [MAP(rfid.map):%s]"
String Arduino_RFID2 "Currently drinking [MAP(rfid.map):%s]"

 

 

A rule is used to parse the data received via the serial binding. As I put clear delimiters in the string, it was easy to parse the interesting bits of data. The parsed UIDs are then assigned to the proper items defined earlier.

 

rule "Arduino"
 when 
  Item Arduino received update
 then
      var String ArduinoUpdate = Arduino.state.toString.trim

      var int rfid1StartsOn = ArduinoUpdate.indexOf("-B1-RFID1:") + "-B1-RFID1:".length
      var String reading1 = ArduinoUpdate.mid(rfid1StartsOn, ArduinoUpdate.indexOf('-E1-')-rfid1StartsOn)

      var int rfid2StartsOn = ArduinoUpdate.indexOf("-B2-RFID2:") + "-B2-RFID2:".length
      var String reading2 = ArduinoUpdate.mid(rfid2StartsOn, ArduinoUpdate.indexOf('-E2-')-rfid2StartsOn)
      
      Arduino_RFID1.postUpdate(reading1)
      Arduino_RFID2.postUpdate(reading2)
end

 

 

I could convert the UIDs to meaningful names within the rule using "if" statements. I have however opted for the creation of a mapping file which will translate the UIDs to my cats' names. This approach is more simple, requires less code, and works just as well (I hope). Internally, the system will use the UIDs, but when exposing data, the names are used.

 

00000000=-
E3468DF4=Spot
737193F4=Tijger



Collars

 

I attached the marked RFID tags to the cats' collars and watched how they reacted to this.

image

 

One of the cats' first reaction was to try to eat the tag ... after some failed attempts at eating it, the cat seemed OK with the tag hanging there. The other cat was less impressed, but accepted the tag as well.

imageimage

 

So now you have finally seen my two test subjects: the striped cat, "Tijger", and the black cat, "Spot". At the end of this challenge, they will be the (lucky ?) owners of a fully automated [CaTS] prototype

 

Cover

 

I needed a way to attach the RFID readers properly, so I've made covers to be able to mount and protect them. It has an opening to connect the wires and four mounting holes.

imageimage

 

Demo

 

To demonstrate the functionality, I could have waved the RFID tags manually in front of the readers and show the result in openHAB. As the final solution is meant to work with cats, I set up a small rig and lured one of the cats with some cold milk.

imageimage

 

Cats are not actors, they have a will of their own and can't be told what to do. I have however managed to catch one of them on film, demonstrating the system.

 

This is the footage:

 

You don't have permission to edit metadata of this video.
Edit media
x
image
Upload Preview
image

 

The video demonstrates the mechanism works. It does however require some fine tuning with regards to the positioning of the RFID reader, but I'm satisfied with the result!

 

 

I'll be travelling to Rome this week, to attend Maker Faire (is anyone else going ?). This means my next post might be slightly delayed ...

  • Sign in to reply

Top Comments

  • shabaz
    shabaz over 10 years ago +1
    Hi Frederick, This is great! From the footage, your RFID method is a very effective cat activity detection system : ) I originally thought you'd maybe need some video analysis method to achieve this, but…
  • DAB
    DAB over 10 years ago +1
    Hi Frederick, Great post. Also a cool use for RFID tags. Well Done, DAB
  • mcb1
    mcb1 over 10 years ago in reply to fvan +1
    Well done. RFID works by the receiver (Tag) detuning the Transmitter (Reader) antenna. Basically the Tag shorts its antenna, which is tuned to the 125KHz/134KHz/13.5MHz frequency, and thereby loads the…
  • clem57
    clem57 over 9 years ago in reply to Former Member

    No, because the RESET pin has a defined meaning to the Arduino hardware to execute a hardware reset function. Other ways are Arduino Software Reset - CodeProject

    Clem

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • Former Member
    Former Member over 9 years ago

    Frederick, is there a way to use the RESET pin also as a common pin?

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • Former Member
    Former Member over 9 years ago

    Thanks you so much Frederick for this image

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • mcb1
    mcb1 over 10 years ago in reply to fvan

    Sheet ferrite would seem to be an obvious choice to shield it,(in the same way as the Wurth coils were shielded)

    Otherwise if you can maximise the distance and increase the angle so that both aren't in the same plane, it will also help a little.

     

    At least your method is easier than trying to read the 134 KHz microtag they put between their shoulders.

    image

    Mark

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • fvan
    fvan over 10 years ago in reply to mcb1

    Thanks for the advice Mark, I was indeed considering the build to help position the tag properly. We'll see how that goes.

     

    As for the metals bowls: I wanted to opt for at least one metal bowl as I wanted to cool the water. By attaching the cold side of a small peltier to the bowl, the bowl would serve as heatsink and help spread the cold. The second metal bowl was just for symmetry image Perhaps the bowls can somehow be shielded to avoid interference ?

     

    Frederick

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
>
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube