(2/4) BPM (Pulse Sensor) and Pedometer (ADXL345 Accelerometer) Wearable Device with OLED Display



Lub dub… Lub dub… In the midst of the silence, you hear the most hardworking muscle beating 24/7 to keep you alive. It’s no doubt, with it’s distinct rhythm, that it’s the Heart.

Continuing from the previous post, the goal of this mini-tutorial is to use a heartbeat sensor to perceive a pulse. The Beats per Minute is calculated as the number of beats divided by a sampling time.

Hardware Used

Software Used

  • Arduino IDE

Library Used

If you open the Pulse Sensor library, it is well documented and very self-explanatory. (Open the .h file with notepad)


Application Description

According to, a heartbeat is the cycle of contraction and expansion of the heart.

When the heart beats, blood pressure causes a very slight movement in some parts of the body, such as in the necks and fingertips. The Heartbeat sensor, albeit very similar to a proximity sensor, recognizes this movement via a photodiode and an LED.

The typical resting heart beats per minute  lies about 60 to 100 BPM.


Before we do anything else, we should calibrate the sensor ! Luckily, the steps are straightforward.

  1. Set-up and Upload the Code in the Arduino
  2. Strap/Mount the Pulse Sensor. (Typically placed in the fingertips)
  3. Open Arduino’s Serial Plotter. Tools->Serial Plotter OR CTLR+SHIFT+L. After a few samples, it should show the following graph/figure
  4. Note the left number (Y-Axis) on where your heart beat occurs. Set this as your threshold.
  5. You have now calibrated your Pulse Sensor !

Set-up the Hardware

Setting up the hardware is pretty straightforward.


This code is used for heartbeat detection calibration. The threshold separates the actual heartbeat from the background noise.

The Code for measuring BPM is well-documented in the Library functions.

Code Breakdown

If you open the library, it is very self-explanatory and simple. The author of the library has a detailed comment about each function calls.

Start reading and processing data from the PulseSensors.

Returns true if a new sample has been read from each PulseSensor.

Returns the latest beats-per-minute measure for the given PulseSensor. The sensorIndex is optional if you put more pulse sensor.

Returns true if a new heartbeat (pulse) has been detected from the given PulseSensor since the last call to sawStartOfBeat() on this PulseSensor.

Threshold is used to find the heartbeat. Adjust this value up in the setup function to avoid noise.


The Infrared LED plus Photodiode is a flexible combination of electronic elements. Applications of the Infrared transceiver ranges from a simple proximity sensor (such as the pulse sensor) to your every-day Television Remote Control. By simply adjusting the sensitivity of the photo diode, it has been made to sense the beat of the heart. How cool is that ?


Tags : arduinoHeartheart rateHeart SensorPulsePulse Sensor

Leave a Response