close
KnowledgeBase

Heart Beat Counter on Raspberry Pi Zero Using Pulse sensor and LCD Display

Overview

Your heart rate, or pulse, is the number of times your heart beats per minute. Normal heart rate varies from person to person. Knowing yours can be an important heart-health gauge.

In this tutorial we made a Heartbeat Counter which displays the beats per minute in an LCD using a Raspberry Pi Zero.

Hardware Components

Software Components

Application Discussion

How Pulse Sensor works

The working of the Pulse/Heart beat sensor is very simple. The sensor has two sides, on one side the LED is placed along with an ambient light sensor and on the other side we have some circuitry. This circuitry is responsible for the amplification and noise cancellation work. The LED on the front side of the sensor is placed over a vein in our human body. This can either be your Finger tip or you ear tips, but it should be placed directly on top of a vein.

Now the LED emits light which will fall on the vein directly. The veins will have blood flow inside them only when the heart is pumping, so if we monitor the flow of blood we can monitor the heart beats as well.  If the flow of blood is detected then the ambient light sensor will pick up more light since they will be reflected by the blood, this minor change in received light is analysed over time to determine our heart beats.

What is an I2C 1602 LCD

The I2C 1602 LCD module is a 2 line by 16 character display interfaced to an I2C daughter board. The I2C interface only requires 2 data connections, +5 VDC and GND to operate.

I2C (Inter-Integrated Circuit)

In I2C you can connect multiple slaves to a single master and you can have multiple masters controlling single, or multiple slaves. This is really useful when you want to have more than one microcontroller logging data to a single memory card or displaying text to a single LCD.

I2C is a serial communication protocol, so data is transferred bit by bit along a single wire (the SDA line). Like SPI, I2C is synchronous, so the output of bits is synchronized to the sampling of bits by a clock signal shared between the master and the slave. The clock signal is always controlled by the master.

ADS1115

The ADS1115 is a 16 bit Analog-to-Digital Converter that can greatly improve your Arduino resolution and measurement accuracy.   It has four input channels that can be configured for Single Ended, Differential or Comparator Measurements.

Hardware Setup

Pulse sensor setup

Connect the VCC to the 3V3 pin of Raspberry Pi Zero and GND to GND pin.

ADS1115 setup

Connect the SDA pin to GPIO 2 pin (SDA) of Raspberry Pi Zero and SCL to GPIO 3 pin (SCL) and the VCC to 3v3 and GND to GND of Raspberry Pi Zero.

I2C 1602 LCD setup

Connect the SDA and SCL to GPIO 2 and 3 of Raspberry Pi Zero and the VCC to 5v pin and the GND to GND pin.

Code

Libraries Included

I2C_LCD_driver Code

Create a new script, and then name it I2C_LCD_driver. And then copy the code and save it in the folder where your main script is located.

Python Code

Code Breakdown

In this code, we read the analog value from pulse sensor and we find the peak and trough of the pulse wave and removing the noise from the pulse wave.

This is the code were we find the heart beat and calculate BPM (Beats Per Minute) and if the the lastBPM is equal to the current BPM reading it will now display the BPM in the LCD. This means that it is now showing the actual BPM.

Conclusion

There so many types of sensors today that is applicable in health monitoring or in medical field. Like the pulse sensor, it allows us to create a project that helps us count our heartbeat and also helps us monitor our heart and health.

References

[1] http://henrysbench.capnfatz.com/henrys-bench/arduino-voltage-measurements/arduino-ads1115-module-getting-started-tutorial/

[2] https://components101.com/sensors/pulse-sensor

[3] http://www.circuitbasics.com/basics-of-the-i2c-communication-protocol/

Tags : ADS1115Heart beat sensorHeartBeati2cI2C 1602 LCDPulsePulse SensorRaspberry piRaspberry Pi Zero

Leave a Response


Warning: Cannot assign an empty string to a string offset in /home/createl1/public_html/community/wp-includes/class.wp-scripts.php on line 454

Warning: Cannot assign an empty string to a string offset in /home/createl1/public_html/community/wp-includes/class.wp-scripts.php on line 454