Ohnitsch Cartoons Cartoons, Electronics, Acrobatics and other things.

18Mar/1519

Measuring heart rate with a piezoelectric vibration sensor

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!

Piezo sensor taped to finger

Piezo sensor taped to finger

Analog values from a piezoelectric sensor taped to my finger.

Analog values from a piezoelectric sensor taped to my finger.

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.

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:

If you would like to try this at home, just connect the analog output of the sensor to A2 (or change the code) and connect the 5V and GND lines of the sensor.