May 27, 2021

How to make Pulse Oximeter at Home

In our previous blog, we interfaced Pulse-Oximeter (Max30100) Module to NodeMCU. With a little bit of modification that can be upgraded to a full functioning Pulse-Oximeter. We have interfaced 0.96" I2C OLED display before. Today we made a Pulse-Oximeter using that knowledge.

Follow our previous blogs for a better understanding of the scenario.
Pulse Oximeter MAX30100 Interface with NodeMCU
OLED Display Interface with Arduino

Things we need:

  • NodeMCU
  • Max30100 Module
  • 0.96" OLED I2C Display Module 
  • Female Berg Strip Connector
  • Dot Vero Board
  • Soldering Kit
  • Nut and Bolts 1/8"
  • PVC Spacer Tube

Connection Diagram:
Now follow the diagram below to do the connections.

After the connection is done upload the code below.

Source Code:

/*
Controller : NodeMCU
Display : 0.96" OLED I2C
Sensor : MAX30100
*/
#include <Wire.h>
#include <Blynk.h>
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <OneWire.h>
#include <DallasTemperature.h>
#include "MAX30100_PulseOximeter.h"
/*-------------------- Timer --------------------*/
#define REPORTING_PERIOD_MS 1000
#define REPORTING_PERIOD_MS_1 30000
uint32_t tsLastReport = 0;
uint32_t tsLastReport1 = 0;
/*-------------------- OLED --------------------*/
#define OLED_RESET D5
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
/*-------------------- Blynk --------------------*/
char auth[] = "lfCiyoMVb8455V_-uKbx8HVxiLWRGN1c";
char ssid[] = "ProjectHub";
char pass[] = "creativestudio1974";
/*-------------------- Max30100 --------------------*/
PulseOximeter pox;
float BPM, SpO2;
/*-------------------- Temp --------------------*/
#define ONE_WIRE_BUS 2
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
float TEMP;
int pinValue;
const unsigned char bitmap [] PROGMEM =
{
0x00, 0x00, 0x00, 0x00, 0x01, 0x80, 0x18, 0x00, 0x0f, 0xe0, 0x7f, 0x00, 0x3f, 0xf9, 0xff, 0xc0,
0x7f, 0xf9, 0xff, 0xc0, 0x7f, 0xff, 0xff, 0xe0, 0x7f, 0xff, 0xff, 0xe0, 0xff, 0xff, 0xff, 0xf0,
0xff, 0xf7, 0xff, 0xf0, 0xff, 0xe7, 0xff, 0xf0, 0xff, 0xe7, 0xff, 0xf0, 0x7f, 0xdb, 0xff, 0xe0,
0x7f, 0x9b, 0xff, 0xe0, 0x00, 0x3b, 0xc0, 0x00, 0x3f, 0xf9, 0x9f, 0xc0, 0x3f, 0xfd, 0xbf, 0xc0,
0x1f, 0xfd, 0xbf, 0x80, 0x0f, 0xfd, 0x7f, 0x00, 0x07, 0xfe, 0x7e, 0x00, 0x03, 0xfe, 0xfc, 0x00,
0x01, 0xff, 0xf8, 0x00, 0x00, 0xff, 0xf0, 0x00, 0x00, 0x7f, 0xe0, 0x00, 0x00, 0x3f, 0xc0, 0x00,
0x00, 0x0f, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
void onBeatDetected()
{
display.drawBitmap( 100, 20, bitmap, 28, 28, 1);
display.display();
}
BLYNK_WRITE (V5)
{
pinValue = param.asInt();
}
void setup()
{
/*-------------------- Display --------------------*/
if (!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {
for (;;);
}
display.clearDisplay();
display.setTextSize(1);
display.setTextColor(WHITE);
display.setCursor(28, 0);
display.println(F("Project Hub"));
display.display();
/*-------------------- Blynk --------------------*/
Blynk.begin(auth, ssid, pass);
/*-------------------- Max30100 --------------------*/
pinMode(16, OUTPUT); //D0 INT Pin
if (!pox.begin())
{
display.clearDisplay();
display.println("POX FAILED");
display.display();
for (;;);
}
/*-------------------- Temp --------------------*/
sensors.begin();
}
void loop()
{
Jump:
display.clearDisplay();
display.setCursor(28, 0);
display.println(F("Project Hub"));
display.display();
pox.begin();
pox.setOnBeatDetectedCallback(onBeatDetected);
pox.setIRLedCurrent(MAX30100_LED_CURR_7_6MA);
while (1)
{
/*-------------------- POX --------------------*/
pox.update();
BPM = pox.getHeartRate();
SpO2 = pox.getSpO2();
/*-------------------- Blynk --------------------*/
Blynk.run();
/*-------------------- Timer1S --------------------*/
if (millis() - tsLastReport > REPORTING_PERIOD_MS)
{
/*-------------------- Blynk --------------------*/
Blynk.virtualWrite(V7, BPM);
Blynk.virtualWrite(V8, SpO2);
/*-------------------- OLED --------------------*/
display.clearDisplay();
display.setCursor(28, 0);
display.println(F("Project Hub"));
display.print(" HBPM: ");
display.println(pox.getHeartRate());
display.print(" SpO2: ");
display.println(pox.getSpO2());
display.print(" Temp: ");
display.println(TEMP);
display.display();
tsLastReport = millis();
}
if (pinValue)
{
sensors.requestTemperatures();
TEMP = sensors.getTempCByIndex(0);
TEMP = DallasTemperature::toFahrenheit(TEMP);
pinValue = 0;
/*-------------------- Blynk --------------------*/
Blynk.virtualWrite(V6, TEMP);
/*-------------------- OLED --------------------*/
display.clearDisplay();
display.setCursor(28, 0);
display.println(F("Project Hub"));
display.println("");
display.println("");
display.print(" Temp: ");
display.println(TEMP);
display.display();
goto Jump;
}
}
}
view raw Pulse-Oximeter hosted with ❤ by GitHub

Video:
Watch the video for a better understanding.


Reference:

[1] Sarkar, S., Ghosh, A., Chakraborty, M., & Mondal, A. (2024). Design, Hardware Implementation of a Domestic Pulse Oximeter Using IOT for COVID – 19 Patient. International Journal of Microsystems and Iot, 2(1), 469–475. https://doi.org/10.5281/zenodo.10629635

No comments:

Post a Comment