Summary of Measuring Heart Rate With A Piezo
This article describes an accidental discovery where a piezoelectric sensor, originally intended to detect water flow vibrations, successfully measured the user's heart rate by being taped to their finger. The project utilizes an Arduino to read analog signals from the sensor, filtering noise through averaging and detecting signal thresholds to calculate time intervals between beats. This data is then averaged over the last 16 beats to determine a stable heart rate value.
Parts used in Heart Rate Monitor:
- DFRobot Piezo Disc Vibration Sensor Module
- Arduino board
- Tape
While trying to create a circuit that detects whether water is flowing through a pipe by measuring the vibration with a piezoelectric sensor, just to see what happens I taped the sensor around my finger and – to my surprise – got values that were a very noise-free representation of my heart rate!
This is even easier than using LEDs as it only requires a piezoelectric sensor and an Arduino. (and a piece of tape)
The sensor I used is a DFRobot Piezo Disc Vibration Sensor Module.
void loop() {
int avg = 0;
for(int i=0;i<64;i++){
avg+=analogRead(A2);
}
Serial.println(avg/64,DEC);
delay(5);
}
|
1
2
3
4
5
6
7
8
9
10
11
12
|
void setup() {
Serial.begin(57600);
}
void loop() {
int avg = 0;
for(int i=0;i<64;i++){
avg+=analogRead(A2);
}
Serial.println(avg/64,DEC);
delay(5);
}
|
When defining an arbitrary threshold (e.g. half of the maximum measured value), the rising edge of the signal will pass the threshold once per heartbeat, making measuring it as simple as measuring the time between two successive beats. For less jitter, I chose to calculate the heart rate using the average of the last 16 time differences between the beats.
Here’s a quick and dirty code that calculates the heart rate and outputs the average heart rate over the last 16 beats at every beat:
-
What components are required for this project?
The project requires a DFRobot Piezo Disc Vibration Sensor Module, an Arduino board, and a piece of tape. -
How can I measure heart rate using a piezo sensor?
You can tape the sensor around your finger to detect vibrations caused by your heartbeat. -
Does the code average multiple readings to reduce noise?
Yes, the code averages 64 analog readings from pin A2 to smooth out the signal. -
How does the system detect individual heartbeats?
The system detects a heartbeat when the signal rises past an arbitrary threshold value. -
How is the final heart rate calculated?
The heart rate is calculated by averaging the time differences between the last 16 detected beats. -
Can this method be used to detect water flow?
The original intention was to detect water flow vibration, but it unexpectedly worked better for heart rate detection. -
Which Arduino pin is used for reading the sensor?
The code reads the sensor data from analog pin A2. -
What is the purpose of the timings array in the code?
The timings array stores the time differences between successive beats in a ring buffer format.

