Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

Arduino Nano-Based Pulse Oximeter with OLED Display

View and Edit Project In Cirkit DesignerImage of Arduino Nano-Based Pulse Oximeter with OLED Display

Circuit Documentation

Summary of the Circuit

This circuit is designed to measure heart rate and blood oxygen saturation (SpO2) using a MAX30102 sensor, display the data on a 0.96" OLED screen, and allow user interaction through a pushbutton. The Arduino Nano serves as the central microcontroller to process the sensor data, control the OLED display, and manage user input.

Component List

Arduino Nano

0.96" OLED

Pushbutton

MAX30102 Heart Rate and Oxygen Sensor

Wiring Details

Arduino Nano

0.96" OLED

Pushbutton

MAX30102 Heart Rate and Oxygen Sensor

Documented Code

The code for the Arduino Nano is written in C++ and is designed to work with the connected components to measure heart rate and blood oxygen saturation, display the data on the OLED, and respond to button presses.

#include "ssd1306h.h"
#include "MAX30102.h"
#include "Pulse.h"
#include <avr/pgmspace.h>
#include <EEPROM.h>
#include <avr/sleep.h>

// Definitions for bit manipulation
#ifndef cbi
#define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit))
#endif
#ifndef sbi
#define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))
#endif

// Object instantiation for the OLED, sensor, and pulse processing
SSD1306 oled; 
MAX30102 sensor;
Pulse pulseIR;
Pulse pulseRed;
MAFilter bpm;

// Pin definitions
#define LED LED_BUILTIN
#define BUTTON 3
#define OPTIONS 7

// Heart bitmap for display
static const uint8_t heart_bits[] PROGMEM = { /* ... */ };

// SpO2 lookup table
const uint8_t spo2_table[184] PROGMEM = { /* ... */ };

// Function to read the supply voltage
int getVCC() {
  // Implementation details...
}

// Function to print a digit on the OLED
void print_digit(int x, int y, long val, char c=' ', uint8_t field = 3,const int BIG = 2) {
  // Implementation details...
}

// Waveform class to record and display PPG waveform
class Waveform {
  // Class members and methods...
} wave;

// Global variables and function declarations
int  beatAvg;
int  SPO2, SPO2f;
int  voltage;
bool filter_for_graph = false;
bool draw_Red = false;
uint8_t pcflag =0;
uint8_t istate = 0;
uint8_t sleep_counter = 0;

void button(void) {
  // Implementation details...
}

void checkbutton() {
  // Implementation details...
}

void Display_5() {
  // Implementation details...
}

void go_sleep() {
  // Implementation details...
}

void draw_oled(int msg) {
  // Implementation details...
}

void setup(void) {
  // Setup code for the OLED, sensor, and button interrupt
}

void loop()  {
  // Main loop for processing sensor data and updating the display
}

The code includes setup and loop functions, which are standard in Arduino sketches. The setup function initializes the OLED display, the MAX30102 sensor, and sets up an interrupt for the pushbutton. The loop function continuously checks the sensor data, updates the display, and handles button presses to change display modes or enter a low-power sleep state.