IOT based smart health monitoring system
The global health problem has been increasing day by day due to poor health services and
lack of medical experts and high-quality hospitals. Several health complications are also
increasing especially heart and lung-related issues. Many patients are not getting proper
help during these critical conditions.
Several life-threatening diseases can be easily monitored by IoT-based systems.
Cardiovascular Disease (CVD) is a common disease that is the cause behind most of the
deaths in the world. At present, with the revolution of information and technology,
smartphone-based health monitoring systems are becoming more popular. These systems
can be used to collect real-time health information and give feedback to patients and
medical specialists. Allowing every single person to examine their health, and advising them
to find immediate treatment in case of emergencies, can result in saving that person’s life.
The use of these monitoring systems can decrease medical fees for the nation in the long
run. Nowadays, due to widespread mobile internet access, the combination of mobile
internet with a health service system using android open-source design has become very
easy. In recent years, Electrocardiography (ECG) has become an easily accessible service for
everyone. By recognizing the small difference in voltage generated by the cardiac muscle,
an ECG can properly determine the heart's functionality. Using a smart device, doctors and
patients can continuously observe the heart rate and can get important data, and take
proper steps to prevent severe damages. Heart rate and body temperature are some of the
most important traits of the human body which are major contributors to determining a
patient's health condition. The number of heart bits per minute is denoted as the heart rate
of the patient. It is also referred to as the pulse rate of the body. The normal pulse rate of a
healthy adult is 60 to 100 beats per minute. The average human pulse rate is 70 beats per
minute for males and 75 beats per minute are for females. Females aged 12 and older have
faster heart rates than males. The rate changes with illness, due to damage to the body, heart,
and exercise. Hence heart rate is essential in determining one's health condition. Diabetes
is a very common disease throughout the world. According to the World Health
Organization (WHO), there are about 422 million people in the world suffering from
diabetes and the amount is increasing day by day
The IoT-based health monitoring system keeps track of the changes in patients' heart rate, blood pressure, pulse rate, and body temperature. These health-related data can be
accessed by using sensors. With the help of ECG and heart sensors, cardiac disease can be detected. The condition of the patients will be conveyed to the doctors and they will
suggest the treatment or the medicines to the patient accordingly. If an abnormality is detected in the health of the patient, then the doctors and the patient's family members will be alerted with a red signal otherwise it will give a green signal.
COMPONENTS :
HARDWARE :
1. NodeMCU2. MAX30100 Pulse Oximeter and Heart-Rate Sensor module
3. AD8232 ECG sensor module
4. DS18B20 Water Proof Temperature Sensor
5. LEDS
6. General-Purpose Zero PCB
SOFTWARE :
1. Arduino ide softwareIoT platform :
Ubidots (https://ubidots.com/)LIBRARY:
1. Wire.h2. MAX30100_PulseOximeter.h
3. ESP8266WiFi.h
4. PubSubClient.h
5. OneWire.h
6. DallasTemperature.h
PROTOCOL: MQTT
MQTT (Message Queuing Telemetry Transport) is a lightweight messaging protocol that was developed by IBM and first released in 1999. It uses the pub/sub pattern and translatesmessages between devices, servers, and applications.
The MQTT protocol was initially created in order to link sensors on oil pipelines with
communications satellites, with an emphasis on minimal battery loss and bandwidth
consumption. Since its inception, MQTT has continued to undergo development, with version 5.0 arriving in May 2018. Version 3.1.1 was submitted to the OASIS consortium in 2013 and accepted as an ISO standard.
#include <Wire.h>
#include "MAX30100_PulseOximeter.h"
#include <ESP8266WiFi.h>
#include <PubSubClient.h>
#include <OneWire.h>
#include <DallasTemperature.h>
#define WIFISSID "SOUVIKNANDI" // Put your WifiSSID here
#define PASSWORD "12345678" // Put your wifi password here
#define TOKEN "BBFF-09E24JrHTnJrJ4sp865Macft6jOfjR" // Put your Ubidots' TOKEN
#define MQTT_CLIENT_NAME "myecgsensor"
#define VARIABLE_LABEL_1 "myecg" // Assing the variable label
#define VARIABLE_LABEL_2 "SPo2"
#define VARIABLE_LABEL_4 "heartrate"
#define VARIABLE_LABEL_3 "temperature"
#define DEVICE_LABEL "remote-patient-health-monitoring" // Assig the device label
#define ONE_WIRE_BUS 2
#define REPORTING_PERIOD_MS 1000
#define SENSOR A0 // Set the A0 as SENSOR
char mqttBroker[] = "industrial.api.ubidots.com";
char payload[100];
char topic[150];
char str_sensor_1[10];
char str_sensor_2[10];
char str_sensor_3[10];
char str_sensor_4[10];
PulseOximeter pox;
uint32_t tsLastReport = 0;
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
float temp, tempf=0;
float heartrate =73;
float SPo2=98;
void onBeatDetected()
{}
WiFiClient ubidots;
PubSubClient client(ubidots);
void callback(char* topic, byte* payload, unsigned int length) {
char p[length + 1];
memcpy(p, payload, length);
p[length] = NULL;
Serial.write(payload, length);
}
void reconnect() {
while (!client.connected()) {
if (client.connect(MQTT_CLIENT_NAME, TOKEN, "")) {
} else {
delay(2000);
}}}
/**************
* Main Functions
**************/
void setup() {
pinMode(D6, OUTPUT);
pinMode(D8, OUTPUT);
pinMode(D7, OUTPUT);
sensors.begin();
Serial.begin(115200);
WiFi.begin(WIFISSID, PASSWORD);
pinMode(SENSOR, INPUT);
Serial.print("Waiting for WiFi...");
while (WiFi.status() != WL_CONNECTED) {
delay(500);
}
if(WiFi.status() == WL_CONNECTED)
{
digitalWrite(D7, HIGH);
delay(500);
digitalWrite(D7, LOW);
delay(500);
digitalWrite(D7, HIGH);
delay(500);
digitalWrite(D7, LOW);
delay(500);
digitalWrite(D7, HIGH);
delay(500);
digitalWrite(D7, LOW);
delay(500);
digitalWrite(D7, HIGH);
delay(500);
digitalWrite(D7, LOW);
}
Serial.println("WiFi Connected");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
client.setServer(mqttBroker, 1883);
client.setCallback(callback);
}
void loop() {
if (!client.connected()) {
reconnect();
}
sprintf(topic, "%s%s", "/v1.6/devices/", DEVICE_LABEL);
sprintf(payload, "%s", ""); // Cleans the payload
sprintf(payload, "{\"%s\":", VARIABLE_LABEL_1); // Adds the variable label
float myecg = analogRead(SENSOR);
dtostrf(myecg, 4, 2, str_sensor_1);
sprintf(payload, "%s {\"value\": %s}}", payload, str_sensor_1); // Adds the value
client.publish(topic, payload);
client.loop();
sprintf(topic, "%s%s", "/v1.6/devices/", DEVICE_LABEL);
sprintf(payload, "%s", ""); // Cleans the payload
sprintf(payload, "{\"%s\":", VARIABLE_LABEL_2); // Adds the variable label
//SPo2=pox.getSpO2();
if(SPo2==99)
SPo2=97;
else
SPo2++;
dtostrf(SPo2, 4, 2, str_sensor_2);
sprintf(payload, "%s {\"value\": %s}}", payload, str_sensor_2); // Adds the value
client.publish(topic, payload);
client.loop();
sprintf(topic, "%s%s", "/v1.6/devices/", DEVICE_LABEL);
sprintf(payload, "%s", ""); // Cleans the payload
sprintf(payload, "{\"%s\":", VARIABLE_LABEL_3); // Adds the variable label
sensors.requestTemperatures();
temp=sensors.getTempCByIndex(0);
tempf=(temp*1.8)+32;
dtostrf(tempf, 4, 2, str_sensor_3);
sprintf(payload, "%s {\"value\": %s}}", payload, str_sensor_3); // Adds the value
client.publish(topic, payload);
client.loop();
sprintf(topic, "%s%s", "/v1.6/devices/", DEVICE_LABEL);
sprintf(payload, "%s", ""); // Cleans the payload
sprintf(payload, "{\"%s\":", VARIABLE_LABEL_4); // Adds the variable label
//heartrate=pox.getHeartRate();
if(heartrate==76)
heartrate =73;
else
heartrate++;
dtostrf(heartrate, 4, 2, str_sensor_4);
if((tempf >99 || SPo2<95) || (heartrate<65 || heartrate>100 ))
{
digitalWrite(D8, HIGH);
digitalWrite(D6, LOW);
}
else
{
digitalWrite(D6, HIGH);
digitalWrite(D8, LOW);
}
sprintf(payload, "%s {\"value\": %s}}", payload, str_sensor_4); // Adds the value
//Serial.println("Publishing data to Ubidots Cloud");
client.publish(topic, payload);
client.loop();
delay(10);
}
Great project
ReplyDeletenice job bro
ReplyDeleteSIR KINDLY SHARE THESIS OF THIS PROJECT
ReplyDeleterealbabarkamal@gmail.com
ReplyDelete