Project Description
Heart Rate Monitors are very popular at the moment.
There is something very appealing about watching the pattern of your own heart beat. And once you see it, there is an unstoppable urge to try and control it. This simple project will allow you to visualize your heart beat, and will calculate your heart rate. Keep reading to learn how to create your very own heart rate monitor.
Parts Required:
- Arduino UNO or compatible board
- Grove Base Shield
- Grove Ear-clip Heart Rate Sensor
- Grove Universal 4 pin cables
- LED and 330 ohm resistor
Fritzing Sketch
Grove Base Shield to Module Connections
Arduino Sketch
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
/* ================================================================================================= Project: Arduino Heart rate monitor Author: Scott C Created: 21st April 2015 Arduino IDE: 1.6.2 Website: http://arduinobasics.blogspot.com/p/arduino-basics-projects-page.html Description: This is a simple sketch that uses a Grove Ear-clip Heart Rate sensor attached to an Arduino UNO, which sends heart rate data to the computer via Serial communication. You can see the raw data using the Serial monitor on the Arduino IDE, however, this sketch was specifically designed to interface with the matching Processing sketch for a much nicer graphical display. NO LIBRARIES REQUIRED. =================================================================================================== */ #define Heart 2 //Attach the Grove Ear-clip sensor to digital pin 2. #define LED 4 //Attach an LED to digital pin 4 boolean beat = false; /* This "beat" variable is used to control the timing of the Serial communication so that data is only sent when there is a "change" in digital readings. */ //==SETUP========================================================================================== void setup() { Serial.begin(9600); //Initialise serial communication pinMode(Heart, INPUT); //Set digital pin 2 (heart rate sensor pin) as an INPUT pinMode(LED, OUTPUT); //Set digital pin 4 (LED) to an OUTPUT } //==LOOP============================================================================================ void loop() { if(digitalRead(Heart)>0){ //The heart rate sensor will trigger HIGH when there is a heart beat if(!beat){ //Only send data when it first discovers a heart beat - otherwise it will send a high value multiple times beat=true; //By changing the beat variable to true, it stops further transmissions of the high signal digitalWrite(LED, HIGH); //Turn the LED on Serial.println(1023); //Send the high value to the computer via Serial communication. } } else { //If the reading is LOW, if(beat){ //and if this has just changed from HIGH to LOW (first low reading) beat=false; //change the beat variable to false (to stop multiple transmissions) digitalWrite(LED, LOW); //Turn the LED off. Serial.println(0); //then send a low value to the computer via Serial communication. } } } |
Processing Sketch
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 |
/* ================================================================================================= Project: Arduino Heart rate monitor Author: Scott C Created: 21st April 2015 Processing IDE: 2.2.1 Website: http://arduinobasics.blogspot.com/p/arduino-basics-projects-page.html Description: A Grove Ear-clip heart rate sensor allows an Arduino UNO to sense your pulse. The data obtained by the Arduino can then be sent to the computer via Serial communication which is then displayed graphically using this Processing sketch. =================================================================================================== */ import processing.serial.*; // Import the serial library to allow Serial communication with the Arduino int numOfRecs = 45; // numOfRecs: The number of rectangles to display across the screen Rectangle[] myRecs = new Rectangle[numOfRecs]; // myRecs[]: Is the array of Rectangles. Rectangle is a custom class (programmed within this sketch) Serial myPort; String comPortString="0"; //comPortString: Is used to hold the string received from the Arduino float arduinoValue = 0; //arduinoValue: Is the float variable converted from comPortString boolean beat = false; // beat: Used to control for multiple high/low signals coming from the Arduino int totalTime = 0; // totalTime: Is the variable used to identify the total time between beats int lastTime = 0; // lastTime: Is the variable used to remember when the last beat took place int beatCounter = 0; // beatCounter: Is used to keep track of the number of beats (in order to calculate the average BPM) int totalBeats = 10; // totalBeats: Tells the computer that we want to calculate the average BPM using 10 beats. int[] BPM = new int[totalBeats]; // BPM[]: Is the Beat Per Minute (BPM) array - to hold 10 BPM calculations int sumBPM = 0; // sumBPM: Is used to sum the BPM[] array values, and is then used to calculate the average BPM. int avgBPM = 0; // avgBPM: Is the variable used to hold the average BPM calculated value. PFont f, f2; // f & f2 : Are font related variables. Used to store font properties. //==SETUP============================================================================================== void setup(){ size(displayWidth,displayHeight); // Set the size of the display to match the monitor width and height smooth(); // Draw all shapes with smooth edges. f = createFont("Arial",24); // Initialise the "f" font variable - used for the "calibrating" text displayed at the beginning f2 = createFont("Arial",96); // Initialise the "f2" font variable - used for the avgBPM display on screen for(int i=0; i<numOfRecs; i++){ // Initialise the array of rectangles myRecs[i] = new Rectangle(i, numOfRecs); } for(int i=0; i<totalBeats; i++){ // Initialise the BPM array BPM[i] = 0; } myPort = new Serial(this, Serial.list()[0], 9600); // Start Serial communication with the Arduino using a baud rate of 9600 myPort.bufferUntil('\n'); // Trigger a SerialEvent on new line } //==DRAW============================================================================================== void draw(){ background(0); // Set the background to BLACK (this clears the screen each time) drawRecs(); // Method call to draw the rectangles on the screen drawBPM(); // Method call to draw the avgBPM value to the top right of the screen } //==drawRecs========================================================================================== void drawRecs(){ // This custom method will draw the rectangles on the screen myRecs[0].setSize(arduinoValue); // Set the first rectangle to match arduinoValue; any positive value will start the animation. for(int i=numOfRecs-1; i>0; i--){ // The loop counts backwards for coding efficiency - and is used to draw all of the rectangles to screen myRecs[i].setMult(i); // setMulti creates the specific curve pattern. myRecs[i].setRed(avgBPM); // The rectangles become more "Red" with higher avgBPM values myRecs[i].setSize(myRecs[i-1].getH()); // The current rectangle size is determined by the height of the rectangle immediately to it's left fill(myRecs[i].getR(),myRecs[i].getG(), myRecs[i].getB()); // Set the colour of this rectangle rect(myRecs[i].getX(), myRecs[i].getY(), myRecs[i].getW(), myRecs[i].getH()); // Draw this rectangle } } //==drawBPM=========================================================================================== void drawBPM(){ // This custom method is used to calculate the avgBPM and draw it to screen. sumBPM = 0; // Reset the sumBPM variable avgBPM = 0; // Reset the avgBPM variable boolean calibrating = false; // calibrating: this boolean variable is used to control when the avgBPM is displayed to screen for(int i=1; i<totalBeats; i++){ sumBPM = sumBPM + BPM[i-1]; // Sum all of the BPM values in the BPM array. if(BPM[i-1]<1){ // If any BPM values are equal to 0, then set the calibrating variable to true. calibrating = true; // This will be used later to display "calibrating" on the screen. } } avgBPM = sumBPM/(totalBeats-1); // Calculate the average BPM from all BPM values fill(255); // The text will be displayed as WHITE text if(calibrating){ textFont(f); text("Calibrating", (4*width)/5, (height/5)); // If the calibrating variable is TRUE, then display the word "Calibrating" on screen fill(0); // Change the fill and stroke to black (0) so that other text is "hidden" while calibrating variable is TRUE stroke(0); } else { textFont(f2); text(avgBPM, (4*width)/5, (height/5)); // If the calibrating variable is FALSE, then display the avgBPM variable on screen stroke(255); // Change the stroke to white (255) to show the white line underlying the word BPM. } textFont(f); text("BPM", (82*width)/100, (height/11)); // This will display the underlined word "BPM" when calibrating variable is FALSE. line((80*width)/100, (height/10),(88*width)/100, (height/10)); stroke(0); } //==serialEvent=========================================================================================== void serialEvent(Serial cPort){ // This will be triggered every time a "new line" of data is received from the Arduino comPortString = cPort.readStringUntil('\n'); // Read this data into the comPortString variable. if(comPortString != null) { // If the comPortString variable is not NULL then comPortString=trim(comPortString); // trim any white space around the text. int i = int(map(Integer.parseInt(comPortString),1,1023,1,height)); // convert the string to an integer, and map the value so that the rectangle will fit within the screen. arduinoValue = float(i); // Convert the integer into a float value. if (!beat){ if(arduinoValue>0){ // When a beat is detected, the "trigger" method is called. trigger(millis()); // millis() creates a timeStamp of when the beat occured. beat=true; // The beat variable is changed to TRUE to register that a beat has been detected. } } if (arduinoValue<1){ // When the Arduino value returns back to zero, we will need to change the beat status to FALSE. beat = false; } } } //==trigger=========================================================================================== void trigger(int time){ // This method is used to calculate the Beats per Minute (BPM) and to store the last 10 BPMs into the BPM[] array. totalTime = time - lastTime; // totalTime = the current beat time minus the last time there was a beat. lastTime = time; // Set the lastTime variable to the current "time" for the next round of calculations. BPM[beatCounter] = 60000/totalTime; // Calculate BPM from the totalTime. 60000 = 1 minute. beatCounter++; // Increment the beatCounter if (beatCounter>totalBeats-1){ // Reset the beatCounter when the total number of BPMs have been stored into the BPM[] array. beatCounter=0; // This allows us to keep the last 10 BPM calculations at all times. } } //==sketchFullScreen========================================================================================== boolean sketchFullScreen() { // This puts Processing into Full Screen Mode return true; } //==Rectangle CLASS==================================================================================********* class Rectangle{ float xPos, defaultY, yPos, myWidth, myHeight, myMultiplier; // Variables used for drawing rectangles int blueVal, greenVal, redVal; // Variables used for the rectangle colour Rectangle(int recNum, int nRecs){ // The rectangles are constructed using two variables. The total number of rectangles to be displayed, and the identification of this rectangle (recNum) myWidth = displayWidth/nRecs; // The width of the rectangle is determined by the screen width and the total number of rectangles. xPos = recNum * myWidth; // The x Position of this rectangle is determined by the width of the rectangles (all same) and the rectangle identifier. defaultY=displayHeight/2; // The default Y position of the rectangle is half way down the screen. yPos = defaultY; // yPos is used to adjust the position of the rectangle as the size changes. myHeight = 1; // The height of the rectangle starts at 1 pixel myMultiplier = 1; // The myMultiplier variable will be used to create the funnel shaped path for the rectangles. redVal = 0; // The red Value starts off being 0 - but changes with avgBPM. Higher avgBPM means higher redVal if (recNum>0){ // The blue Value progressively increases with every rectangle (moving to the right of the screen) blueVal = (recNum*255)/nRecs; } else { blueVal = 0; } greenVal = 255-blueVal; // Initially, the green value is at the opposite end of the spectrum to the blue value. } void setSize(float newSize){ // This is used to set the new size of each rectangle myHeight=newSize*myMultiplier; yPos=defaultY-(newSize/2); } void setMult(int i){ // The multiplier is a function of COS, which means that it varies from 1 to 0. myMultiplier = cos(radians(i)); // You can try other functions to experience different effects. } void setRed(int r){ redVal = int(constrain(map(float(r), 60, 100, 0, 255),0,255)); // setRed is used to change the redValue based on the "normal" value for resting BPM (60-100). greenVal = 255 - redVal; // When the avgBPM > 100, redVal will equal 255, and the greenVal will equal 0. } // When the avgBPM < 60, redVal will equal 0, and greenVal will equal 255. float getX(){ // get the x Position of the rectangle return xPos; } float getY(){ // get the y Position of the rectangle return yPos; } float getW(){ // get the width of the rectangle return myWidth; } float getH(){ // get the height of the rectangle return myHeight; } float getM(){ // get the Multiplier of the rectangle return myMultiplier; } int getB(){ // get the "blue" component of the rectangle colour return blueVal; } int getR(){ // get the "red" component of the rectangle colour return redVal; } int getG(){ // get the "green" component of the rectangle colour return greenVal; } } |
Processing Code Discussion:
The Rectangle class was created to store relevant information about each rectangle. By using a custom class, we were able to design our rectangles any way we wanted. These rectangles have properties and methods which allow us to easily control their position, size and colour. By adding some smart functionality to each rectangle, we were able to get the rectangle to automatically position and colour itself based on key values.
The Serial library is used to allow communication with the Arduino. In this Processing sketch, the values obtained from the Arduino were converted to floats to allow easy calulations of the beats per minute (BPM). I am aware that I have over-engineered the serialEvent method somewhat, because the Arduino is only really sending two values. I didn't really need to convert the String. But I am happy with the end result, and it does the job I needed it to...
I hope you liked this tutorial. Please feel free to share it, comment or give it a plus one. If you didn't like it, I would still appreciate your constructive feedback.
![]()
Visit my ArduinoBasics Google + page.
Follow me on Twitter by looking for ScottC @ArduinoBasics.
I can also be found on Pinterest and Instagram.
Have a look at my videos on my YouTube channel.
![]()
However, if you do not have a google profile...
Feel free to share this page with your friends in any way you see fit.
Hey! Thanks for uploading the project.
ReplyDeleteI want to get a strip of LEDs (such as these: https://www.sparkfun.com/products/12023) to pulse to my heartbeat. Could you suggest how that would be done? I´m a novice with electronics so would really appreciate your help.
Thank you!
Hi Ali,
DeleteI like your idea. Perhaps we can work through this together.
Please follow the link to the forum, and we can discuss this further.
***Click here to go to the forum post***
Hi Ali - please go to the forum post that I mentioned in my last reply.
DeleteI have posted a link to my instagram account which perhaps shows what you are trying to do.
Let me know what you think - and then we can try and update it as required.
i just want to measure the heart rate without graphs. how to do that simply?
ReplyDeleteChange line 57 in the Processing sketch from this
DeletedrawRecs();
to this:
// drawRecs();
You will get the heart rate without the graphs. And it is very simple to do.
thank you so much for the info...........great job sir!!!!!!!!
ReplyDeleteThanks for the feedback Anshu
Deleteplz give me an idea how can i count digital pulse either 0 or 1 in 10 seconds.plz send me the code.can i use callback and timer1 function.
ReplyDeleteHi Opu - the comment section is not ideal for this type of query.
DeletePlease ask this question in the ArduinoBasics Forum
please give the complete circuit diagram....
ReplyDeletelionjust93@gmail.com
Hi Lion Ray,
DeleteThe complete circuit diagram is there already.
Look for Fritzing sketch in the tutorial above.
Regards
Scott
First,thank you so much for uploading the project.
ReplyDeleteI'm a beginner and I have some problems.
I get a lot of error messages when I paste the code on my arduino software.
So I'm wondering where should I put these code and what else should I do to make it work?
Hi Amanda,
DeleteFirstly, there are two sets of code here.
One for Arduino and one for Processing.
Each have an IDE which can be downloaded from the link provided by the title.
Make sure you are pasting the code into the correct IDE.
Obviously the Arduino code will be uploaded to the Arduino. Whereas the processing IDE will be compiled and run on your computer.
If you have have pasted the code into the correct place and are still getting error messages - then please let me know.
Regards
Scott
Thanks for your detailed explanation.
DeleteIt worked!!
After I paste the code on the processing and compile it, an error message "Cannot override the final method from PApplet"came out.
ReplyDeleteHow can I solve it?
I think this relates to the fullscreen method. I think this became an issue with Processing version 3. So try to get rid of anything related to fullscreen:
Deletesize(displayWidth,displayHeight); // This line may also need to change
And you can probably get rid of this method:
boolean sketchFullScreen() {
return true;
}
Do a google search for that error, and you should see some forum posts related to this topic.
BPM in arduino code please
ReplyDeletehow to use a counter to count the pulses in arduino code?
ReplyDeletecan you tell me please
Hi Viraj,
DeleteYou will see in the Arduino code that it will trigger when there is a new beat. You just have to record the interval between the beats to calculate the BPM as I have done in the processing sketch.
int counter=0; //put this in setup
and then after it detects a beat:
counter=counter+1; // or you can use counter++;
You will also need to keep track of the time, and these websites may be helpful :
https://www.arduino.cc/en/Reference/Millis
http://playground.arduino.cc/code/time
Regards
Scott
Getting this issue
ReplyDeleteCould not run the sketch (Target VM failed to initialize).
For more information, read revisions.txt and Help ? Troubleshooting.
Not sure - but maybe this will help:
Deletehttps://processing.org/bugs/bugzilla/1257.html
Hi. Thanks for simplifying it all out! I run the processor and I get a full screen window that says "calibrating". nothing happens from here. What (probably obvious) detail am I missing?
ReplyDeletegrateful for your help...
Hi, running the processor gives me a full screen that says "compiling" and nothing happens from there. what am I missing?
ReplyDeletegrateful for help...
calibrating not compiling...
ReplyDeleteHi Yaniv,
DeleteTry running the Arduino sketch without the Processing sketch.
Open the serial monitor, and double check that you are in fact getting some values that are greater than zero?
Hi! I really like your project!
ReplyDeleteI'd like to do something similar like this for my final year project so I would like to ask you a few questions if you don't mind.
If I'm not mistaken, you have connected this to your computer and you are watching all of this through your monitor, right?
Is it possible instead of the computer to attach this to the LCD screen and to bring external power supply so you can get portable device?
Can you suggest how to do it?
Best regards,
LeVu
Yes - you could make it portable.
DeleteOnce you have the values within the Arduino, you can program the animation on a LCD screen based on those values - but you would have to design the animation.
This might help: http://andybrown.me.uk/2010/12/05/animation-on-the-arduino-with-easing-functions/
Will the same code work on Arduino Pro Mini like on Arduino Uno?
DeleteHi Levu - obviously you would have to connect the wires directly to the heartbeat sensor - and would not be able to use the grove base shield, but the code should still work on the Arduino Pro Mini - I cannot see why it wouldn't work?? I am assuming you are referring to a 5V version of pro mini? If not, then you will need to check the operating instructions for that heart-beat sensor to see if it can operate at 3.3V
DeleteWell you see, I'm making my own sensor with the optocoupler in SMD technology, because I want it to be as smaller as possible, that's why I used Pro Mini instead of Uno. Im going to plase sensor to the botom side of Arduino and attach it directly from there. Now I only need to find solution for the power supply, because it must have small dimensions too, so it wont ruin the size of this project.
DeleteThank you for your answers Scott C!
Hi,
ReplyDeleteI tried with this code its working with the arduino but the processing code is not working it shows as calibrating for a long time not displaying any thing , what to do further, do i want to make any change with code.
Open your Serial monitor when the Arduino code is running. What values are being transmitted to the COM port ??
DeletePlease note - when you have the Serial monitor running - don't run the Processing code... run the Arduino code on it's own.
Hi,
DeleteThanks for replaying, I indivuialy runned the processing code but still it showing as calibrating for a long time.
when i used the serial monitor i got the values as below
0
1023
0
1023
0
1023
0
1023
0
1023
0
1023
0
1023
Hence please tell me weather i want to assign the com port in the processing code?
Ok - you definitely need to run the Arduino Code at the same time as the processing code. Make sure that the Serial monitor on the Arduino IDE is closed before you run the Processing code. Also make sure you have the Arduino code running before you start the Processing code. And yes - you may have to specifically assign the com port in the processing code. You may want to use a number of Print statements within the Processing code to see where it is failing or why it continues to say Calibrating. What that calibrating message means (when it stays like that forever) is that it is not receiving the 1023 values from the Arduino. It needs to acquire about 10 beats before it will show you the Average BPM.
DeleteSo how do you get it to receive those 1023 values?
DeleteHey So I'm stuck in "calibrating" also. I'm getting 0 1023 0 1023 as well. Not sure what do do next. I've real all the comments here and it hasn't been that helpful. How DO I change the COM Port. What else can I try?
DeleteThe COM port is determined by the following line:
DeletemyPort = new Serial(this, Serial.list()[0], 9600);
If you have more than one active COM port, you could possibly try to use Serial.list()[1] instead.
Sometimes it is helpful to print the Serial.list() to the debug window to see the available COM ports, and choose the SAME one as that in Arduino IDE (i.e. the COM port you use to upload your sketch to the Arduino).
There is an error in calculation of beats per min in my output. Can you help me how can i solve it!
ReplyDeleteI'm getting 0 1023 o/p.
I have no idea what you are doing differently.
DeleteVery cool! I tried the arduino and it worked very well, but the processing one just kept saying "calibration". is there any way to fix it?
ReplyDeleteYes - as per the comments above
DeleteGreat job sir...I am currently working on the project"health monitoring ",where i need to measure the BPM ,and whenever it exceeds certain limit it alerts ...so i would be thankful if you provide calculation of BPM from "only the arduino code"...I don't need any animations and processing
ReplyDeletethakning you
waiting for your reply sir
I didn't use the Arduino to do the BPM calculations. I used processing. You just have to transfer the calculations to the Arduino.
DeleteCalculate the time between beats. Divide 1 minute, by that calculated time to get BPM. Make sure you use the same units for the numerator and denominator.
thank you sir
DeleteDo we require grove base shield for processing ??is it compulsory??
DeleteNo you don't need the Grove base shield for Processing. It is used as an interface between the heart-rate sensor and the Arduino. If you know what you are doing, you can bypass the Grove base shield, however, it is easier to use it when you have it.
DeleteHi Shaik
DeleteI am working on a similar project to display BPM on an LCD screen, did you manage to calculate BPM on the arduino as I am having problems figuring it out to get it to work
I am using an LCD, is there a way I can do this without the shield?
ReplyDeleteDo you mean the Grove Base shield? Yes- there is, just make the appropriate connections to the Arduino.
DeleteAnd please can I use the code even if I'm not using the same components as yourself? Is it a universal code for heart rate?
ReplyDeleteI have no idea whether it is universal code or not... I just calculated/programmed it based on common sense.
DeleteHello, I have to program this sensor on arduino uno using test code for my project and also I don't need the animation with the rectangle. Someone who can give me a test code of this sensor ? I try to use only the arduino code but i just get 0 and 1023 values. Thanks
ReplyDeleteWhat values were you expecting from this sensor ?
DeleteIt sends a digital reading to the Arduino (0 or 1), the code converts this to 0 or 1023. I am not exactly sure why I made this conversion.. I could have just left it to send a 0 or 1 to the Processing sketch on the computer. If you were looking for an analog reading, then this sensor is not suitable for your project.
Thanks for uploading the project.
ReplyDeleteI'm working on a project using an app developed by the App Inventor to receive data from this heart rate sensor via bluetooth and react if there's no heartbeat.
Can you give me some suggestions?Um...like how can I know if there's a heartbeat or not and give my app the signal?
Hi Scott,
ReplyDeleteI am encountering the following error - have you any idea by any chance?
Error, disabling serialEvent() for COM4
null
Hi Scott,
ReplyDeleteFirst of all thank you so much for your implementation.
I am working on my dissertation and looking to guage user heart beats. Having set up the arduino code and the processing and followed all your instructions read in the comments, I still encountered the following error.
Error, disabling serialEvent() for COM4
null
Do you by any chance know what this means?
Thanks,
James
You may need to implement a try-catch setup:
Deletehttp://stackoverflow.com/questions/26070466/aurdino-processing-code-error-disabling-serialevent
Double check that COM4 exists??
What COM port is the Arduino using ?
Do you have a download link to the Library?
ReplyDeleteThe Serial Library is inbuilt into Processing. No download required.
DeleteThank u for sharing this project & it worked perfectly for me.
ReplyDeleteExcellent !! Thank you for your feedback !!
DeleteHi!
ReplyDeleteI am a part of a group project on heart beat detector, we are using Arduino Uno with a KY-039 sensor to sense the heart beat.
We are very new to Arduino and processing, and want to display the readings of the sensor as a graph using processing. Could you guide us on how to do that? It would be really helpful!
Thanks a lot!
HI,
ReplyDeleteI am currently working on one project in which i have to use the bio-medical sensor for sense the signal which is generated by human body during some typical condition (like, pain due to injury) and it is in micro volts. so, anyone can suggest appropriate sensor which i will interface with commercial controller
Hi, in my project, I'm thinking of using a RGB LED to show the 3 different range of heart rates during an exercise. I can't seem to figure out the code to to get Green to blink at 60-100bpm, Blue at 101-150bpm and Red at 151-200bpm. Can you help me with this?
ReplyDeleteHi KingMan,
ReplyDeletePlease show me the code you have - post it to the ArduinoBasics Forum under the section "Help me with my project".
Hi, i am currently working on this project. i want to know what is the interface between pulse sensor and arduino. Can you help me with this?
ReplyDeleteNot sure what you mean ? The only thing between the sensor and the Arduino is the wires that connect the two ? The sensor has a digital output.
DeleteHi Scott
DeleteFirst of all great project, absolutely fantastic. I am doing a very similar final year project except i want it my device to be portable. in this case how would i execute it without connecting the arduino to a computer and still display BPM on a lcd screen? thanks
Hi ZedP,
DeleteI answered a similar question in the comments above.
You just need to do the calculations on the Arduino using a timer.
https://www.arduino.cc/en/Reference/Millis
Hi Scott C,
ReplyDeleteCan I use ESP8266-01 module instead of arduino UNO???
I am not sure - I presume so.
DeleteI don't have an ESP8266 module - sorry.
hello sir,
ReplyDeletei uploaded the code and i am getting an error as following:
variable or field 'serialEvent' declared void
please any help?
plus where i can download the used library ?
and i could not found the IDE to download them
thank you in advance
Hi Unknown,
DeleteFirstly, did you use both the Arduino IDE and Processing IDE?
Note that this tutorial uses two seperate IDEs.
The Arduino IDE is used to upload the Arduino code to the Arduino Microcontroller.
The Processing IDE is used to run the Processing sketch on your computer.
The titles of each section are actually a link to the relevant IDE download page. So if you click on the "Processing Sketch" title just before the code is displayed, it will take you to the Processing IDE download page.
You do not need to download any libraries for this tutorial. The processing sketch uses a Serial library which is inbuilt into the IDE.
Hi Scott
ReplyDeleteThank you for a very useful tutorial. I am thinking of trying this out myself but instead of a serial connection to a PC I was thinking of a WiFi connection can you see any big problems with my idea or is it not possible? Your input would be greatly appreciated?
Hi Anonymous,
DeleteAs long as you know how to send data to the PC, whether it be through Serial, Bluetooth or WIFI, it should work.
Regards,
Scott
Hi, I really need your help, it`s an emergency :( I would like to ask you the following question: Is it the same fritzing sketch that I need to follow if I`m just gonna make the arduino code? I have the grove base shield and all the requiered material, but I don`t know if just because I`m making only the arduino code the fritzing sketch changes. Thank you so much!
ReplyDeleteHi Jessica,
DeleteSorry for the late reply - I was travelling and put this blog on hold while I was away.
You don't need to make any changes to the fritzing sketch.
I want to display pulse with oled. How can I do this with .96 i2c oled display .
ReplyDeleteI just added u8glib.print(BPM)
But it doesnt print anything
Find out how the oled works first, design a simple script to get thst side to display ANY text, and then once you have that working, come back and modify the arduino code to accommodate your needs.
DeleteHi Scott
ReplyDeleteI am currently working on a project which would just display the BPM on an LCD Arduino Shield. should this code work for this, if I just copy the BPM calculation code from the processing file and run it in the arduino code?
I am using the Grove Heart rate sensor with the wrist strap and don't have the base shield, instead I am just connecting using a grove to jumper wire, does this also work in the same way?
Thanks
Olivia
Hi Olivia,
DeleteThe Arduino sends HIGH and LOW signals to the computer, and the computer does the necessary calculations to works out the BPM, and from that BPM, the animations are created. There is no reason why this project could not be adapted to run on an LCD screen, but you may find it easier if you run the "animation" from a seperate Arduino. It may be possible to use just one Arduino, but using two will give you some added flexibility. So one Arduino will take the readings, and the second one will display the heart beat on the LCD. Either way, it should be possible.
You can definitely calculate the BPM on the Arduino, but it may need to be adpted somewhat from the Processing code.
Calculate the amount of time between beats, using millis() function, and go from there.
The Grove base shield just makes the connections to the Arduino easier and neater, but of course, you could just use jumper wires if you wanted to.
Hi Scott,
ReplyDeleteI am not sure my old comment has come through
I am working on a similar project to this however I just need the BPM to print on an LCD arduino shield, would the processing code work for that?
Thanks
Olivia
Hi Olivia,
DeleteYes your previous comment came through, however the comments on this blog are moderated, so that I can destroy "SPAMMY comments".
I hope my previous answer helps.
Hi Scott,
ReplyDeleteThank you for this wonderful tutorial. However i'd like to ask you something.
Have you ever try to connect this to Android? If yes, can you give me some insight on how to do it?
Thanks for your time
No - never tried. And has been too long since I have done anything with Android. Sorry - not much help to you.
DeleteI wants to show the average BPM on LCD after calculating avarage of 10 sec. what can i do?
ReplyDeleteHi Scott,
ReplyDeleteThank you for this application. However I have a question for you. I run these codes then I can get nearly 6000 bpm heart rate. In your video above, you got 60-140 bpm. How can I solve this problem. Where is the problem?
Thank you so much.
I don't know where the problem is.
DeleteObviously it is triggering way too quickly.
Maybe start with the sensor and create a sketch to visualise when it is triggering.
nice
ReplyDelete