Arduino Projects

IoT Cardiovascular Disease Detection and Prevention Project

Vascular Disease Detection and Prevention Project: The flow chart diagram

In today’s blog post, we will discussing how to design and construct a cardiovascular disease detection and prevention project. This project work uses some inexpensive modules to device an non-invasive technique to take body temperature readings, Electrocardiograph (ECG), pulse rate reading, and blood glucose reading, Cholesterol level and blood pressure.

To design a non-invasive technique to detect and prevent these cardiovascular disease we needed to make sure we can read these health parameters effectively. As always said in science, we go from the known to the unknown.

Introduction

cardiovascular Disease types

Cardiovascular diseases (CVDs) remain a leading cause of death globally, emphasizing the need for effective detection and prevention methods. Traditional monitoring systems, often invasive, can be uncomfortable and impractical for continuous monitoring. The advent of IoT (Internet of Things) and advancements in non-invasive technology have opened new avenues for real-time cardiovascular health monitoring. This blog post explores an exciting project that combines Arduino with non-invasive techniques to detect and prevent cardiovascular diseases

In the digital age, health monitoring has evolved significantly, thanks to innovations in technology. Non-invasive monitoring techniques are at the forefront, offering a painless and convenient way to track vital signs. This blog post delves into an IoT-based project using Arduino, focusing on non-invasive detection of cardiovascular diseases. This system aims to provide real-time data on heart health, enabling early diagnosis and timely intervention.

Understanding the Basics

Non-Invasive Monitoring

Non-Invasive Glucose and ECG levels Monitoring using Arduino: An ECG sensor for pregnancy

Non-invasive monitoring refers to techniques that do not require penetration of the skin or body cavities. These methods are less painful, reduce the risk of infection, and are generally more comfortable for continuous monitoring.

Cardiovascular Disease Monitoring

Cardiovascular diseases encompass a range of conditions affecting the heart and blood vessels, including hypertension, heart attacks, and strokes. Early detection and continuous monitoring are crucial for effective management and prevention.

IoT Cardiovascular Disease and Prevention Project: Components Needed

The Development Boards

Arduino Uno and NodeMCU development board

For this project, an Arduino Uno and a NodeMCU board. This choice was ideal due to its ease of use and extensive support community. Most of our sensors were DIY (Do-It-yourself) inexpensive sensor modules. Whereas, the ones we couldn’t get due to cost, we fabricated it using the techniques required for it.

Sensors

  • ECG Sensor (AD8232): To monitor the heart’s electrical activity.
  • Pulse Sensor: To detect heart rate by measuring pulse waves.
  • Temperature Sensor (DS18B20 waterproof type): To monitor body temperature, a vital sign in heart disease diagnosis.
  • Photo Diode sensor: to detect the lights off the human specimen body.

Additional Components

ITEM DESCRIPTIONQUANTITY
NodeMCU1
JUMPER WIRES2 SETS
RESISTORS6
ARDUINO UNO1
CASING1
VERO BOARD1
ECG SENSOR MODULE1
SOLDER1
CUSTOM CHOLESTEROL MODULE1
2004 LCD MODULE1
LiPo BATTERY CHARGER1
LiPo BATTERY2
LED1
DS18B20 TEMPERATURE SENSOR1
GLUE GUN1
FEMALE HEADERPIN2
RED SWITCH1
MISCELLANEOUS

The table above shows the rest of the components and modules needed for this project design. The bill of materials talked about a custom cholesterol level detection module. This was designed by applying the Beer-Lambert technique using optical method of Infrared radiation and light absorption technology. You can read more here Non-Invasive Glucose and ECG levels Monitoring Arduino.

How the Sensors Work

Non-Invasive ECG Sensor

Cardiovascular disease detection and prevention: The ECG sensor module

The ECG sensor captures the electrical signals generated by the heart. It detects the PQRST waves, representing different phases of the cardiac cycle. These signals are crucial for diagnosing heart conditions.

Non-Invasive ECG levels Monitoring using Arduino: An ECG sensor module

This module made it very possible for us to read the electrocardiogram using the non-invasive approach for a very reduced cost implications. The sensor worked very well with the Arduino Uno board that was available for programming the sensor module itself.

Non-Invasive Pulse Sensor

Cardiovascular disease detection and prevention: The pulse sensor module

The pulse sensor detects blood flow through the arteries, providing real-time heart rate data. It uses an LED and photodiode to measure the pulse by detecting changes in light intensity caused by blood flow.

This module uses an oximeter to measure the pulse of the person’s pulse rate. The sensor measures the rate of oxygenated blood that flows through the fingers where the infrared sensor is placed. This is because the blood flow casts a shadow each time, the hearts pumps blood through the body.

Non-Invasive Temperature Sensor

Temperature sensors help monitor body temperature, a critical parameter in diagnosing heart-related conditions like fever or infection-induced heart strain. We used the DS18B20 temperature sensor, the waterproof type to take the precise body temperature. The temperature sensor is a factor that we need that is related to the glucose measurement.

Non-Invasive Glucose Sensor

The glucose sensor circuit diagram design

The Glucose level of the was measured using the technique adopted by schematic diagram shown above. The setup diagram was drawn on fritzing IDE, the breadboard version. Here we used the types of LED for the design and  a photocell to represent the emitters of different spectrum of light needed and the sensor that would detect the reflected light through the human skin respectively. According to Beer-Lambert’s law.

The Beer-Lambert’s Law expression

According to the Beer-Lambert’s law, as infrared light passes through the material, the intensity of light exponentially decays because it is absorbed by molecules of material. Thus based on Beer-Lambert’s law, a single wavelength is selected for glucose concentration evaluation and by using absorption theory glucose level is predicted.

Non-Invasive Cholesterol Sensor

The Cholesterol sensor configuration

To measure the cholesterol level, the laser and the photocell was added to the circuit as shown in fig 4.15 above. Using the methodology stated above, We used the Arduino code snippet to determine the cholesterol level.

Non-Invasive Blood Pressure Sensor

The Blood pressure chart

To design the blood pressure for the person using a non-invasive method, We adopted the approach presented in this paper that shows the relationship between Electrocardiographic changes and blood pressure. According to the publication,  Elevated blood pressure induces electrocardiographic changes and is associated with an increase in cardiovascular disease later in life compared to normal blood pressure levels.

A library DFRobot_ECG was created that made life easier. It allowed us to use the temperature readings and call some function that would produce the BP based on the calculations and formula shown in chapter 3.  We converted the read ECG valued to BP by calling these functions and also summing the SBP and DBP together and dividing by 3 as shown in code line 43.

You May Also Like…

Circuit Design and Connections

Cardiovascular disease detection and prevention: The circuit diagram design

Explanation of Wiring Diagram

  1. ECG Sensor: Connect the sensor’s output pin to Arduino analog pin A0. Connect the ground to GND and VCC to 5V.
  2. Pulse Sensor: Connect the pulse sensor’s signal pin to analog pin A1. Connect the ground to GND and VCC to 5V.
  3. Temperature Sensor: Connect the DS18B20 sensor’s output pin to analog pin D2. Connect VCC to 5V and ground to GND.

Assembly Steps

Cardiovascular disease detection and prevention: The circuit diagram design
  1. Connect all sensors to the Arduino using the breadboard and jumper wires.
  2. Ensure proper grounding and power supply connections.
  3. Connect the Wi-Fi module to the Arduino (using the appropriate pins for TX/RX communication).

Programming the Arduino

#include <EEPROM.h>
#include <SoftwareSerial.h>
#include <DallasTemperature.h>
#include <OneWire.h>
#include <LiquidCrystal.h>

SoftwareSerial mySerial(2, 3); // RX, TX
int sensor[] = {};

//4 pin of uno
#define ONE_WIRE_BUS 4                          

OneWire oneWire(ONE_WIRE_BUS);
 
DallasTemperature sensors(&oneWire);            // Pass the oneWire reference to Dallas Temperature.

LiquidCrystal lcd(12, 11, 10, 9, 8, 7);

#define greenLED  13
#define redLED  A4
#define blueLED A5

long randNumber;

float temp, bp, chloe1, chloe2, totalChlr;
int ecg1, ecg, pulseRate, glocoseSensor; //chekRandNumber; 
 int changeTemp;


void generate(){
  randNumber = random(5, 10);
  Serial.println(randNumber);
 EEPROM.write(0, randNumber);
}

void setup(void){
  Serial.begin(115200); 
  while (!Serial) { ; }
  // set the data rate for the SoftwareSerial port
  mySerial.begin(115200);
  //mySerial.println("Hello, world?");
  sensors.begin();
  lcd.begin(20,4);
  //define the pins for ECG sensor
  pinMode(6, INPUT); // Setup for leads off detection LO +
  pinMode(5, INPUT); // Setup for leads off detection LO -

  //the LEDs
  pinMode(greenLED, OUTPUT);
  pinMode(redLED, OUTPUT);
  pinMode(blueLED, OUTPUT);

  //print a welcome message
  lcd.setCursor(0, 0);
  lcd.print("      WELCOME   ");
  lcd.setCursor(0, 1);
  lcd.print("  Mr. Ameh Solomon");
  for(int x=0; x<19; x++){
   lcd.setCursor(x,2);
  lcd.print("*");
  delay(200);
  }
  for(int x=0; x<19; x++){
   lcd.setCursor(x,3);
  lcd.print("*");
  delay(200);
  }
  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print(" IoT Based Vascular");
  lcd.setCursor(0,1);
  lcd.print("   Blood Disease");
  lcd.setCursor(0,2);
  lcd.print("   Prevention And");
  lcd.setCursor(0, 3);
  lcd.print(" Detection Project");
  delay(4000);
  lcd.setCursor(0,0);
  lcd.print("Prepping Sensors");
  for(int x=16; x<19; x++){
   lcd.setCursor(x,0);
  lcd.print("*");
  delay(200);
  }
  for(int x=0; x<19; x++){
   lcd.setCursor(x,1);
  lcd.print("*");
  delay(200);
  }
  for(int x=0; x<19; x++){
   lcd.setCursor(x,2);
  lcd.print("*");
  delay(200);
  }
  for(int x=0; x<19; x++){
   lcd.setCursor(x,3);
  lcd.print("*");
  delay(200);
  }
  lcd.clear();

  randomSeed(analogRead(A3));

  generate();
}



float bodyTemp(){
  // Send the command to get temperatures  
  sensors.requestTemperatures();                
  Serial.println("Temperature is: ");
  // Why "byIndex"? You can have more than one IC on the same bus. 0 refers to the first IC on the wire
  temp = sensors.getTempCByIndex(0);
  
  
  return temp;
 
}


int ecgSensor(){
   ecg1 = analogRead(A0);
  if((digitalRead(5) == 1)||(digitalRead(6) == 1)){
Serial.println('!');
}
else{
  return ecg1;
}
//Wait for a bit to keep serial data from saturating
delay(100);
}


To get the rest of this code, let us know by sending us a message

Programming the NodeMCU

 #include "ThingSpeak.h"
#include <ESP8266WiFi.h>
#include <SoftwareSerial.h>

SoftwareSerial nodeMCU(D1, D2);

char ssid[] = "AncII";   // your network SSID (name) 
char pass[] = "eureka26";   // your network password

int keyIndex = 0;            // your network key Index number (needed only for WEP)

WiFiClient  client;
 unsigned long myChannelNumber = 1685425;
const char * myWriteAPIKey = "IWGFF3L5SEHT38RB";

String myStatus = "field1 equals field2";

const int ledPin =  LED_BUILTIN;// the number of the LED pin

// Variables will change:
int ledState = LOW;             // ledState used to set the LED

// Generally, you should use "unsigned long" for variables that hold time
// The value will quickly become too large for an int to store
unsigned long previousMillis = 0;        // will store last time LED was updated

// constants won't change:
const long interval = 1000; 

char c;
String dataIn;
int8_t indexOfA, indexOfB,indexOfC,indexOfD,
       indexOfE,indexOfF,indexOfG,indexOfH; 

String data1, data2, data3, data4, data5, data6,
       data7, data8;


void setup() {
Serial.begin(115200);
nodeMCU.begin(115200);

pinMode(ledPin, OUTPUT);

WiFi.mode(WIFI_STA); 
  ThingSpeak.begin(client);  // Initialize ThingSpeak
}


void blinkLed(){
  unsigned long currentMillis = millis();

  if (currentMillis - previousMillis >= interval) {
    // save the last time you blinked the LED
    previousMillis = currentMillis;

    // if the LED is off turn it on and vice-versa:
    if (ledState == LOW) {
      ledState = HIGH;
    } else {
      ledState = LOW;
    }

    // set the LED with the ledState of the variable:
    digitalWrite(ledPin, ledState);
  }
}



void loop(){
while(nodeMCU.available() >0){
  c = nodeMCU.read();
 
   if( c == '\n'){
    break;
  }

  else{
    dataIn += c;
  }
}

if(c == '\n'){
  //Serial.println(c);
  parse_data();


  //thingspeak send
    if(WiFi.status() != WL_CONNECTED){
    Serial.print("Attempting to connect to SSID: ");
    Serial.println(ssid);
    while(WiFi.status() != WL_CONNECTED){
      WiFi.begin(ssid, pass);  // Connect to WPA/WPA2 network. Change this line if using open or WEP network
      Serial.print(".");
      delay(5000);
  } 
    Serial.println("\nConnected.");
  }

  else{
    blinkLed();
  }

  // set the fields with the values
  ThingSpeak.setField(1, data1);
  ThingSpeak.setField(2, data2);
  ThingSpeak.setField(3, data3);
  ThingSpeak.setField(4, data4);
  ThingSpeak.setField(5, data5);
  ThingSpeak.setField(6, data6);
  ThingSpeak.setField(7, data7);
  ThingSpeak.setField(8, data8);
 
  // figure out the status message
//  if(data1 > data2){
//    myStatus = String("field1 is greater than field2"); 
//  }
//  else if(data1 < data2){
//    myStatus = String("field1 is less than field2");
//  }
//  else{
//    myStatus = String("field1 equals field2");
//  }
//  
  // set the status
 ThingSpeak.setStatus(myStatus);
  
  // write to the ThingSpeak channel
  int x = ThingSpeak.writeFields(myChannelNumber, myWriteAPIKey);
  if(x == 200){
    Serial.println("Channel update successful.");
  }
  else{
    Serial.println("Problem updating channel. HTTP error code " + String(x));
  }
  
  // change the values
//  data1++;
//  if(data1 > 999){
//    data1 = 0;
//  }

    Serial.println("data 1= " + data1);
  Serial.println("data 2= " + data2);
  Serial.println("data 3= " + data3);
  Serial.println("data 4= " + data4);
  Serial.println("data 5= " + data5);
  Serial.println("data 6= " + data6);
  Serial.println("data 7= " + data7);
  Serial.println("data 8= " + data8);
  Serial.println("............................");
  
  delay(20000); // Wait 20 seconds to update the channel again
  
  c = 0;
  dataIn = "";
  }
  
}


void parse_data(){
  indexOfA = dataIn.indexOf("A");
  indexOfB = dataIn.indexOf("B");
  indexOfC = dataIn.indexOf("C");
  indexOfD = dataIn.indexOf("D");
  indexOfE = dataIn.indexOf("E");
  indexOfF = dataIn.indexOf("F");
  indexOfG = dataIn.indexOf("G");
  indexOfH = dataIn.indexOf("H");

  data1 = dataIn.substring(0, indexOfA);
  data2 = dataIn.substring(indexOfA+1, indexOfB);
  data3 = dataIn.substring(indexOfB+1, indexOfC);
  data4 = dataIn.substring(indexOfC+1, indexOfD);

  data5 = dataIn.substring(indexOfD+1, indexOfE);
  data6 = dataIn.substring(indexOfE+1, indexOfF);
  data7 = dataIn.substring(indexOfF+1, indexOfG);
  data8 = dataIn.substring(indexOfG+1, indexOfH);
  
}

Explanation of Source Code

This code connects an ESP8266 WiFi module (NodeMCU) to the internet and sends data to a website called ThingSpeak.

Here’s a breakdown of the functionality in 3 parts:

  1. Setup:
    • It first establishes serial communication for debugging messages and sets up the NodeMCU to communicate at a specific baud rate.
    • It configures a pin as an output to control an LED.
    • It connects the ESP8266 to your WiFi network using the provided credentials.
    • Finally, it initializes the ThingSpeak library to communicate with the ThingSpeak website.
  2. Main Loop:
    • This loop runs continuously.
    • It constantly checks for incoming data on the serial port from the NodeMCU.
    • If data is available, it reads it character by character until it encounters a newline character (“\n”).
    • Once a complete line is received, it calls the parse_data function to extract eight data values separated by specific characters (likely letters A to H).
    • It then checks the WiFi connection status. If not connected, it attempts to connect using the provided credentials. If connected, it blinks an LED and sends the extracted data to ThingSpeak using the ThingSpeak library functions.
    • After sending the data, it prints the received data values to the serial monitor for debugging purposes.
    • Finally, it delays for 20 seconds before repeating the loop.
  3. Data Parsing:
    • This function takes the received data string as input and searches for specific characters (A-H) within the string.
    • It uses the indexOf function to find the positions of these characters.
    • Based on these positions, it extracts eight substrings from the original data string using the substring function. These eight substrings are assigned to variables data1 to data8.

Data Processing and Display

Visualization

  • LCD Display: Shows real-time ECG, pulse, and temperature data.
  • It also measures and displays the ECG levels, as well as the Glucose levels
  • The LCD screen also displays the total Cholesterol level measured by the design.
  • Serial Monitor: We used the serial monitor and serial graph for debugging and data analysis.

IoT Integration

The thingspeak IoT platform display

We used the NodeMCU board to use its Wi-Fi capability to send data to a cloud server of thingspeak. This would allow us to view and monitor the reading remotely using HTTP protocol.

Calibration and Testing

testing the sensors

Sensor Calibration

We ensured the sensor is properly placed on the skin to get accurate readings. and we place the pulse sensor and glucose sensor on a fingertip for best results. Using the temperature sensor DS18B20, we didn’t need to much, its result was very closer to known clinical thermometer reading we had earlier.

Testing

Traditional glucose measurement
  • Initial Testing: Before we began this project, we had to take clinical reading of a person whom we termed Speciment A. We got the results of this test subject and got the Glucose, cholesterol, temperature, ECG, blood pressure data. And we were able to verify our own non-invasive readings on the LCD and Serial Monitor against these.
Cardiovascular disease detection and prevention design: Blood work samples for lab test
  • Field Testing: We tested the system in different environments to ensure reliability.

Challenges and Limitations

Accuracy and Noise

  • ECG Signal Quality: Noise and artifacts can interfere with ECG readings. Use filters and signal processing techniques to enhance signal quality.
  • Pulse Detection: Ensure the pulse sensor is correctly positioned to avoid false readings.

Conclusion

The IoT-based cardiovascular disease detection and prevention project using Arduino and non-invasive techniques is a groundbreaking approach to heart health monitoring. By leveraging modern technology, this system promises to enhance the early detection and prevention of cardiovascular diseases, making health monitoring more accessible and efficient. As technology continues to evolve, the integration of IoT and non-invasive techniques will undoubtedly play a pivotal role in transforming healthcare.

FAQs

  1. How accurate are non-invasive glucose sensors?
    • Non-invasive glucose sensors are continuously improving. While they are not yet as accurate as traditional methods, they offer significant convenience and comfort.
  2. Can I use any Arduino board for this project?
    • Yes, but Arduino Uno or Mega are recommended for their ease of use and extensive community support.
  3. What are the best sensors for beginners in this project?
    • The AD8232 ECG sensor and the Pulse Sensor are excellent choices for beginners due to their simplicity and reliability.
  4. How can I improve the accuracy of my ECG readings?
    • Use noise filters, proper electrode placement, and consider signal amplification to enhance the accuracy of ECG readings.
  5. What are the safety considerations when working with ECG sensors?
    • Ensure proper insulation and grounding to avoid electrical shock. Always follow safety guidelines when handling electrical components.

smartechlabs

Recent Posts

AI-Powered Soil Analysis for Precision Nutrient Management: Revolutionizing Agriculture

In the ever-evolving landscape of modern agriculture, artificial intelligence (AI) is emerging as a game-changing…

1 day ago

IoT Applications in Enhancing Manufacturing Flexibility

The Internet of Things (IoT) is reshaping the way we live, work, and produce goods.…

1 day ago

AI-Driven Process Optimization in Continuous Manufacturing

Introduction Have you ever wondered how some manufacturing industries consistently deliver high-quality products while minimizing…

1 day ago

Implementing IoT for Real-Time Monitoring of Livestock Feed Intake

In the ever-evolving landscape of modern agriculture, the integration of Internet of Things (IoT) technology…

1 day ago

Implementing IoT Solutions for Remote Equipment Diagnostics

Introduction Have you ever imagined diagnosing equipment issues without even being on-site? Welcome to the…

1 day ago

Leveraging AI for Inventory Management in Smart Manufacturing

In the ever-evolving world of manufacturing, staying competitive means adopting innovative solutions to optimize every…

1 day ago

This website uses cookies.