The activity monitor was designed to fit in colony home-cages for long term monitoring of activity levels.
Using a passive infrared sensor and a datalogger to record activity patterns from rodent home cages
To make the experience fit your profile, pick a username and tell us what interests you.
We found and based on your interests.
The activity monitor was designed to fit in colony home-cages for long term monitoring of activity levels.
RAD_analysis.pyPython code to analyze RAD data.py - 49.75 kB - 06/29/2019 at 17:31 |
|
|
PIR Sample Data.zipSample data from four devices over multiple days.x-zip-compressed - 505.13 kB - 04/26/2019 at 18:08 |
|
|
PIRCounter-031119.zipMain code to run RADx-zip-compressed - 9.81 kB - 03/12/2019 at 04:53 |
|
|
RAD_libraries_031219.zipLibraries required for RADx-zip-compressed - 363.49 kB - 03/12/2019 at 16:19 |
|
|
AdaLoggerM0-SetClock.inoCode for setting the RTC on the Adalogger M0 boardino - 4.73 kB - 09/13/2018 at 12:01 |
|
Check out the newest iteration of this project!
https://hackaday.io/project/168588-rad2-research-activity-detector-version-2
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!
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?
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.
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.
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.
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.
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!
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.
Create an account to leave a comment. Already have an account? Log In.
Hi sorry I'm just seeing this now! Unfortunately my notifications on here don't always send an email when someone comments on a project. How is it going with these for you? Please feel free to email me too if you want a more immediate response or want to talk about these - we have a new wireless version going as well I can tell you about. You can find my email address online I'm at Wash U.
Hello! I am currently in the process of building this awesome device. I have everything put together, but when I run the code, I get an error message for the SD card. I have since checked the SD card with other code and it seems to be working fine. Any ideas on why this might be, or have any suggestions for a potential fix?
Hi John, I think I might know what's going on. Can you try downgrading the Adafruit SAMD Boards package to version 1.5.5? It seems like something changed in version 1.5.6 that creates a conflict with how we wrote the data logging code. I confirmed that versions including 1.5.5 and below work with the PIR code on Hackaday, while versions including 1.5.6 and above do not (Adafruit is on verison 1.6.1 currently). I'd like to figure out a solution but haven't had time to dig into it so in the meantime can you try downgrading the Adafruit SAMD boards to 1.5.5? To do so, go to the boards manager in the Arduino IDE, find the "Adafruit SAMD Boards" package and click on the "Select version" dropdown. Then choose 1.5.5 and install that and see if it works? Let me know!
Mr. Kravitz,
That worked! Thanks for the timely response. Can't wait to start collecting data.
Become a member to follow this project and never miss any updates
By using our website and services, you expressly agree to the placement of our performance, functionality, and advertising cookies. Learn More
Hello! Thank you so much for putting out this project. I'm currently making 30 of these for our circadian biology research at UC Berkeley. I do have a comment and a question: First, I don't know if this was just me or if it's a larger problem, but when I was uploading the main PIR sketch to my feather boards, I noticed that it didn't compile. I eventually found that when I changed <TimeLib.h> to just <Time.h>, the code compiled and worked well. I know there are a million real time clock libraries for Arduino, so maybe it just got switched around?
Secondly, I'm having a problem where some of the RADs spontaneously stop recording and send me back to the "Push A to start" screen. Is that something you ran into as well? I'm scared that I'll lose data if I'm not checking them all the time to restart them. I'm hoping to have these in cages for several weeks and I'd ideally like to get continuous data. Something to note is that we aren't using batteries for this project. We instead got microUSB cables and have them plugged into outlets with a 5V/1A output adapter.
Thank you for any suggestions you might have, and thanks again for the project!