Hackster is hosting Hackster Holidays, Ep. 6: Livestream & Giveaway Drawing. Watch previous episodes or stream live on Monday!Stream Hackster Holidays, Ep. 6 on Monday!
Naman Singhal
Created September 5, 2024

IoT-Based Heart Monitoring System for Mobility disabled.

This IoT heart monitoring system uses ECG signals to detect heart conditions, ensuring timely alerts for mobility-impaired patients.

32
IoT-Based Heart Monitoring System for Mobility disabled.

Things used in this project

Story

Read more

Code

IoT-Based Heart Monitoring System for Mobility Impaired Patients

C/C++
Libraries: The code uses the ESP8266WiFi library for WiFi connectivity and LiquidCrystal_I2C for controlling the LCD display.
WiFi Setup: The connectWiFi function connects the device to the specified WiFi network.
ECG Reading: The loop continuously reads the ECG signal from the specified pin. It displays the ECG value on the LCD.
Abnormality Check: If the ECG value is outside the normal range (example thresholds given), an alert is sent (you would need to implement the actual sending logic).
User Interface: The LCD shows whether the ECG is normal or if an alert has been sent.
#include <ESP8266WiFi.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>

// WiFi credentials
const char* ssid = "your_SSID";
const char* password = "your_PASSWORD";

// Define the ECG sensor pin
const int ecgPin = A0;

// LCD setup
LiquidCrystal_I2C lcd(0x27, 16, 2);

// Function to connect to WiFi
void connectWiFi() {
  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
  }
}

// Function to send alert
void sendAlert(String message) {
  // Implement your alert sending logic here (e.g., HTTP POST request to a server)
}

void setup() {
  Serial.begin(115200);
  lcd.begin();
  connectWiFi();
  lcd.print("Connected to WiFi");
  delay(2000);
  lcd.clear();
}

void loop() {
  int ecgValue = analogRead(ecgPin);
  lcd.setCursor(0, 0);
  lcd.print("ECG Value: ");
  lcd.print(ecgValue);
  
  // Check for abnormal ECG values
  if (ecgValue < 300 || ecgValue > 700) { // Example threshold values
    sendAlert("Abnormal ECG detected!");
    lcd.setCursor(0, 1);
    lcd.print("Alert Sent!");
  } else {
    lcd.setCursor(0, 1);
    lcd.print("Normal ECG   ");
  }
  
  delay(1000); // Read every second
}

Credits

Naman Singhal

Naman Singhal

1 project • 0 followers

Comments