easy pulse plugin sensor

Easy Pulse Plugin Heartbeat Sensor with arduino Tutorial

There are some heartbeat sensor in market with cheap price. I’ve used three of them, that is heart rate from pulsesensor.com, max30100 and easy pulse Plugin heartbeart sensor. In my opinion, the most stable is easy pulse plugin. Maybe because it comes with a shell or cover. That make minimum interference from outside. Different with heart rate sensor form pulsesensor.com sometimes it’s has different output amplitude that make it harder to get stable value. It has many factor that make that unstable.

easy pulse plugin sensor
easy pulse plugin sensor

In this tutorial we will only examine how to use Easy Pulse Plugin Heartbeat Sensor with an arduino. This sensor has an analog output just like sensor from pulsesensor.com. Before we go far how to use this sensor, we will examine how this sensor works. Little basic theory about this sensor.

How Easy Pulse Plugin Sensor Works?

Easy Pulse Plugin is an open-source sensor based on photoplethysmography principle (PPG). It is non-invasive to measure the cadiovascular pulse wave by detect the blood volume changes in blood vessels. This sensor uses a infrared light emitting diode (IR-LED) and a photodetector.

photoplethysmography sensor
photoplethysmography sensor

Look at picture above, there is an IR-LED as transmitter. This LED will transmit an infrared light to the photo sensor. But if we place our finger between them, the photo sensor will receive only the light left after absorbed by finger. And the thing is, the light absorbed by finger is vary according to the blood. The light intensity that up to the photo sensor is related to the changes in blood volume inside the tissue.



Analog output from this sensor will form a wave that related to the beat of the heartbeat. it will rise when there’s a beat.

beat wave
beat wave

Using it with arduino

easy pulse plugin sensor with arduino wiring
easy pulse plugin sensor with arduino wiring

You can choose to use 5V or 3.3V for power of this sensor. To choose simply move the jumper in top left corner (yellow circle in picture above). And you can also choose the output to out at A0 or A1 (move the jumper in green circle).

Connect this sensor to arduino just like picture above.

5v -> 5v (if using 5V module)

GND -> GND

A0 -> A0 (if choose A0 as output).

Or you can just directly connect the sensor to the arduino UNO. Just like the picture below. The module is designed can connect directly. Of course if you don’t need another power pin.

arduino uno with easy pulse plugin
arduino uno with easy pulse plugin

The arduino code

In beat wave picture above is the picture of wave created by the beats from sensor when a finger placed in the sensor. The peak made when a beat is sensed by the sensor. To get the wave like in picture above you can use the sample code from arduino named analogReadSerial  with little modification. The modification should give longer delay. Or you can just copy the code below :

/*
  AnalogReadSerial

  Reads an analog input on pin 0, prints the result to the Serial Monitor.
  Graphical representation is available using Serial Plotter (Tools > Serial Plotter menu).
  Attach the center pin of a potentiometer to pin A0, and the outside pins to +5V and ground.

  This example code is in the public domain.

  http://www.arduino.cc/en/Tutorial/AnalogReadSerial
*/

// the setup routine runs once when you press reset:
void setup() {
  // initialize serial communication at 9600 bits per second:
  Serial.begin(9600);
}

// the loop routine runs over and over again forever:
void loop() {
  // read the input on analog pin 0:
  int sensorValue = analogRead(A0);
  // print out the value you read:
  Serial.println(sensorValue);
  delay(10);        // delay in between reads for stability
}

I modify the delay so it will only read the sensorValue every 10ms. Upload code above and open your Serial Plotter. Open it from tools -> Serial Plotter.



If we want to make a heart rate device we can measure by count how many peak from the sensor in one minute. To do this you need to define your threshold first. So you can decide where the beats happen. Look at picture below for example

beat threshold
beat threshold

I will give the threshold for my beats at 450 value of ADC. So every adc reach more than 450 I will count it as a beat.  And because I consider measure beats per minute will take a long time when it’s really count for one minute, I will just count for 20 seconds. And the result will multiply by 3. So it is just like 60 seconds or one minute.


int adc;
boolean counter;
int count;
unsigned long millisBefore;
unsigned long beatTime=20000;
const int threshold=450;

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  counter = true;
  millisBefore = millis();
}

void loop() {
  // put your main code here, to run repeatedly:
  adc = analogRead(A0);
  Serial.println(adc);
  delay(10);

  if ((millis() - millisBefore) < beatTime) {
    if (counter == true) {
      if (adc >= threshold) {
        count++;
        counter = false;
        Serial.print("Beat : ");
        Serial.println(count);
      }
    }
    if (adc < threshold) {
      counter = true;
    }
  } else {
    Serial.print(count*(60000/beatTime));
    Serial.println(" BPM");
    count=0;
    millisBefore = millis();
  }
}

The code above will print number every beat detected and will print the beats per minute every 20 seconds. You can edit how long to get count the beat by edit variable beatTime. 20000 means 20 seconds, because it is in miliseconds. And of course you can edit the threshold too by edit number in threshold variable.

Leave a Reply

Your email address will not be published. Required fields are marked *