For a while now I have seen biometric tools that measure heartbeats in order to give an indication of an emotive state. Not only has biometrics been taken up in businesses to measure happiness and engagement at work but more recently they have been embedded into pet collars to help owners track their pet’s health and emotions often through an app.
While I have blogged before about biometrics and emotions, I decided to have a go at building a biometric device for dogs myself, to explore this further.
Looking online there are a few costly pre-built dog heart rate monitors, often through collars, such as PetPace collar ($149.95), Voyce collar ($199.99) and Alivecor Vet a phone snap-on ($199.99). But how do these work?
Alivecor Vet works by having two metal strips (see below) which act as electrodes to measure the electric current in the heart over a period of time called electrocardiography (ECG).
In order for this to work you have to have skin contact, hence why AliveCor recommends using alcohol to allow the electric current bypass the issue of the pet’s fur. PetPace and Voyce do not advertise how they measure heartbeat but due to the fact that it is on the neck it must measure heartbeat through light. Technology, such as the apple watch and other devices worn on the wrist (or dogs neck), shine light into your skin to detect the difference in volume in blood that occurs when your heart beats and pushes blood through these vessels. Sensors on the device can detect how much light is reflected back which is less when there is a higher volume of blood. This way of measuring heartbeat is called photoplethysmography. To combat the fur getting in the way PetPace has sticking out probes to get close enough to the skin so that the light can reach the skin: ochie!
In the device I wanted to make I did not want it to be uncomfatable to dogs through probes worn on the neck like PetPace and Voyce, or alcohol gel like AliveCor. Therefore I chose to do it via photoplethysmography and through an area on the dog that does not have much (or much fur!): the ear.
As I wanted a low priced solution I chose to build the device through Arduino (Genuino Uno) board which cost approximately £14.40 (€20).
Arduino is an open source microcontroller that is programmable through Arduino Software (IUD). The photoplethysmography device I chose a Grove Ear Clip Sensor with receiver module from SeedStudio (cost around £10/€13.40). To pair these devices together I used standard Arduino wires: 10mm male jump wires. To ensure more accuracy I ran the Arduino board off a 9v battery connected via a battery connector (snap connector).
The software I decided to use was also from SeedStudo written by FrankieChu (shown below). Unlike the code shown I did not use the base shield and instead wired it straight into the board. Authough the code allows for it, I also did not use LEDs & Breadboard to create a flashing LED representing heart rate. Instead I used the Serial Monitor (available under tools) to create an average heart rate per every 20 beats taken.
How does this all work? This project works by measuring each heartbeat through photoplethysmography (as described above) and then creating a signal interruption when the blood volume is at its fullest. The IUD then times these interruptions (beats) to create an average interruption per minute. If using the LED, these interruptions also cause Arduino to change the state from LOW to HIGH causing a pulse flash.
Now to test it. I initially used it on the edge of my dog’s ears in a similar fashion to my own when building the monitor. However due to the furriness of the edge of my dog’s ear the light could not penetrate through this with the monitor restarting itself due to lack of signal. To combat this I then clipped the ear monitor to the middle by folding over his ear where there was no fur.
(Disclaimer: This did not hurt him and the ear clip is not tight (I tried it myself). He actually fell asleep while I was doing this ).
In the serial monitor this produced both the interruptions times (in milliseconds), total time (ms), beat number (out of 20) and average heartbeat; for my Dog his heart rate was 63.
So you can measure in ears, now what? Once it was established you are able to take a dogs heart beat through their ears, I realized this method was not viable to be used in ordinary circumstances as the dogs ear was not in a normal position. I then tried other places on a dog’s body, including the inside of his leg which has not only high concentrations of veins but also is not very furry. I was able to get readings here, but they were not as reliable as the inside of the ear. This was because the average number of beats had greater variations; the rate would jump from 60 to in the 100s within 20 beats. A dog’s heart rate usually varies from 60 to 140 bmp (as you can tell from the above heartbeat (a low 63) he was sleeping). The variation was suspect due to the dog moving his leg causing interruptions altering the average time between the interruptions which are how the heartbeat is calculated.
So what have we learned? I have found out it is possible to measure a dogs heartbeat through a cheap photoplethysmography device built using Arduino (approx £25 spent). However this is not possible in ordinary movement due to the dense fur usually found on a dog preventing photoplenthysmographies light transmission. Without shaving the dog, which we do not want to do, or constantly folding the dog’s ear over, which would be uncomfortable whilst standing due to the ear naturally flopping down in this breed, I am unsure how you would measure heartbeat. This is perhaps why current technology requires prongs into the dog or alcoholic gel.
Further work from this? With the current technology not supporting ECG or photoplethysmography, the alternative option could be though breathing monitoring which is directly linked to heart rate. As some dogs wear a dog harness already, a monitoring device could be put into place in a similar fashion and measure the breath rate. However in dogs with one of their primary senses being smell, this could cause interruptive data, or smell data? We shall have to see!
EXTRA DETAILS INCLUDING IDU CODE, ITEM LIST & FRITZING SKETCH
Arduino Code Used – Originally coded by Frankie Chu found on Seed Studio
// Function: This program can be used to measure heart rate, the lowest pulse in the program be set to 30. // Use an external interrupt to measure it. // Hardware: Grove - Ear-clip Heart Rate Sensor, Grove - Base Shield, Grove - LED // Arduino IDE: Arduino-1.0 // Author: FrankieChu // Date: Jan 22, 2013 // Version: v1.0 // by www.seeedstudio.com #define LED 4//indicator, Grove - LED is connected with D4 of Arduino boolean led_state = LOW;//state of LED, each time an external interrupt //will change the state of LED unsigned char counter; unsigned long temp[21]; unsigned long sub; bool data_effect=true; unsigned int heart_rate;//the measurement result of heart rate const int max_heartpluse_duty = 2000;//you can change it follow your system's request. //2000 meams 2 seconds. System return error //if the duty overtrip 2 second. void setup() { pinMode(LED, OUTPUT); Serial.begin(9600); Serial.println("Please ready your chest belt."); delay(5000); arrayInit(); Serial.println("Heart rate test begin."); attachInterrupt(0, interrupt, RISING);//set interrupt 0,digital port 2 } void loop() { digitalWrite(LED, led_state);//Update the state of the indicator } /*Function: calculate the heart rate*/ void sum() { if(data_effect) { heart_rate=1200000/(temp[20]-temp[0]);//60*20*1000/20_total_time Serial.print("Heart_rate_is:\t"); Serial.println(heart_rate); } data_effect=1;//sign bit } /*Function: Interrupt service routine.Get the sigal from the external interrupt*/ void interrupt() { temp[counter]=millis(); Serial.println(counter,DEC); Serial.println(temp[counter]); switch(counter) { case 0: sub=temp[counter]-temp[20]; Serial.println(sub); break; default: sub=temp[counter]-temp[counter-1]; Serial.println(sub); break; } if(sub>max_heartpluse_duty)//set 2 seconds as max heart pluse duty { data_effect=0;//sign bit counter=0; Serial.println("Heart rate measure error,test will restart!" ); arrayInit(); } if (counter==20&&data_effect) { counter=0; sum(); } else if(counter!=20&&data_effect) counter++; else { counter=0; data_effect=1; } } /*Function: Initialization for the array(temp)*/ void arrayInit() { for(unsigned char i=0;i < 20;i ++) { temp[i]=0; } temp[20]=millis(); }
Items used
- Arduino Uno Board
- Jumper Wires (x3)
- Grove Ear Heart Rate Sensor
- Grove Ear Clip
- Grove Receiver Module