HBS201 is a Heartbeat Sensor Module based on infrared technology, offering a non-intrusive method of detecting heartbeats. By placing the fingertip on the sensor, it accurately detects the heartbeat. An illustration of its IR sensor is provided. It’s essential to note that this module is intended solely for educational and research applications and is not suitable for medical purposes. It is shown in the Fig 1.
Fig. 1
Features:
- · Analog signal output
- · Digital pulse output
- · Breadboard mountable
- · LED indicator for each pulse
- · 3.3v to 5v power supply
Application:
- Heartbeat sensor
Sensor:
It is a transducer that converts the variation in the light into an electrical signal. An infrared (IR) based heartbeat sensor, also known as a photoplethysmogram (PPG) sensor. It is a device designed to measure the heartbeat or pulse rate of an individual by detecting changes in blood volume in peripheral blood vessels. The basic principle behind these sensors is the absorption of light by haemoglobin in the blood. The function of the sensor is depicted in the Fig.2
Fig. 2
The sensor comprises two elements: an IR light-emitting diode (LED) and either a photodiode or a phototransistor. These components are positioned adjacent to each other, separated by a black divider. This divider serves to prevent direct exposure of the photodiode to IR rays.
IR LED emits the IR rays into the skin. When blood pulses through the blood vessels, the blood volume in the vessels changes. During each heartbeat, more blood enters the area being illuminated by the IR LED, leading to increased absorption of infrared light. The intensity of the reflected light is dependent on the volume of the blood. These reflected light incident to the photodiode, and the photodiode diode converts this intensity variation into an electrical signal. This signal is in the form of Analog voltage. The amplitude of this signal is very low, with unwanted noise. So, it is necessary to process this signal through a signal conditioner circuit. The Signal conditioner circuit amplifies the pulse signal and filters out unwanted noise. The block diagram of the sensor is shown in the Fig.3
Fig. 3
Output of the module:
The amplitude of the output of the signal conditioner circuit is sufficient to read by a Microcontroller or display on an Oscilloscope. Channel one displayed an analog signal, and channel two displayed a digital signal. Each pulse represents 0s. Shown in Fig. 4. Test conditions: Supply: 5V dc powered by external supply source.
Fig. 4
Video demo of the waveform.
Calculation of Pulses:
A Microcontroller or a digital pulse counter can count the pulses in the predefined time interval, and later, it can calculate pulses per minute. It also can be achieved by finding the time between two successive pulses.
An LED is also mounted on the board, which blinks for each pulse. Manually, one can count pulses per minute using this LED without other equipment.
Physical Dimension:
Dimension of the PCB is 21mm x 23mm. There is a pin header of 4 ways. Pin’s name and function are depicted in Fig 5. The pitch of the pins of the connector is 2.54mm, which is compatible with the breadboard. So that it can be mounted on the breadboard easily. There is an LED that blinks for each pulse. The module is also operated with a 3.7v lithium-ion battery.
Fig.5
Interface with Arduino Board:
The module can be interfaced with any Microcontroller. Interface steps and codes for the Arduino Uno board are given below.
The module has 4 pins as
- Ground
- Analog Signal Output
- Digital Signal Output
- Positive Power Supply (3V3 to 5V)
Connect the ground and power pin to the Arduino board. In this test, the power pin of the module has been connected to 5V of the Arduino board.
If you want to plot the Analog waveform, connect the Analog Output (Pin 2) of the module to any Analog pin of the Arduino board, i.e. A0, A1, A2, and so on. Upload the following codes to the Arduino board. Here, Analog output of the module is connected to A1 port of the Arduino Uno.
Code:
//Global Variables int analogInputPin = A1; // select the input pin for the input analog signal uint16_t analogValue=0; void setup() { Serial.begin(9600); } void loop() { analogValue = analogRead(analogInputPin); //read the analog signal from module Serial.print(analogValue); // print the analog signal on serial monitor delay(60); }
Now go to the tools tab in the Arduino IDE and select Serial Plotter. Check the baud rate. The baud rate should be the same as given in the code. Now, put the fingertip on the sensor of the module. You can see the analog output of the Pulse sensor module on the Arduino serial plotter window, as shown in Fig 6.
Output of the Analog waveform in serial plotter (baud rate: 9600).
Fig. 6
Code to display both signals together in the Serial plotter window. Connect the Digital and analog output of the module to A0 and A1 of the Arduino, respectively.
/* */ //Global Variables int digitalInputPin = A0; // select the input pin for the input digital signal int analogInputPin = A1; // select the input pin for the input analog signal uint16_t analogValue=0; uint16_t digitalValue=0; void setup() { Serial.begin(9600); } void loop() { analogValue = analogRead(analogInputPin); //read the analog signal from module digitalValue = analogRead(digitalInputPin); //read the analog signal from module Serial.print(analogValue); // print the analog signal on serial monitor Serial.print(","); Serial.println(digitalValue); // print the analog signal on serial monitor delay(60); }
The output of both waveforms in the serial plotter is shown in Fig. 7
Fig. 7
Pulse rate calculation with analog signal. Read the time between successive peaks of the analog signal. The captured time is the Time period of the Signal in milliseconds.
\(Pulse \; Rate = 60 * (\frac{1000}{Period(ms)}) \; bpm\)
Code:
/* */ //Global Variables int analogInputPin = A1; // select the input pin for the input analog signal uint16_t analogValue=0; uint16_t digitalValue=0; double start=0; double stop=0; void setup() { Serial.begin(9600); } void loop() { analogValue = analogRead(analogInputPin); //read the analog signal from module do{ analogValue = analogRead(analogInputPin); //read the analog signal from module }while(analogValue<450); do{ analogValue = analogRead(analogInputPin); //read the analog signal from module start=millis(); }while(analogValue>449); //wait to detect peak do{ analogValue = analogRead(analogInputPin); //read the analog signal from module }while(analogValue<450); // wait during the peak do{ analogValue = analogRead(analogInputPin); //read the analog signal from module stop=millis(); }while(analogValue>449); //wait for next peak //(stop-start) is time period in milliseconds between two consecutive peaks. int pulseRate = 60000/(stop-start); // Pulse rate is calculated per minute Serial.print("Pulse Rate : "); Serial.print(pulseRate); // print the calculated pulse Rate Serial.println(" bpm"); //reset the time variables stop=0; start=0; }
Pulse rate also can be calculated using Digital Signal. Connect the Digital Pin 3 of the module to the Arduino Digital Pin 2. Enable the external interrupt on the rising or falling edge of the digital signal and count these pulses per minute. Another way to capture the time stamp between two successive interrupts is to calculate the number of pulses per minute.
Code:
/* */ //Global variables uint8_t interruptPin = 2; double time=0; double currentTime=0; double lastTime=0; int timePeriod=0; void setup() { Serial.begin(9600); pinMode(interruptPin, INPUT_PULLUP); attachInterrupt(digitalPinToInterrupt(interruptPin), calculateTime, FALLING); } void loop() { //(stop-start) is time period in milliseconds between two consecutive peaks. if(timePeriod<1) { Serial.println("Finger Out ....."); } else{ int pulseRate = 60000/(timePeriod); // Pulse rate is calculated per minute timePeriod=0; Serial.print("Pulse Rate : "); Serial.print(pulseRate); // print the calculated pulse Rate Serial.println(" bpm"); } delay(1000); } void calculateTime() { currentTime=millis(); timePeriod = currentTime-lastTime; lastTime=currentTime; }
Video Output of the calculated pulse rate: