• First Steps
  • General
  • Projects
Facebook Twitter YouTube
Tutorials for Raspberry Pi Tutorials for Raspberry Pi
  • Hardware & GPIO
  • Sensors & Components
  • Scale
  • Cases
  • Fingerprint
  • Gas Sensor
  • Heartbeat
  • German
  • French
Tutorials for Raspberry Pi Tutorials for Raspberry Pi
Home»Hardware & GPIO»Raspberry Pi Heartbeat / Pulse measuring

Raspberry Pi Heartbeat / Pulse measuring

Facebook Twitter LinkedIn Tumblr Email Reddit
Raspberry Pi Pulsmesser
Share
Facebook Twitter LinkedIn Email Tumblr Reddit Telegram WhatsApp

Not only with fitness watches, but also with the Raspberry Pi it is possible to measure pulse / heart rates. With a small module – the Raspberry Pi pulse sensor – you can easily measure your own pulse and thus monitor permanently your health condition. This sensor can also be used in mobile Raspberry Pi applications (fitness tracker project? ;-)) thanks to low power consumption.

What is still needed and which libraries can be used are shown in this tutorial.

Heart Rate Monitor Accessories

The Raspberry Pi pulse sensor can not be read out digitally, thus we need an analog-to-digital converter. Such an ADC makes it possible to read out analog signals on the Raspberry Pi because. Unlike the Arduino, the Pi has no integrated analog IO pins.

I used the following components in the video below:

  • Heart rate Pulse sensor: US / UK
  • MCP3008 ADC: US / UK
  • Small Breadboard: US / UK
  • Jumper Wire: US / UK

Some sensors are shipped with a Velcro fastener for the finger, which is advantageous for the measurement, since there is not too much pressure on the finger.

 

Raspberry Pi Heart Rate Monitor – Connection

Since this sensor has also been designed for the Arduino, it does not provide a digitally readable signal. In order to be able to read the analogue signal, an ADC such as the MCP3008 is required. It doesn’t matter which channel of the ADC you are using, as long as you adjust it later in the code.

The positive pole of the pulse sensor is connected to 3.3V from the Raspberry Pi, as well as Minus to Ground. I have connected the signal / data pin (marked with an “S”) to channel 0 of the MCP3008.

 

The ADC uses the SpiDev library, which must be installed.

 

Code for reading the Heart / Pulse Rate

If you don’t use a current Raspbian / NOOBS operating system, you may need to update and install git.

sudo apt-get update
sudo apt-get upgrade sudo apt-get install git

On GitHub I have provided a library for recording the heart rate. You can download it as follows:

git clone https://github.com/tutRPi/Raspberry-Pi-Heartbeat-Pulse-Sensor

Also attached is a sample file, which reads the heart rate every second. In the video below you can see this visualized.
To start the example we switch to the folder and call the example.py.

cd Raspberry-Pi-Heartbeat-Pulse-Sensor/
sudo python example.py

If you want to stop, press CTRL+C.

If you look at the example more closely, you will find that with p.startAsyncBPM() a thread is started, which measures the pulse in the background. By p.stopAsyncBPM() you can stop this thread – and thus the measurement. Feel free to customize the code.

 

Raspberry Pi Pulse Sensor Example and Extension

In the following video I have run the sample file and the measurement of my pulse is shown. Before that, I measured my heart rate with my smartphone (integrated heart rate monitor), which showed me a resting pulse of 55 BPM.

As you can see, the measurement is not always accurate, especially if the finger does not touch the pulse sensor. Here, one could use an additional pressure sensor or something similar. Then, it should only measure if you are sure that the finger touches the pulse sensor. It also takes a few seconds for the pulse to be recorded correctly, but this is not the case with commercially available pulse meters.

 

For the module (originally developed for Arduino), there is also some sample code. In addition, there is a nice visualisation of the values on Github. It should not be too much effort to customize these files for my library. If you want to change the code, you may also change my library according to the requirements. I would be happy about a comment 🙂

Raspberry Pi Puls Heartbeat Monitor
The data provide a better overview of the pulse history, when visualized.

 

heart frequence MCP3008 pulse analyser pulse sensor
Share. Facebook Twitter Pinterest LinkedIn Tumblr Email
Previous ArticleWS2812 RGB LED Streifen per Raspberry Pi steuern
Next Article How to use a Raspberry Pi Fingerprint Sensor for Authentication

Related Posts

How to build a ESP8266 Scale (with Weight Sensor HX711)

How-To: Bluetooth Connection between ESP32’s and Raspberry Pi’s

How to create a Solar Powered Raspberry Pi Bitcoin Miner

How to build a Smart Agriculture System using IoT

97 Comments

  1. Chandrakanth on 17. October 2017 11:45

    Traceback (most recent call last):
    File “example.py”, line 4, in
    p = Pulsesensor()
    File “/home/pi/Raspberry-Pi-Heartbeat-Pulse-Sensor/pulsesensor.py”, line 11, in __init__
    self.adc = MCP3008(bus, device)
    File “/home/pi/Raspberry-Pi-Heartbeat-Pulse-Sensor/MCP3008.py”, line 18, in __init__
    self.open()
    File “/home/pi/Raspberry-Pi-Heartbeat-Pulse-Sensor/MCP3008.py”, line 21, in open
    self.spi.open(self.bus, self.device)
    IOError: [Errno 2] No such file or directory

    I am getting these errors. what is the problem??? PLEASE HELP!!

    Reply
    • Felix on 17. October 2017 13:01

      I think you haven’t installed spidev.

      Reply
      • Chandrakanth on 28. October 2017 17:15

        thanks bro… It worked… But it shows garbage values even if not touched… What is the solution????

      • GNRAJU on 21. December 2017 13:39

        It gives always 228,229 and 230 values. I think calculation is wrong…. !!!!

      • Felix on 21. December 2017 19:24

        Why? See the video 🙂

    • Thejus Singh on 17. November 2017 0:24

      Hello, even I am getting the same error… how do I fix it??

      Reply
    • Lucas on 13. December 2017 15:15

      Im still havin this issue even after installing SpiDev !!!
      Can someone help!!

      Reply
      • Aravindh Kumar on 13. February 2018 10:51

        enable SPI in Raspberry pi by preference>Raspberry pi configuration > Interfaces
        Check Enable respective to SPI
        welcome..!!

    • thas on 29. October 2018 9:34

      Hi bro im using High-Precision AD/DA Board instead of MCP3008. Do u have solution for it.

      Reply
    • USer on 23. January 2019 14:42

      I’m also getting the same problem but I already installed spidev. Please help!!!

      Reply
    • ymi on 3. February 2021 22:23

      Same problem for me. How to solve it???????

      Reply
  2. Tina on 23. October 2017 18:49

    My set up does not read the heart rate reliably. The bmp jumps all over the place. Can anyone help?

    Reply
    • Chandrakanth on 29. October 2017 11:52

      same problem for me too

      Reply
    • Simon on 2. November 2017 12:33

      for me too

      Reply
    • johngarcia on 15. November 2017 22:09

      Hello! could you solve the problem?

      Reply
  3. Joel on 25. October 2017 20:58

    The Pulse Sensor you are using is a knock-off of the original.
    Support the original makers by purchasing their products
    http://www.pulsesensor.com

    Reply
  4. PiEater on 17. November 2017 0:08

    I’m trying to put this together and having a little trouble. I have spidev installed and everything else running as it should. Are there any code modifications necessary? Any help would be greatly appreciated.

    Reply
  5. AriffZ on 28. November 2017 10:00

    Hello..my sensor show zero value pulse..can anyone help?

    Reply
  6. raju on 14. December 2017 6:19

    I am also having same problem. Can someone please help?

    Reply
  7. GNRAJU on 16. December 2017 7:14

    my output values always gives zero “0”. Please help me ?

    Reply
  8. S.Karthi on 19. December 2017 10:56

    kindly can you give me the source code for heart beat rate monitoring

    Reply
    • Felix on 19. December 2017 12:37

      It is all on github (see the link).

      Reply
      • saurabh on 22. August 2018 12:18

        any code to run in c…

  9. NewToRaspi on 29. December 2017 15:42

    Hello I need some help. Sensor always showing no heartbeat found.
    Can you please help.

    Reply
    • Lak on 11. January 2018 12:23

      I’m having the same problem too..Did you find the reason?

      Reply
    • abhijeet on 20. January 2018 20:09

      same here

      Reply
      • Bernd on 13. February 2018 20:58

        It is the same for me, “no heartbeat found”. Anyone who can help, please?

    • KAVYA RAVALI on 6. March 2018 18:10

      I have the same problem.It is showing no heartbeat found.Any solution for it?

      Reply
    • fadi on 14. September 2019 23:22

      i had found the same error no heartbeat found did you find the solution please help

      Reply
  10. Chris on 2. January 2018 9:15

    Hi,

    I am trying this out. I am able to see variation in the signal, however they are not consistent. I am able to confirm MCP3008 is processing signals when I send in a specific signal through a variable resistor. That channel shows consistent signal out.
    Bu when I connect the pulse sensor, reading shows values at random and looks like they jump all over.
    Question is, is there a way that the pulse sensor and the MCP3008 are working as it should?

    Reply
    • Trojx on 24. January 2018 10:28

      Same issue here. I do have receive the signal through the example code above,however the BMP fluctuate around 220 even though the sensor was attached to nothing. Any help plz 🙂

      Reply
      • am18 on 4. September 2018 12:46

        Hi, I have the same problem, did you find a solution plz??

  11. Le Jia on 9. January 2018 11:10

    Hi, I have followed your tutorial and it works initially, but it could not read bpm and shows “No heartbeat found” after i format my sd card with the latest Raspbian, can you help me with this problem?

    Reply
    • HrDDD on 30. January 2018 22:27

      Le Jia, I have the same problem like you, did you found what is wrong ?

      Reply
      • Le Jia on 6. February 2018 3:57

        Use Wheezy instead of raspbian jessie

  12. Kih on 31. January 2018 10:46

    Can grove ear clip heart rate sensor be used instead of heart rate pulse sensor?

    Reply
    • Felix on 31. January 2018 22:03

      Have you a link to that sensor?

      Reply
  13. Ashikur Rahman on 21. February 2018 8:33

    How can I use Ad8232 sensor with raspberry pi 3b . I have also mcp3008 adc

    Reply
    • Arun kumar on 10. February 2020 18:54

      iam also using the same components… can you help me?pleaseeeeee

      Reply
  14. Omkar on 23. February 2018 6:22

    I have connected everything exactly as you have suggested, installed everything that you asked. It wont work anyways. Please help.

    Using Raspberry Pi 3 with this module.

    Reply
  15. Abdiaziz Mohamud on 8. March 2018 2:05

    Has anybody find a solution using the raspberry pi 3? I am getting “No Heartbeat found”

    Reply
  16. Javed on 13. March 2018 9:04

    I am getting ‘No Heartbeat found’ msg always

    Reply
  17. sandhya on 13. March 2018 20:28

    Had a similar “No Heartbeat found” issue.
    Works after adding this to MCP3008 code module before spi.xfer2 line
    spi.max_speed_hz = 1350000
    Found the solution here:
    https://www.raspberrypi.org/forums/viewtopic.php?t=115971
    Reducing 1350000 to 700000 also works.

    Reply
    • D.Saketh on 23. February 2019 8:21

      Thank you!! It worked , but…… The values are highly fluctuating like
      65
      88
      99
      140
      186
      Like this.
      Could you please reply, what to do?

      Reply
      • liv on 25. March 2019 16:30

        did you ever find out how to fix this?

    • syameeza natasha on 29. March 2019 9:24

      hi, i got a similar problem with u but when i adding the spi.max_speed_hz = 1350000 i got an error that “spi” is not defined?

      Reply
      • rishi on 5. October 2019 10:31

        use this.spi insted of spi

    • rishi on 5. October 2019 10:29

      No Heartbeat found
      BPM: 47
      BPM: 47
      No Heartbeat found
      No Heartbeat found
      No Heartbeat found
      No Heartbeat found
      No Heartbeat found
      No Heartbeat found
      No Heartbeat found
      BPM: 50
      BPM: 52
      BPM: 76
      BPM: 144
      BPM: 233
      BPM: 231
      BPM: 230
      BPM: 230
      BPM: 230
      BPM: 228
      BPM: 228
      BPM: 229
      BPM: 231
      BPM: 231
      BPM: 231
      BPM: 239
      BPM: 239
      BPM: 239
      No Heartbeat found

      Reply
    • Smita Dasharath Dange on 26. September 2020 14:38

      It really worked for me too….thank you

      Reply
  18. mano on 16. May 2018 5:53

    Hi.. I am facing the same issue..value fluctuate around 220 and also it shows value when it is not touched.. how to fix it..? can anyone please help ?

    Reply
  19. Jamie on 1. June 2018 18:11

    Hi,
    I having trouble actually connecting it all together i have a raspberry pi and all the attachments needed but having difficultly putting them together.
    Can anyone help.? step by step would be great.
    Thanks in advance

    Reply
  20. karthik on 21. July 2018 13:25

    Hello,
    I have set up the circuit as instructed and also the code is set. I am getting values, but the values hike all of a sudden eg : 70 to 115, detect beats even when no finger is pressed. Can anyone help me with the false signals.

    Reply
    • liv on 25. March 2019 16:30

      did you ever find out how to fix this?

      Reply
  21. thas on 29. October 2018 9:31

    hello I have to use High-Precision AD/DA Board for the same project. i dont know how start with it. can anyone help me.

    Reply
  22. Jayant Bokefode on 17. January 2019 13:33

    No heartbeat found. Mcp 3008 working correctly with lm35 sensor but not with heart rate sensor.. please help me… I am stucked….

    Reply
  23. Walzade Pranit .R on 3. February 2019 16:31

    how to measure heart rate by this sensor help of arduino uno

    Reply
  24. Mehmet Emin Dağ on 16. March 2019 22:53

    i tryed self.spi.max_speed_hz = 13500000 but my values is very high and when i try to download i see my bcm2835 is that why the problem ?

    Reply
  25. Lily on 19. March 2019 6:52

    Every time I run the code it says ‘No Hearbeat Found’and I’ve tried changing the code and switching sensors but it’s still the same.

    Reply
  26. zarea on 20. March 2019 12:00

    Traceback (most recent call last):
    File “example.py”, line 4, in
    p = Pulsesensor()
    File “/home/pi/Raspberry-Pi-Heartbeat-Pulse-Sensor/pulsesensor.py”, line 11, in __init__
    self.adc = MCP3008(bus, device)
    File “/home/pi/Raspberry-Pi-Heartbeat-Pulse-Sensor/MCP3008.py”, line 18, in __init__
    self.open()
    File “/home/pi/Raspberry-Pi-Heartbeat-Pulse-Sensor/MCP3008.py”, line 21, in open
    self.spi.open(self.bus, self.device)
    IOError: [Errno 2] No such file or directory
    Im using mcp3208 and it come this error pls help me

    Reply
    • IG on 5. June 2019 19:45

      sudo raspi-config
      turn on the SPI

      Reply
  27. zarea on 21. March 2019 23:39

    thanks, put now I run the code it says ‘No Hearbeat Found’ what the solution pls help

    Reply
  28. Leonard on 1. May 2019 23:18

    Can someone help me set up the pins in the program? I am very confused because I have just started working with RaspberryPi. I just want someone to send me a code with which pins I connect what to

    Reply
    • bali on 4. November 2019 19:51

      heyy did you get the code working?

      Reply
  29. GQ on 22. June 2019 6:13

    Traceback (most recent call last):
    File “example.py”, line 4, in
    p = Pulsesensor()
    File “/home/pi/Raspberry-Pi-Heartbeat-Pulse-Sensor/pulsesensor.py”, line 11, in __init__
    self.adc = MCP3008(bus, device)
    File “/home/pi/Raspberry-Pi-Heartbeat-Pulse-Sensor/MCP3008.py”, line 18, in __init__
    self.open()
    File “/home/pi/Raspberry-Pi-Heartbeat-Pulse-Sensor/MCP3008.py”, line 21, in open
    self.spi.open(self.bus, self.device)
    IOError: [Errno 2] No such file or directory

    This error still occurs even though i have turned on my SPI and installed Spidev, anybody can help me please T.T I beg you

    Reply
  30. Coder on 2. October 2019 18:48

    can you read pulsations from your hands palm ?

    Reply
  31. Gyanendra Priyadarshi on 21. November 2019 21:53

    I’m getting ‘no Heatbeat found’ msg every time. I’m unable to read the signal from MCP3008. could anyone plz help me out

    Reply
  32. Roe on 23. December 2019 19:58

    I tried all advices but still I got ‘No Heartbeat Found’ message. What can I do now?

    Reply
  33. Arslan Khawar on 25. December 2019 12:37

    Can some one help me
    I’m using ADS1115 with Pulse sensor .
    How can i connect pulse sensor with ads1115. its my first time and i’m dont understand how to start it.
    kindly help me it will be big help in final year project.
    Thnaks in advance …!!!!!

    Reply
  34. Renu Kshirsagar on 17. March 2020 15:07

    Read the comments and made the changes, works good,getting consistent values.
    Below is the code block:

    def read(self, channel = 0):
    self.spi.max_speed_hz = 1350000
    adc = self.spi.xfer2([1, (8 + channel) << 4, 0])
    data = ((adc[1] & 3) << 8) + adc[2]
    return data

    Reply
    • stevie on 11. March 2021 22:26

      Still got msg ‘ No heartbeat Found’ any alternative solution?

      Reply
  35. AKASH RONAD on 5. June 2020 10:47

    No Heartbeat found
    No Heartbeat found
    No Heartbeat found
    No Heartbeat found
    BPM: 41
    BPM: 41
    BPM: 41
    BPM: 46
    BPM: 53
    BPM: 91
    BPM: 168
    BPM: 230
    BPM: 231
    BPM: 230
    BPM: 230
    BPM: 231
    BPM: 230
    BPM: 230
    BPM: 230
    BPM: 231
    BPM: 230
    BPM: 230
    BPM: 230
    BPM: 230
    BPM: 230
    BPM: 230
    BPM: 203
    BPM: 203
    BPM: 203
    BPM: 229
    value will raise sudden why?

    Reply
    • Felix on 6. June 2020 1:36

      Can you check the voltage?

      Reply
      • Akash Ronad on 24. June 2020 7:41

        I can give only 3.5 v

  36. Lon Landry on 14. July 2020 17:58

    No heartbeat found – tried code changes mentioned above (PI 4 b)

    Reply
  37. nay on 29. August 2020 4:29

    i got result no heartbeat found.ithink i’m mistake between breadboard and raspberry pi.plz. show me real connection picture.Thank you so much

    Reply
  38. ruba almhtar on 18. September 2020 21:23

    excuce me, can you help me I just followed your way, but the phrase appears not found

    Reply
  39. Mark on 17. October 2020 19:18

    It worked for me when I swapped to the 5 volts pin… but before you do that just make sure your pulsemeter can handle 5 volts

    Reply
  40. Lalithsaran on 13. March 2021 4:51

    My pulse sensor doesn’t glow what should I do??

    Reply

Leave A Reply Cancel Reply

Build a digital Raspberry Pi Scale (with Weight Sensor HX711)

How to setup a Raspberry Pi FTP Server – Webserver Installation

Read Capacitive Soil Moisture Sensor DFROBOT Gravity on the Raspberry Pi

Raspberry Pi Traffic Light Circuit with GPIO Part 1

How to build Raspberry Pi voice control (home automation)

50 of the most important Raspberry Pi Sensors and Components

Subscribe to Blog
Subscribe to Raspberry Pi Tutorials and don't miss any new Tutorial!
Subscribe

Thank you!

We will contact you soon.

Tutorials for Raspberry Pi
Facebook Twitter YouTube
  • Contact & Disclaimer

Type above and press Enter to search. Press Esc to cancel.