Engineers Garage

  • Electronic Projects & Tutorials
    • Electronic Projects
      • Arduino Projects
      • AVR
      • Raspberry pi
      • ESP8266
      • BeagleBone
      • 8051 Microcontroller
      • ARM
      • PIC Microcontroller
      • STM32
    • Tutorials
      • Audio Electronics
      • Battery Management
      • Brainwave
      • Electric Vehicles
      • EMI/EMC/RFI
      • Hardware Filters
      • IoT tutorials
      • Power Tutorials
      • Python
      • Sensors
      • USB
      • VHDL
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Product News
    • Business News
    • Company/Start-up News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • DigiKey Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Learn
    • eBooks/Tech Tips
    • Design Guides
    • Learning Center
    • Tech Toolboxes
    • Webinars & Digital Events
  • Resources
    • Digital Issues
    • EE Training Days
    • LEAP Awards
    • Podcasts
    • Webinars / Digital Events
    • White Papers
    • Engineering Diversity & Inclusion
    • DesignFast
  • Guest Post Guidelines
  • Advertise
  • Subscribe

Arduino-based heartbeat monitor with graphical heartbeat display

By Nikhil Agnihotri August 12, 2021

The measurement of pulse rate or heartbeat is a very common medical procedure. Quite often, the patient kept under observation is essentially monitored via their pulse/heartbeat rate.

Pulse rate varies from person to person. The pulse is lower when we are resting because at that time, the body does not need much oxygen, and the heart can pump blood at a lower rate to fulfill the oxygen required by the body. The pulse rises when we exercise or are under stress. This is because the body requires more oxygen during these times and, therefore, requires more blood to pump through it to meet the oxygen requirement. The normal pulse rate for children ranges from 70 to ~100 beats per minute. The normal pulse rate for adults is 60 to ~100 beats per minute. To estimate your maximum age-related heart rate, subtract your age from 220.

Critically ill patients are continuously monitored for their pulse rate, blood pressure, etc. It is common to monitor pulse rate graphically in Intensive Care Units (ICU) and High Dependency Units (HDU) in hospitals.

In this project, we have designed two models of pulse rate monitor. One model only displays the heartbeat per minute. The second model also displays the heartbeat graphically.

Both models are designed on Arduino UNO. The display unit is an SSD1306 OLED screen. The pulse sensor used to design the project is the XD-58C sensor.

The XD-58C is a low-power plug-and-play analog heartbeat sensor easily interfaced to any microcontroller or single board computer that allows analog input. This sensor is very compact – the size of a button and extremely handy.

XD58C pulse sensor
XD58C is a low-cost optical heart-rate sensor designed and made by World Famous Electronics. This is an open-source hardware project by Joel Murphy and Yury Gitman. You can learn more about this open-source hardware project at pulsesensor.com.

The sensor is made of an ambient light sensor APDS-9008 from Avago, and a green reverse mounted LED AM2520ZGC09 from Kingbright. The front of the sensor is indicated by a heart shape figure, where you can place your finger on Kingbright’s reverse-mounted green LED. On the reverse side of the sensor is Microchip’s MCP6001 operational amplifier with the rest of the circuit that makes a RC filter network. The new version of the Pulse sensor has diode protection on the power line, so if the power leads are reversed by mistake, the sensor does not damage.

The operating voltage of the XD85C pulse sensor is 3V to 5.5V DC, and the current required is 3~4 mA. The operating temperature range of the sensor is -40˚C to 85˚C. The sensor has three leads – GND, VCC, and Signal.

How optical heart rate sensors work
An optical pulse sensor illuminates a green light (~550 nm) and measures the amount of light reflected back using a photosensor. XD85C has a LED output of 565 nm, and its photosensor has an input of 525 nm. The oxygenated hemoglobin in the arterial blood tends to absorb green light. Higher is the hemoglobin in the blood; the more green light is absorbed. During each heartbeat, the blood is pumped through the finger/earlobe. As a result, the amount of reflected light changes with the flow of blood. This produces a changing waveform at the photosensor. As several readings from the photosensor are taken, a heartbeat rate is obtained. This method of detecting heart rate using green light is called Photoplethysmogram.

The photosensor output is filtered through a RC network and amplified to a sufficient level to remove noise and get a clearer signal. The heartbeat’s graphical display is just the graphical depiction of blood flow variation through the finger or earlobe.

Interfacing XD85C pulse sensor with Arduino

The XD85C can be directly plugged in with Arduino and other microcontrollers. The pulse sensor has three leads – VCC, GND, and Signal. Connect the VCC and GND pins to 5V out and Ground of the Arduino, respectively. Connect the Signal lead to any of the analog inputs of the controller.

Pulse sensor library
The pulse sensor XD85C from World Famous Electronics LLC has a well-documented Arduino library. The library is called “PulseSensor Playground”. It can be included by navigating to Sketch->Include Library -> Manage Libraries and search for “pulsesensor”. The library comes with lots of example sketches that can be tried to test the sensor. Once the library is installed, these example sketches can be explored by navigating to File -> Examples -> PulseSensor Playground once the library is installed. These example libraries are useful in detecting pulse rate on Arduino’s Serial Monitor and visualizing heartbeat at Arduino’s Serial Plotter and Processing Visualizer.

In this project, we will plot the heartbeat and indicate heartbeat measurement on a display unit, which is the SSD1306 OLED screen. The pulse sensor library does not provide any functions or examples that let you utilize raw data for plotting heartbeat. Let us start building our heartbeat monitor. There are two models designed here. Model 1 only displays the heartbeat rate on the OLED screen. Model 2 displays a plot of the heartbeat as well.

Heartbeat monitor model 1
In this model, we will only detect pulse rate and display it on an OLED screen.

Components required

  1. Arduino UNO/any Arduino board x1
  2. XD85C Pulse Sensor x1
  3. SSD1306 128×64 OLED x1
  4. Jumper wires/ connecting wires

Circuit connections

To connect the pulse sensor with Arduino UNO, connect the VCC and GND to 3.3V out and ground the Arduino, respectively. Connect the Signal lead to analog input pin A0 of Arduino UNO. In this project, a 7-pin SSD1306 OLED module is interfaced to Arduino UNO. The module is connected to the Arduino, as shown in the following table.

Arduino sketch

How the circuit works
This model uses the official library of the pulse sensor. It uses Arduino interrupts to measure pulse rate. The interrupts are used to determine the time interval between each beat, and the number of beats per minute are evaluated accordingly. The beat is detected by comparing the analog signal value to a threshold value. If the signal value exceeds the threshold, one beat is counted. The interrupt is generated every time a beat is detected.

The code
The sketch begins by indicating the Arduino to use interrupt and then importing the Pulsesensor Playground library. The SPI and Adafruit libraries for SSD1306 OLED are imported. The constants for OLED display are declared. Similarly, constants for pulse sensors are defined. The OLED display is initialized, and bitmap storing the icon for “EEWORLDONLINE” is defined to PROGMEM. The bitmap is converted to an array. An object of the pulse sensor class is declared.

In the setup() function, the baud rate for serial data transmission is set to 9600. The analog signal from the pulse sensor is read using the analogInput() method. The pulse indicating LED, i.e., Arduino’s  LED is blinked using blinkOnPulse() method, and the threshold is set to 555 using the setThreshold() method. The pulse sensor is initialized using begin() method. The OLED display is initialized, and the logo of “EEWORLDONLINE” is displayed on the screen.

In the loop() function, text font and color is set using setTextSize() and setTextColor() methods. The pulse rate is read using getBeatsPerMinute() method and displayed on the OLED screen in appropriate format.

Results

Heartbeat monitor model 1
In this model, not just the pulse rate. The graph of the heartbeat is also displayed on the OLED screen.

Components required

  1. Arduino UNO/any Arduino board x1
  2. XD85C Pulse Sensor x1
  3. SSD1306 128×64 OLED x1
  4. Jumper wires/ connecting wires

Circuit connections

Same as in model 1.

Arduino sketch

How the circuit works
This model does not use the official pulse sensor library. Instead, it utilizes the raw analog values obtained from the pulse sensor. The raw sensor values are compared to an upper and lower threshold to detect the beginning and end of each heartbeat. The number of heartbeats is sampled over a period of 1 minute using millis() method of Arduino. The analog readings of the sensor are mapped to the size of the SSD1306 OLED, and a graph of the heartbeat is plotted at the top of the screen. After every minute, beats per second are calculated and displayed as text at the bottom of the OLED screen.

The code
The sketch begins with importing SPI and Adafruit libraries for the SSD1306 OLED display and its declaration of constants. The constants for the pulse sensor are defined.  The OLED display is initialized, and the bitmap storing the icon for “EEWORLDONLINE” is defined as PROGMEM. The bitmap is converted to an array. The variables to map the pulse waveform are declared as follows.

This includes the declaration of the upper and lower threshold. In the setup() function, pulse indicating LED on Arduino board is set as output. The OLED display is initialized, and the logo of “EEWORLDONLINE” is flashed to it. The display is cleared, and the font size is set to 2.

In the loop() function, we first test if the value of x for the vertical number line of the plot does not exceed 127 as the OLED display is 128 pixels wide. The current time elapsed is stored in the “ThisTime” variable, and the analog reading is taken from the A0 pin. The signal value is stored as a y variable by mapping the signal value to the height of the OLED display. Note that the range of analog value, i.e., 1024, is divided by 64 to obtain 16. The signal value is divided by 16 to scale it to OLED display resolution. The signal value is compared to the upper threshold to determine if the beat is detected. The signal value is compared to the lower threshold to determine the completion of the beat. The BPM is detected every 1 minute and displayed as text at the bottom of the OLED display.

Result

 

You may also like:

  • pollution monitoring
    Arduino-based portable pollution monitor with OLED display

  • Arduino-based walking steps and distance calculator

  • What types of motors are used in electric vehicles?

  • Arduino-based electronic leveling device

  • Insight into Arduino: Beginner’s Guide

  • Designing an Arduino-based EMG monitor

Filed Under: Arduino Projects, Electronic Projects, Sensors, Tutorials, Video
Tagged With: Arduino, Arduino Heartbeat Graph, Arduino Heartbeat Monitor, Arduino projects, Arduino Pulse Monito, Arduino Pulse Sensor, Arduino SSD1306, Arduino XD58C Pulse Sensor
 

Next Article

← Previous Article
Next Article →

Questions related to this article?
👉Ask and discuss on EDAboard.com and Electro-Tech-Online.com forums.



Tell Us What You Think!! Cancel reply

You must be logged in to post a comment.

EE TECH TOOLBOX

“ee
Tech Toolbox: Internet of Things
Explore practical strategies for minimizing attack surfaces, managing memory efficiently, and securing firmware. Download now to ensure your IoT implementations remain secure, efficient, and future-ready.

EE Learning Center

EE Learning Center
“engineers
EXPAND YOUR KNOWLEDGE AND STAY CONNECTED
Get the latest info on technologies, tools and strategies for EE professionals.

HAVE A QUESTION?

Have a technical question about an article or other engineering questions? Check out our engineering forums EDABoard.com and Electro-Tech-Online.com where you can get those questions asked and answered by your peers!


RSS EDABOARD.com Discussions

RSS Electro-Tech-Online.com Discussions

  • Parts required for a personal project
  • Curved lines in PCB design
  • Wideband matching an electrically short bowtie antenna; 50 ohm, 434 MHz
  • using a RTC in SF basic
  • PIC KIT 3 not able to program dsPIC

Featured – RPi Python Programming (27 Part)

  • RPi Python Programming 21: The SIM900A AT commands
  • RPi Python Programming 22: Calls & SMS using a SIM900A GSM-GPRS modem
  • RPi Python Programming 23: Interfacing a NEO-6MV2 GPS module with Raspberry Pi
  • RPi Python Programming 24: I2C explained
  • RPi Python Programming 25 – Synchronous serial communication in Raspberry Pi using I2C protocol
  • RPi Python Programming 26 – Interfacing ADXL345 accelerometer sensor with Raspberry Pi

Recent Articles

  • AC-DC power supply extends voltage range to 800 V DC
  • Infineon’s inductive sensor integrates coil system driver, signal conditioning circuits and DSP
  • Arm Cortex-M23 MCU delivers 87.5 µA/MHz active mode
  • STMicroelectronics releases automotive amplifiers with in-play open-load detection
  • Convection-cooled power controller integrates EtherCat connectivity

EE ENGINEERING TRAINING DAYS

engineering

Submit a Guest Post

submit a guest post
Engineers Garage
  • Analog IC TIps
  • Connector Tips
  • Battery Power Tips
  • DesignFast
  • EDABoard Forums
  • EE World Online
  • Electro-Tech-Online Forums
  • EV Engineering
  • Microcontroller Tips
  • Power Electronic Tips
  • Sensor Tips
  • Test and Measurement Tips
  • 5G Technology World
  • Subscribe to our newsletter
  • About Us
  • Contact Us
  • Advertise

Copyright © 2025 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy

Search Engineers Garage

  • Electronic Projects & Tutorials
    • Electronic Projects
      • Arduino Projects
      • AVR
      • Raspberry pi
      • ESP8266
      • BeagleBone
      • 8051 Microcontroller
      • ARM
      • PIC Microcontroller
      • STM32
    • Tutorials
      • Audio Electronics
      • Battery Management
      • Brainwave
      • Electric Vehicles
      • EMI/EMC/RFI
      • Hardware Filters
      • IoT tutorials
      • Power Tutorials
      • Python
      • Sensors
      • USB
      • VHDL
    • Circuit Design
    • Project Videos
    • Components
  • Articles
    • Tech Articles
    • Insight
    • Invention Stories
    • How to
    • What Is
  • News
    • Electronic Product News
    • Business News
    • Company/Start-up News
    • DIY Reviews
    • Guest Post
  • Forums
    • EDABoard.com
    • Electro-Tech-Online
    • EG Forum Archive
  • DigiKey Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Learn
    • eBooks/Tech Tips
    • Design Guides
    • Learning Center
    • Tech Toolboxes
    • Webinars & Digital Events
  • Resources
    • Digital Issues
    • EE Training Days
    • LEAP Awards
    • Podcasts
    • Webinars / Digital Events
    • White Papers
    • Engineering Diversity & Inclusion
    • DesignFast
  • Guest Post Guidelines
  • Advertise
  • Subscribe