Cirkit Designer Logo
Cirkit Designer
Your all-in-one circuit design IDE
Home / 
Project Documentation

Arduino Nano-Based Heart Rate Monitor with OLED Display

Image of Arduino Nano-Based Heart Rate Monitor with OLED Display

Circuit Documentation

Summary

This circuit integrates an Arduino Nano microcontroller with a 0.96" OLED display, a Heart Pulse Sensor, and a power supply consisting of a 3.7v LiPo battery. A toggle switch is included to control the power flow, and a resistor is used for current limiting or pull-up/down purposes. The Arduino Nano is programmed to read the pulse signal from the Heart Pulse Sensor and display the beats per minute (BPM) on the OLED screen. An LED on the Arduino Nano blinks with each detected heartbeat.

Component List

Arduino Nano

  • Microcontroller board based on the ATmega328P
  • It has a variety of digital and analog I/O pins.

0.96" OLED

  • Small display screen for visual output
  • Communicates with the Arduino Nano via I2C protocol.

Heart Pulse Sensor

  • Sensor that detects heart pulse rate
  • Outputs an analog signal corresponding to the heartbeat.

3.7v LiPo Battery

  • Rechargeable power source
  • Provides power to the circuit.

Toggle Switch

  • Mechanical switch that controls the connection of the circuit to the power source.

Resistor (10 Ohms)

  • Passive component used to limit current or voltage levels within the circuit.

Wiring Details

Arduino Nano

  • GND connected to the common ground net.
  • VIN connected to the positive terminal of the 3.7v LiPo battery.
  • 5V output providing power to the Heart Pulse Sensor and the OLED display.
  • A5 (SCK) connected to the SCK pin of the OLED for I2C clock signal.
  • A4 (SDA) connected to the SDA pin of the OLED for I2C data signal.
  • A0 connected to the SIGNAL pin of the Heart Pulse Sensor to read the pulse signal.
  • D2 connected to one end of the Resistor.

0.96" OLED

  • GND connected to the common ground net.
  • VDD connected to the 5V output from the Arduino Nano.
  • SCK connected to the A5 pin of the Arduino Nano.
  • SDA connected to the A4 pin of the Arduino Nano.

Heart Pulse Sensor

  • GND connected to the common ground net.
  • VCC connected to the 5V output from the Arduino Nano.
  • SIGNAL connected to the A0 pin of the Arduino Nano.

3.7v LiPo Battery

  • +Ve connected to the VIN pin of the Arduino Nano.
  • GND connected to the common ground net.

Toggle Switch

  • L1 connected to the common ground net.
  • COM connected to one end of the Resistor.

Resistor (10 Ohms)

  • pin1 connected to the COM pin of the Toggle Switch.
  • pin2 connected to the D2 pin of the Arduino Nano.

Documented Code

#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <PulseSensorPlayground.h>

#define OLED_RESET -1  // Reset pin not used
Adafruit_SSD1306 display(OLED_RESET);

const int PulseWire = A0;       // Analog pin connected to Heart Pulse Sensor
const int LED13 = 13;           // Onboard LED
int Threshold = 550;            // Threshold value for detecting a heartbeat

PulseSensorPlayground pulseSensor;  // Creates an instance of the PulseSensorPlayground object

void setup() {
  pinMode(LED13, OUTPUT);  // Set the onboard LED as an output
  display.begin(SSD1306_I2C_ADDRESS, 0x3C);  // Initialize the OLED display
  display.clearDisplay();
  display.setTextColor(WHITE);

  pulseSensor.analogInput(PulseWire);  // Configures the pin to read the pulse signal
  pulseSensor.setThreshold(Threshold);  // Sets the threshold for detecting a beat

  // Check if the pulse sensor is ready and display a message on the OLED
  if (pulseSensor.begin()) {
    displayMessage("Pulse Sensor Ready!");
  }
}

void loop() {
  int myBPM = pulseSensor.getBeatsPerMinute();  // Read the BPM from the sensor

  // If a beat is detected, blink the LED and display the BPM on the OLED
  if (pulseSensor.sawStartOfBeat()) {
    digitalWrite(LED13, HIGH);
    delay(50);
    digitalWrite(LED13, LOW);
    displayBPM(myBPM);
  }

  delay(20);  // Short delay for loop stability
}

// Function to display a message on the OLED
void displayMessage(String message) {
  display.clearDisplay();
  display.setTextSize(1);
  display.setCursor(0, 0);
  display.print(message);
  display.display();
}

// Function to display the BPM value on the OLED
void displayBPM(int bpm) {
  display.clearDisplay();
  display.setTextSize(2);
  display.setCursor(0, 10);
  display.print("BPM: ");
  display.print(bpm);
  display.display();
}

This code initializes the OLED display and the pulse sensor, then continuously reads the BPM and displays it on the OLED. The onboard LED blinks with each detected heartbeat.