Heart Rate Monitor Arduino
Hello Tech Freaks, I'm back with another interesting but very simple DIY project for you all, based on Arduino. Today we're going to make a Heart Rate Monitor using Arduino and Pulse sensor. These two are the main components which are required mainly also these can be easily found in any local electronics shop or on online platform. Links for all sensors will be provided.
I hope most of you might be aware of the basic working of the heart rate sensors, but for the beginner, let me brief it. So Pulse sensor works on the principal of photoplethysmography to measure the heart rate of someone. I hope you might be unfamiliar with that long and hard word. There are two types of the sensor available in the market, Reflected and Transmission. The one we're going to use is the reflectance one.
As we all know that there are millions of microscopic blood vessels running under our skin so in simple words the sensor emits light mainly red or green and IR. Which is then passed through our skin and get reflected by the blood flowing through those microscopic blood vessels. Hence, this creates the deflection in the value of light received by the photodetector of the sensor. Using this value we calculate all the required data we want.
For more information about all other devices used in this project, visit its original post and bookmark the website for early access to all other interesting articles like this.
Material Required
- Pulse Rate sensor module
- Arduino Nano
- Zero PCB
- OLED 128X64
- Berg Strips
Circuit Diagram
Code
#include #define OLED_Address 0x3C Adafruit_SSD1306 oled(1); int x=0; int lastx=0; int lasty=0; int LastTime=0; int ThisTime; bool BPMTiming=false; bool BeatComplete=false; int BPM=0; #define UpperThreshold 560 #define LowerThreshold 500 void setup() { oled.begin(SSD1306_SWITCHCAPVCC, OLED_Address); oled.clearDisplay(); oled.setTextSize(2); }void loop() { if(x>127) { oled.clearDisplay(); x=0; lastx=x; } ThisTime=millis(); int value=analogRead(0); oled.setTextColor(WHITE); int y=60-(value/16); oled.writeLine(lastx,lasty,x,y,WHITE); lasty=y; lastx=x; // calc bpm if(value>UpperThreshold) { if(BeatComplete) { BPM=ThisTime-LastTime; BPM=int(60/(float(BPM)/1000)); BPMTiming=false; BeatComplete=false; tone(8,1000,250); } if(BPMTiming==false) { LastTime=millis(); BPMTiming=true; } } if((value<LowerThreshold)&(BPMTiming)) BeatComplete=true; oled.writeFillRect(0,50,128,16,BLACK); oled.setCursor(0,50); oled.print(BPM); oled.print(” BPM”); oled.display(); x++; }For explanation about how the code works visit its original post also for any troubleshooting comments down below either here or there.