Home of RF and Wireless Vendors and Resources

One Stop For Your RF and Wireless Need

Arduino Interfacing with Heartbeat sensor diagram,working,code

This app note covers Arduino Interfacing with Heartbeat sensor diagram and its working. It describes Heartbeat sensor used and mentions arduino code.

About Heartbeat sensor

• This sensor generates a digital square wave as output.
• This output signal is analyzed using PWM ( Pulse Width Modulation ) method.
• Signal output of heartbeat sensor is interfaced with analog read pin (i.e. A0) of Arduino Uno board as shown.
• Following table mentions pin to pin connection of Arduino Interfacing with Heartbeat sensor.

Heartbeat sensor Arduino Uno board
Supply +5 V
Ground GND
Output A0 pin (analog input)

About Arduino board

Arduino board

• Arduino Uno houses ATmega328 microcontroller from ATMEL. This microcontroller contains flash memory (32 KB), RAM (2 KB), 8 bit wide CPU and 1 KB EEPROM.
• It also supports 6 analog pins which reads voltage and not current. Inside, it converts analog measurement to digital for various purposes. It supports digital pins (0 to 13) which can function either as input or output.
• It has various interfaces viz. I2C, digital pins, analog pins, serial communication, USB etc.
• It also has reset pin, power port, crystal oscillator and Tx/Rx LEDs.
• This open source prototype board can be easily programmed using easy to use arduino IDE and USB interfaced between laptop PC and arduino board.
• IDE uses simplified C++ program.
• Board requires 5V DC which can be powered using AC/DC adapter or battery.

Arduino Interfacing with Heartbeat sensor diagram and its working

Arduino Interfacing with Heartbeat sensor

As shown in the figure-1, three pins of heartbeat sensor are connected with arduino board with details provided in the table above.

Arduino heartbeat sensor interface code

Following is the arduino code compiled and uploaded to the arduino board using Arduino IDE. Code snippet is used to declare heartbeat is normal or not. This is done based on comparison between read value and normal value.

WiFiClient me;
Adafruit_MQTT_Client mqtt (&me, server, port,username, aiokey);
Adafruit_MQTT_Publish gas_data = Adafruit_MQTT_Publish (&mqtt, username"/feeds/heartbeat_data");

void loop(){

if (mqtt.connected())
int heartbeat= analogRead(A0);
Serial.println (heartbeat);
if (heartbeat_data.publish (heartbeat))
Serial.println ("Success");
Serial.print (Trying");
delay (2000);

if (BPM >=80)
Serial.println("Rapid Heart beat");
else if (BPM <= 32)
Serial.println("Low heartbeat");
Serial.println ("You are FINE..!!");

Conclusion: In this application note we have seen heartbeat sensor interfacing with Arduino Uno board. Arduino board is also used for interfacing different types of sensors for applications. The typical sensors interfaced with arduino are sound sensor, gyro sensor, LDR sensor, GPS sensor, color sensor, pH sensor etc.

IoT system on chip tutorial Related Links

This tutorial section on IoT (Internet of Things) covers following sub topics:
Main tutorial  IoT section  IoT article  Cellular IoT  Components  Sensors  INDIAN companies  Antenna Types  Wireless technologies  IoT transceiver  SoC 

RF and Wireless Terminologies

Share this page

Translate this page