Close
0%
0%

RAD (Rodent Activity Detector)

Using a passive infrared sensor and a datalogger to record activity patterns from rodent home cages

Public Chat
Similar projects worth following
Goal: Our lab performs studies on obesity and physical activity. We wanted a simple way to monitor home-cage activity in real-time in dozens of rodent home cages.

Approach: We designed a simple device that utilizes a passive infrared (PIR) sensor to detect movement in the cages and logs the data to a microSD card. The device is wireless and battery powered, and can record data for about 3 weeks on a charge.

This project is released under the terms of the Creative Commons - Attribution - ShareAlike 3.0 license: human readable: https://creativecommons.org/licenses/by-sa/3.0/ legal wording: https://creativecommons.org/licenses/by-sa/3.0/legalcode

The activity monitor was designed to fit in colony home-cages for long term monitoring of activity levels.

RAD_analysis.py

Python code to analyze RAD data.

py - 49.75 kB - 06/29/2019 at 17:31

Download

PIR Sample Data.zip

Sample data from four devices over multiple days.

x-zip-compressed - 505.13 kB - 04/26/2019 at 18:08

Download

PIRCounter-031119.zip

Main code to run RAD

x-zip-compressed - 9.81 kB - 03/12/2019 at 04:53

Download

RAD_libraries_031219.zip

Libraries required for RAD

x-zip-compressed - 363.49 kB - 03/12/2019 at 16:19

Download

AdaLoggerM0-SetClock.ino

Code for setting the RTC on the Adalogger M0 board

ino - 4.73 kB - 09/13/2018 at 12:01

Download

View all 6 files

View all 7 components

  • Glamour shots!

    Lex Kravitz12/20/2018 at 22:35 0 comments

    We just submitted this project for publication in a research journal, and as part of the figures took some nicer photos.  Thought I'd share them!

  • Monitoring pets!

    Lex Kravitz10/09/2018 at 01:49 0 comments

    This device can be used for many things beyond mouse cages.  My wife and I have two parakeets, so I zip-tied a PIR device near their feeder and found that they eat almost exclusively during the day.  (I already kind of knew that but it's neat to see the data!)

    Update 10/09/18:

    3 weeks of data on one charge!  The variance in daily feeding early on was the result of us putting a different food source (a "treat stick") in the cage on 9/23.  Still, there is a lot of daily variance in activity near the feeder, maybe some days they're hungrier than others?

  • Battery life and power consumption

    Lex Kravitz09/17/2018 at 02:33 0 comments

    The battery we chose for this project is a large 6600mAh battery sold by Adafruit.  We measured the power consumption of the entire device to be ~15mA, so it should last 440 hours, or about 18 days on a full charge.  Below is a discharging curve from a device in a cage with a mouse, showing that it lasted 14 days from fully charged (this is close enough to 18 days to satisfy me that our calculations were correct).

    A 2 week battery life is acceptable for many applications, but is not ideal.  On the bright side, we achieved this battery life with no sleep modes activated on the processor.  We have been experimenting with sleep modes and believe we can extend the battery life by ~5x with updates to the code, but we don't have that ready to release just yet.  

    However, searching online, a PIR based motion detector should be able to last MUCH longer - Texas Instruments has a reference design that they claim can last for 10 years on a coin cell battery.  In future iterations of this device we may move to a design like that.

  • Validating the PIR sensor for detecting movement inside of a mouse cage

    Lex Kravitz09/09/2018 at 17:11 0 comments

    We used a low--power PIR sensor to detect animal movement.  This sensor returns nice looking data when mounted in a mouse cage, for example we can see a nice circadian rhythm in daily activity.  See 1 month of activity data here - note the cyclical rhythm that shows more activity each night, and less during the daytime (mice are nocturnal):

    While this data showed us that the PIR was detecting biological variance in activity, we wanted to calibrate what exactly was being detected by the sensor. We set up an experiment where we put the PIR next to a video camera, and recorded 4 mice this way for 24 hours.  We then ran the video through a commercial motion tracking software (Noldus Ethovision) to understand what the sensor was correlated with.  

    We evaluated the data in 1 second, 10 second, 30 second, and 5-minute bins, and learned that the PIR correlated extremely well with total distance moved (as assayed by video analysis) at long bin widths, but not so much at the 1 second bin width.  Our conclusion is that the PIR is very useful for measuring gross changes in movement, such as those that occur across minutes, but is not so great at returning second-by-second changes in movement.  This is fine for our purposes, and good to know.

    We then used a machine learning classifier (also part of Ethovision) to classify movement into Walking, Resting, Grooming, Rearing, Sniffing, and Digging.  At a 10 second bin width, the time identified as "Walking" correlated well with how long the PIR was on (R2=0.61), while all other R2 were below 0.2. This indicates that the PIR captures locomotion from place to place, but not "in place" actions such as grooming and digging.  

    To more explicitly test this idea, we bought a small robot from Adafruit and programmed it to move back and forth at a constant speed (~6inches/sec), but make movements of different lengths between 0.1 and 1.0 inches.  We mounted an IR LED on top of the robot to make sure it activated the PIR sensor.

    With this test, we confirmed that only movements that displaced the robot >0.3inches triggered the PIR.  Small vigorous movements in place did not.  This test was consistent with our results from video analysis of mice, in which locomotion triggered the sensor, grooming did not.


  • Sample validation data

    Lex Kravitz09/09/2018 at 16:59 0 comments

    Here is sample data from 4 mouse cages for 24 hours.  Cage 1 had no mouse, while 2, 3, and 4 had mice.  Note circadian rhythm.  CSV file and more data coming soon!

  • First build and testing!

    Lex Kravitz09/09/2018 at 15:54 0 comments

    We designed and built this project fairly quickly (~1 month).  There are a few areas for improvement but we are already collecting cool data with it.  Here are some photos of the finished build, we will post more info and validation data soon.

View all 6 project logs

  • 1
    Download Arduino IDE

    Before starting with building anything you should make sure your computer can communicate with the Adalogger M0 board and that you can flash sketches to it.  This should reduce frustration later.  Start by installing the Arduino IDE.

  • 2
    Install relevant Arduino boards to run the Adalogger M0

    The Adafruit M0 Adalogger board is not natively supported by the Arduino IDE.  Follow instructions here to install support for this board in the Arduino IDE.  After completing these steps make sure you can flash the example sketch "Blink" to the Adalogger board before continuing.  To do this, open the Blink example in File>Examples>Basic>Blink.  

    "Double-click" the small physical button on the Adalogger board to put it in bootloader mode, set Board to "Adafruit Feather M0" and port to the correct COM port and click upload (the right arrow at the top of the Arduino IDE). You should see "Upload complete" in the bottom feedback window and the red LED on the board should blink once per second.  

    Congratulations, you have configured your Arduino IDE and uploaded a sketch to the Adalogger!

  • 3
    Install relevant libraries

    The PIR device requires the following libraries:

    #include <Adafruit_SSD1306.h>
    #include <Wire.h>
    #include <RTCZero.h>
    #include <SPI.h>
    #include <SdFat.h>
    #include <Adafruit_GFX.h>

    These are available for download as a single zip file from the files area, or you can search for them online.  When you're done they should all be in your libraries directory, see example:

    If this doesn't work, or you'd prefer a different way go through instructions here for how to manually add libraries.

View all 15 instructions

Enjoy this project?

Share

Discussions

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates