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

ESP8266-Based Health Monitoring System with MAX30102 and LM35 Sensors

View and Edit Project In Cirkit DesignerImage of ESP8266-Based Health Monitoring System with MAX30102 and LM35 Sensors

Circuit Documentation

Summary

This circuit is a Patient Health Monitoring System that reads temperature data from an LM35 sensor and heart rate and SpO2 data from a MAX30102 sensor. The data is displayed on a 16x2 I2C LCD and sent to the Blynk app for remote monitoring. The system is controlled by an ESP8266 NodeMCU microcontroller.

Component List

MAX30102 Heart Rate and Oxygen Sensor

ESP8266 NodeMCU

16x2 I2C LCD

Temperature Sensor (LM35)

Wiring Details

MAX30102 Heart Rate and Oxygen Sensor

ESP8266 NodeMCU

16x2 I2C LCD

Temperature Sensor (LM35)

Documented Code

ESP8266 NodeMCU Code

void setup() {
  // put your setup code here, to run once:

}

void loop() {
  // put your main code here, to run repeatedly:

}

16x2 I2C LCD Code

void setup() {
  // put your setup code here, to run once:

}

void loop() {
  // put your main code here, to run repeatedly:

}

Patient Health Monitoring System Code

/*
 * Patient Health Monitoring System
 * This code reads temperature data from the LM35 sensor and heart rate and 
 * SpO2 data from the MAX30102 sensor. It displays the data on a 16x2 I2C LCD 
 * and sends it to the Blynk app for remote monitoring.
 */

#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_MAX30105.h>
#include <BlynkSimpleEsp8266.h>

// Blynk authentication token
char auth[] = "YourAuthToken";

// Define the pin for the LM35 temperature sensor
const int tempSensorPin = A0;

// Initialize the MAX30102 sensor
Adafruit_MAX30105 max30102;

// Initialize the I2C LCD (address 0x27, 16 columns, 2 rows)
LiquidCrystal_I2C lcd(0x27, 16, 2);

void setup() {
  // Initialize serial communication at 9600 baud rate
  Serial.begin(9600);

  // Initialize Blynk
  Blynk.begin(auth, "YourSSID", "YourPassword");

  // Initialize the MAX30102 sensor
  if (!max30102.begin(Wire, I2C_SPEED_FAST)) {
    Serial.println("MAX30102 not found. Please check wiring.");
    while (1);
  }

  // Initialize the I2C LCD
  lcd.begin();
  lcd.backlight();

  // Print initial message to LCD
  lcd.setCursor(0, 0);
  lcd.print("Health Monitor");
  lcd.setCursor(0, 1);
  lcd.print("Initializing...");
  delay(2000);
}

void loop() {
  // Read the analog value from the temperature sensor
  int sensorValue = analogRead(tempSensorPin);
  // Convert the analog value to temperature in Celsius
  float temperature = (sensorValue * 5.0 * 100.0) / 1024.0;

  // Read heart rate and SpO2 data from the MAX30102 sensor
  uint32_t irValue = max30102.getIR();
  uint32_t redValue = max30102.getRed();

  // Print the temperature value to the serial monitor
  Serial.print("Temperature: ");
  Serial.print(temperature);
  Serial.println(" °C");

  // Print heart rate and SpO2 data to the serial monitor
  Serial.print("IR: ");
  Serial.print(irValue);
  Serial.print(" Red: ");
  Serial.println(redValue);

  // Display the data on the I2C LCD
  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("Temp: ");
  lcd.print(temperature);
  lcd.print(" C");
  lcd.setCursor(0, 1);
  lcd.print("HR: ");
  lcd.print(irValue);
  lcd.print(" SpO2: ");
  lcd.print(redValue);

  // Send the data to the Blynk app
  Blynk.virtualWrite(V1, temperature);
  Blynk.virtualWrite(V2, irValue);
  Blynk.virtualWrite(V3, redValue);

  // Run Blynk
  Blynk.run();

  // Wait for 1 second before taking another reading
  delay(1000);
}