ESP32-Based Health Monitoring System with MAX30100 and MLX90614 Sensors
View and Edit Project In Cirkit Designer
Circuit Documentation
Summary
This document provides a detailed overview of a circuit that includes an ESP32 microcontroller, various sensors (MAX30100, MLX90614), an OLED display, and an I2C module. The circuit is designed to measure heart rate, oxygen saturation, and temperature, and display the results on an OLED screen.
Component List
ESP32 (30 pin)
- Description: A powerful microcontroller with built-in Wi-Fi and Bluetooth capabilities.
- Pins: EN, VP, VN, D34, D35, D32, D33, D25, D26, D27, D14, D12, D13, GND, Vin, D23, D22, TX0, RX0, D21, D19, D18, D5, TX2, RX2, D4, D2, D15, 3V3
MAX30100
- Description: A pulse oximeter and heart-rate sensor.
- Pins: Vin, gnd, scl, sda, int
MLX90614
- Description: An infrared thermometer for non-contact temperature measurements.
- Pins: SDA, SCL, GND, VIN
OLED Display 2.42"
- Description: A 2.42-inch OLED display for visual output.
- Pins: GND, VCC, SCK, SDA, RES, DC, CS
I2C Module
- Description: A module to facilitate I2C communication.
- Pins: SCL, SDA, VCC, GND
Adafruit Perma Proto for Pi Full Size
- Description: A prototyping board for easy connections.
- Pins: Multiple pins including 3.3V, 5.0V, SDA, SCL, GND, and various GPIO pins.
Resistor (4700 Ohms)
- Description: A resistor with a resistance of 4700 Ohms.
- Pins: pin1, pin2
OLED Display 128x32
- Description: A smaller OLED display with a resolution of 128x32 pixels.
- Pins: SDA, SCL, VCC, GND
Wiring Details
ESP32 (30 pin)
- D22 connected to Adafruit Perma Proto for Pi Full Size at N$140
- D21 connected to Adafruit Perma Proto for Pi Full Size at N$145
- GND connected to Adafruit Perma Proto for Pi Full Size at GNDSTRIP1
- 3V3 connected to Adafruit Perma Proto for Pi Full Size at PWRSTRIP1
MAX30100
- Vin connected to Adafruit Perma Proto for Pi Full Size at PWRSTRIP1
- gnd connected to Adafruit Perma Proto for Pi Full Size at GNDSTRIP1
- scl connected to Adafruit Perma Proto for Pi Full Size at N$140
- sda connected to Adafruit Perma Proto for Pi Full Size at N$145
MLX90614
- SDA connected to Adafruit Perma Proto for Pi Full Size at N$119
- SCL connected to Adafruit Perma Proto for Pi Full Size at N$140
- GND connected to Adafruit Perma Proto for Pi Full Size at GNDSTRIP1
- VIN connected to Adafruit Perma Proto for Pi Full Size at PWRSTRIP1
OLED Display 2.42"
- GND connected to Adafruit Perma Proto for Pi Full Size at GNDSTRIP1
- VCC connected to Adafruit Perma Proto for Pi Full Size at PWRSTRIP1
- SCK connected to Adafruit Perma Proto for Pi Full Size at N$140
- SDA connected to Adafruit Perma Proto for Pi Full Size at N$145
I2C Module
- SCL connected to Adafruit Perma Proto for Pi Full Size at N$126
- SDA connected to Adafruit Perma Proto for Pi Full Size at N$145
- VCC connected to Adafruit Perma Proto for Pi Full Size at PWRSTRIP1
- GND connected to Adafruit Perma Proto for Pi Full Size at GNDSTRIP1
Resistor (4700 Ohms)
- pin2 connected to Adafruit Perma Proto for Pi Full Size at N$119
- pin1 connected to Adafruit Perma Proto for Pi Full Size at N$151
OLED Display 128x32
- SDA connected to Adafruit Perma Proto for Pi Full Size at N$145
- SCL connected to Adafruit Perma Proto for Pi Full Size at N$126
- VCC connected to Adafruit Perma Proto for Pi Full Size at PWRSTRIP1
- GND connected to Adafruit Perma Proto for Pi Full Size at GNDSTRIP1
Documented Code
ESP32 Code
#include <Wire.h>
#include "MAX30100_PulseOximeter.h"
#include <Adafruit_MLX90614.h>
#include <Adafruit_SSD1306.h>
#include <Adafruit_GFX.h> // مكتبة الرسومات العامة
#define SCREEN_WIDTH 128 // عرض الشاشة
#define SCREEN_HEIGHT 64 // ارتفاع الشاشة (قد يختلف حسب الطراز الخاص بك)
#define OLED_RESET -1 // لا حاجة إلى إعادة تعيين شاشة OLED
#define I2C_SDA 21 // Pin for SDA
#define I2C_SCL 22 // Pin for SCL
#define REPORTING_PERIOD_MS 1000
Adafruit_MLX90614 mlx = Adafruit_MLX90614(); // تعريف مستشعر درجة الحرارة
PulseOximeter pox; // تعريف مستشعر الأوكسجين
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET); // تعريف شاشة OLED
float heartRate = 0.0;
float oxygenSaturation = 0.0;
uint32_t tsLastReport = 0;
void setup() {
Serial.begin(115200); // Start Serial communication at 115200 baud rate
Wire.begin(I2C_SDA, I2C_SCL); // Initialize I2C with specified SDA and SCL pins
mlx.begin(); // Initialize the MLX90614 sensor
pox.begin(); // Initialize the MAX30100 sensor
delay(2000); // Allow sensors to initialize
// إعداد شاشة OLED
if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { // التأكد من وجود اتصال مع الشاشة
Serial.println(F("Failed to initialize OLED display"));
while (true);
}
display.display(); // عرض أولي
delay(2000); // إظهار الشاشة لمدة 2 ثانية
display.clearDisplay(); // مسح الشاشة
}
void loop() {
// قراءة درجة الحرارة من جهاز MLX90614 (درجة حرارة الكائن)
float temperature = mlx.readObjectTempC();
// تحديث بيانات جهاز قياس الأوكسجين (MAX30100)
pox.update(); // تحديث القياسات من جهاز قياس الأوكسجين
if (pox.getHeartRate() > 0) {
heartRate = pox.getHeartRate();
}
if (pox.getSpO2() > 0) {
oxygenSaturation = pox.getSpO2();
}
// طباعة البيانات على المونيتور التسلسلي
if (millis() - tsLastReport > REPORTING_PERIOD_MS) {
Serial.print("Heart Rate: ");
Serial.print(heartRate);
Serial.print(" bpm, SpO2: ");
Serial.print(oxygenSaturation);
Serial.print(" %, Temperature: ");
Serial.print(temperature);
Serial.println(" C");
// عرض البيانات على شاشة OLED
display.clearDisplay(); // مسح الشاشة قبل طباعة البيانات الجديدة
display.setCursor(0, 0); // وضع المؤشر في أعلى الشاشة
display.print("HR: ");
display.print(heartRate);
display.print(" bpm");
display.setCursor(0, 16); // الانتقال إلى السطر الثاني
display.print("SpO2: ");
display.print(oxygenSaturation);
display.print("%");
display.setCursor(0, 32); // الانتقال إلى السطر الثالث
display.print("Temp: ");
display.print(temperature);
display.print(" C");
display.display(); // تحديث العرض
tsLastReport = millis();
}