Ks0015 keyestudio Pulse Rate Monitor: Difference between revisions

From Keyestudio Wiki
Jump to navigation Jump to search
 
(7 intermediate revisions by the same user not shown)
Line 1: Line 1:
<br>
==Introduction==
==Introduction==
This module uses a ultra-bright infrared LED and a phototransistor to detect the pulse of your finger. The red LED then flashes in time with your pulse.  
This module uses a ultra-bright infrared (IR) LED and a phototransistor to detect the pulse in your finger. The red LED then flashes in time with your pulse. <br>
Working Principle: Shine the bright LED onto one side of your finger while the
'''Working principle:''' <br>
phototransistor on the other side of your finger picks up the amount of transmitted light. The resistance of the phototransistor will vary slightly as the blood pulses through your finger.
Shine the bright LED onto one side of your finger while the phototransistor on the other side of your finger picks up the amount of transmitted light. <br>
The resistance of the phototransistor will vary slightly as the blood pulses through your finger.
<br>[[File:Ks0015-2.png|500px|frameless|thumb]]<br>
<br>[[File:Ks0015-2.png|500px|frameless|thumb]]<br>


<br>
==Connection Diagram ==
==Connection Diagram ==
<br>[[File:Ks0015.png|700px|frameless|thumb]]<br>


<br>[[File:152.png|500px|frameless|thumb]]<br>
<br>
 
==Sample Code ==
==Sample Code ==
 
Copy and paste the code below to Arduino software.<br>
The program for this project is quite tricky to get right. Indeed, the first step is not to run the entire
final script, but rather a test script that will gather data that we can then paste into a spreadsheet and chart to test out the smoothing algorithm (more on this later).
The test script is provided in Listing Project 12.
<pre>
<pre>
int ledPin = 13;
int ledPin = 13;
Line 29: Line 30:
static double oldValue = 0;
static double oldValue = 0;
static double oldChange = 0;
static double oldChange = 0;
int rawValue =
int rawValue = analogRead(sensorPin);
analogRead(sensorPin);
double value = alpha * oldValue + (1 - alpha) * rawValue;
double value = alpha * oldValue  
+ (1 - alpha) * rawValue;
Serial.print(rawValue);
Serial.print(rawValue);
Serial.print(,);
Serial.print(",");
Serial.println(value);
Serial.println(value);
oldValue = value;
oldValue = value;
delay(period);
delay(period);
}</pre>
}
This script reads the raw signal from the analog input and applies the smoothing function and then
</pre>
writes both values to the Serial Monitor, where we can capture them and paste them into a spreadsheet for analysis. Note that the Serial Monitor’s communications is set to its fastest rate to
minimize the effects of the delays caused by sending the data. When you start the Serial Monitor, you will need to change the serial speed to 115200 baud.
Copy and paste the captured text into a spreadsheet. The resultant data and a line chart drawn from the two columns are shown in Figure 5-17. The more jagged trace is from the raw data read from the analog port, and the smoother trace clearly has most of the noise removed. If the smoothed trace shows significant noise—in particular, any false peaks that will confuse the monitor—increase the level of smoothing by decreasing the value of alpha.
Once you have found the right value of alpha for your sensor arrangement, you can transfer this
value into the real sketch and switch over to using the real sketch rather than the test sketch. The real sketch is provided in the following listing on the next page.


<pre>
<br>
int ledPin = 13;
==Result==
int sensorPin = 0;
Wire it up well as the above diagram, then upload well the code to the board and click the icon of serial monitor on the upper right corner of Arduino software. <br>
double alpha = 0.75;
Set the baud rate as 115200, you will see the data is displayed on the monitor. You can copy and paste the data to the excel, finally it will generate the corresponding picture shown below.
int period = 20;
<br>[[File:35-1.png|500px|frameless|thumb]]<br>
double change = 0.0;
<br>[[File:35-2.png|500px|frameless|thumb]] [[File:35-3.png|500px|frameless|thumb]]<br>
void setup()
{
pinMode(ledPin, OUTPUT);
Serial.begin(115200);
}
void loop()
{
static double oldValue = 0;
static double oldChange = 0;
int rawValue =
analogRead(sensorPin);
double value = alpha * oldValue
+ (1 - alpha) * rawValue;
Serial.print(rawValue);
Serial.print(“,”);
Serial.println(value);
oldValue = value;
delay(period);
}</pre>
LISTING PROJECT 12—TEST SCRIPT
There now just remains the problem of detecting the peaks. Looking at Figure 5-17, we can see that if we keep track of the previous reading, we can see that the readings are gradually increasing
until the change in reading flips over and becomes negative. So, if we lit the LED whenever the old change was positive but the new change was negative, we would get a brief pulse from the LED at the peak of each pulse. Putting It All Together Both the test and real sketch for Project 12 are in your Arduino Sketchbook. For instructions on downloading it to the board, see Chapter 1.
As mentioned, getting this project to work is a little tricky. You will probably find that you have to
get your finger in just the right place to start getting a pulse. If you are having trouble, run the
test script as described previously to check that your detector is getting a pulse and the smoothing
factor alpha is low enough.


<br>[[File:153.png|500px|frameless|thumb]]<br>


<br>
==Resources ==
==Resources ==


'''Video'''
* '''Video'''<br>
http://video.keyestudio.com/ks0015/


http://www.keyestudio.com/wp/ks0015/
* '''PDF and Code''' <br>
https://fs.keyestudio.com/KS0015


'''PDF'''


https://drive.google.com/open?id=1hj_lQm3yU5dgQn5EQ6D8L8MC1t8IMGDc
<br>


==Get One Now==
==Get One Now==
'''Official Website'''


http://www.keyestudio.com/keyestudio-pulse-rate-monitor-sensor-module.html
*[https://www.keyestudio.com/free-shipping-keyestudio-finger-probe-heart-rate-pulse-monitor-sensor-module-for-arduino-p0015.html  '''Official Website''' ]
 
*[https://www.aliexpress.com/store/product/Free-shipping-KEYES-Finger-heartbeat-measurement-sensor-module-for-arduino/1452162_32348204940.html?spm=2114.12010615.8148356.3.4fb166d94Zbqwk  '''Shop on aliexpress''']
 
 


[[Category: Sensor]]
[[Category: Sensor]]

Latest revision as of 14:38, 7 January 2021


Introduction

This module uses a ultra-bright infrared (IR) LED and a phototransistor to detect the pulse in your finger. The red LED then flashes in time with your pulse.
Working principle:
Shine the bright LED onto one side of your finger while the phototransistor on the other side of your finger picks up the amount of transmitted light.
The resistance of the phototransistor will vary slightly as the blood pulses through your finger.
thumb


Connection Diagram


thumb


Sample Code

Copy and paste the code below to Arduino software.

int ledPin = 13;
int sensorPin = 0;
double alpha = 0.75;
int period = 20;
double change = 0.0;
void setup()
{
pinMode(ledPin, OUTPUT);
Serial.begin(115200);
}
void loop()
{
static double oldValue = 0;
static double oldChange = 0;
int rawValue = analogRead(sensorPin);
double value = alpha * oldValue + (1 - alpha) * rawValue;
Serial.print(rawValue);
Serial.print(",");
Serial.println(value);
oldValue = value;
delay(period);
}


Result

Wire it up well as the above diagram, then upload well the code to the board and click the icon of serial monitor on the upper right corner of Arduino software.
Set the baud rate as 115200, you will see the data is displayed on the monitor. You can copy and paste the data to the excel, finally it will generate the corresponding picture shown below.
thumb

thumb thumb



Resources

  • Video

http://video.keyestudio.com/ks0015/

  • PDF and Code

https://fs.keyestudio.com/KS0015



Get One Now