Created
December 5, 2023 18:14
-
-
Save Ajak58a/cd11e14e1ade62075aad6c24ee980e76 to your computer and use it in GitHub Desktop.
Portable Health monitor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <Wire.h> | |
#include <Adafruit_GFX.h> | |
#include <Adafruit_SSD1306.h> | |
#include <MAX30100_PulseOximeter.h> | |
#include <Adafruit_MLX90614.h> | |
#define ECG_PIN A0 | |
#define SCREEN_WIDTH 128 | |
#define SCREEN_HEIGHT 64 | |
#define SCREEN_ADDRESS 0x3C | |
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, -1); | |
PulseOximeter pox; | |
Adafruit_MLX90614 mlx = Adafruit_MLX90614(); | |
void setup() { | |
Serial.begin(115200); | |
if(!display.begin(SSD1306_I2C_ADDRESS, SCREEN_ADDRESS)) { | |
Serial.println(F("SSD1306 allocation failed")); | |
for(;;); | |
} | |
display.display(); | |
delay(2000); | |
display.clearDisplay(); | |
Serial.println("MLX90614 test"); | |
mlx.begin(); | |
pox.begin(); | |
pox.setIRLedCurrent(MAX30100_LED_CURR_7_6MA); | |
} | |
void loop() { | |
float temperature = mlx.readObjectTempC(); | |
Serial.print("Temperature: "); | |
Serial.print(temperature); | |
Serial.println(" °C"); | |
int heartRate = pox.getHeartRate(); | |
Serial.print("Heart rate: "); | |
Serial.print(heartRate); | |
Serial.println(" bpm"); | |
int oxygen = pox.getSpO2(); | |
Serial.print("Blood oxygen: "); | |
Serial.print(oxygen); | |
Serial.println(" %"); | |
// Read ECG value | |
int ecgValue = analogRead(ECG_PIN); | |
Serial.print("ECG Value: "); | |
Serial.println(ecgValue); | |
display.clearDisplay(); | |
display.setTextSize(2); | |
display.setTextColor(SSD1306_WHITE); | |
display.setCursor(0, 0); | |
display.print("Temp: "); | |
display.print(temperature); | |
display.println(" C"); | |
display.print("HR: "); | |
display.print(heartRate); | |
display.println(" bpm"); | |
display.print("SpO2: "); | |
display.print(oxygen); | |
display.println(" %"); | |
display.print("ECG: "); | |
display.println(ecgValue); | |
display.display(); | |
delay(1000); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment