Vitals Monitor: Presented By: Mustafa Zia Haider Badr Abdul Latif Hisham 2Nd Stage (Evening Study) Dr. Omar Youssef
Vitals Monitor: Presented By: Mustafa Zia Haider Badr Abdul Latif Hisham 2Nd Stage (Evening Study) Dr. Omar Youssef
Vitals Monitor: Presented By: Mustafa Zia Haider Badr Abdul Latif Hisham 2Nd Stage (Evening Study) Dr. Omar Youssef
PRESENTED BY:
Mustafa Zia
Haider Badr
Abdul Latif Hisham
2ND STAGE (EVENING STUDY)
DR. OMAR
16 YOUSSEF
TABLE OF CONTENTS:
INTRODUCTION…………………………………………….2-5
FEATURES……………………………………………………….6
SUPPLIES…………………………………………………....…….7
ASSEMBLE ……………….…………………………………....8-12
Schematic ……………………………………12
PROGRAMING …………………………………….……….13-14
CONCLUSION……………………………………………….14-15
CODE……………………………………………….…………16-18
1
VITALS MONITOR
INTRODUCTION:
consumer interest over the past few years. Not only has this
at over $13.2 billion by the end of 2016 and its value is forecast
We all know that doctor first checks Heart Rate to know Heart
2
repeatability of the measured data. This mostly happens due to
per minute). Heart rate varies for different age groups. For a
3
rate is around 72 beats per minute (bpm). The functioning of
when the patient is at rest. Babies have a much higher rate than
adults around 120 bpm and older children have heart rate
around 90 bpm. If the heart rate is lower than the normal heart
4
thermocouples, thermistors, resistance temperature detectors
5
FEATURES:
• Battery-powered wearable
further analysis.
COVID-19.
6
SUPPLIES:
Hardware Needed:
• pulse sensor×1
• thermistor 10k×1
• Arduino IDE
• 3D Printer (generic)
7
ASSEMBLE:
vital signs measured, the heart rate (HR) calculation has been
8
undergone continuous improvements for decades to address
9
Since this device is a wearable this can help front line workers
who are doing day and night service to fight against COVID-
19.
Get the required parts we can change displays and sensor type
10
In order to wear a wearable gadget, it should be enclosed in a
and designed a case which can fit all my sensors and MCUs.
11
Now we need to connect all the required components, earlier I
had a plan of choosing ESP12E as MCU but since it has only one
With ESP one can directly send the data to the cloud may be a
Schematic
motor.
12
PROGRAMING:
13
an NTC type thermistor of 10kΩ is used. NTC of 10kΩ means
Future enhancements:
14
Conclusion:
best part of this device is, it is under 15$ which is a lot cheaper
15
CODE:
#include <math.h> if (Signal < thresh && N > (IBI / 5) * 3) { clearY();
#include <SPI.h> if (Signal < T) {T = Signal;}} pinMode(blinkPin, OUTPUT);
#include <Wire.h> if (Signal > thresh && Signal > P) { Serial.begin(115200);
#include <Adafruit_GFX.h> P = Signal;} interruptSetup();
#include <Adafruit_SSD1306.h> if (N > 250) { display.clearDisplay();
#define pulsePin A0 if ( (Signal > thresh) && (Pulse == false) display.setTextSize(2);
#define OLED_RESET 0 && (N > (IBI / 5) * 3) ) { display.setCursor(0,28);
Adafruit_SSD1306 display(OLED_RESET); Pulse = true; display.print("Raksha");
const int thermistor_output = A1; digitalWrite(blinkPin, HIGH); display.display();
const int WIDTH = 128; IBI = sampleCounter - lastBeatTime; delay(500);}
const int HEIGHT = 64; lastBeatTime = sampleCounter; void loop()
const int LENGTH = WIDTH; if (secondBeat) { {y[x] = map(Signal, 0, 1023, HEIGHT + 10,
int blinkPin = LED_BUILTIN; secondBeat = false; 0);
volatile int BPM; for (int i = 0; i <= 9; i++) { drawY();
volatile int Signal; rate[i] = IBI;}} x++;
volatile int IBI = 600; if (firstBeat) { if (x >= WIDTH)
volatile boolean Pulse = false; firstBeat = false; { int thermistor_adc_val;
volatile boolean QS = false; secondBeat = true; double output_voltage,
int x; sei(); thermistor_resistance, therm_res_ln,
int y[LENGTH]; return;} temperature, tempf;
void clearY() word runningTotal = 0; thermistor_adc_val =
{ for (int i = 0; i <= 8; i++) { analogRead(thermistor_output);
for (int i = 0; i < LENGTH; i++) rate[i] = rate[i + 1]; output_voltage = ( (thermistor_adc_val
{y[i] = -1;}} runningTotal += rate[i];} * 3.301) / 1023.0 );
void drawY() rate[9] = IBI; thermistor_resistance = ( ( 3.301 * ( 10
{display.drawPixel(0, y[0], WHITE); runningTotal += rate[9]; / output_voltage ) ) - 10 );
for (int i = 1; i < LENGTH; i++) runningTotal /= 10; thermistor_resistance =
{ BPM = 60000 / runningTotal; thermistor_resistance * 1000 ;
if (y[i] != -1) QS = true;}} therm_res_ln =
{display.drawLine(i - 1, y[i - 1], i, y[i], if (Signal < thresh && Pulse == true) { log(thermistor_resistance);
WHITE); digitalWrite(blinkPin, LOW); temperature = ( 1 / ( 0.001129148 + (
} else Pulse = false; 0.000234125 * therm_res_ln ) + (
{break;}}} amp = P - T; 0.0000000876741 * therm_res_ln *
volatile int rate[10]; thresh = amp / 2 + T; therm_res_ln * therm_res_ln ) ) ); /*
volatile unsigned long sampleCounter = 0; P = thresh; Temperature in Kelvin */
volatile unsigned long lastBeatTime = 0; T = thresh; temperature = temperature - 273.15;
volatile int P = 512; } display.clearDisplay();
volatile int T = 512; if (N > 2500) { display.setTextSize(1);
volatile int thresh = 525; thresh = 512; display.setTextColor(WHITE);
volatile int amp = 100; P = 512; display.setCursor(0, 0);
volatile boolean firstBeat = true; T = 512; display.print(" Heart Rate = ");
volatile boolean secondBeat = false; lastBeatTime = sampleCounter; display.print(BPM);
void interruptSetup() { firstBeat = true; display.println(" BPM");
TCCR2A = 0x02; secondBeat = false;} Serial.write(BPM);
TCCR2B = 0x06; sei(); display.setTextSize(0);
OCR2A = 0X7C; }// end isr display.setCursor(0, 52);
TIMSK2 = 0x02; void setup() display.print("IBI:");
sei();} { display.print(IBI);
ISR(TIMER2_COMPA_vect) { display.begin(SSD1306_SWITCHCAPVCC, display.print("mS");
cli(); 0x3C); display.setCursor(60, 52);
Signal = analogRead(pulsePin); delay(20); display.print("Temp:");
sampleCounter += 2; display.clearDisplay(); display.print(temperature);
int N = sampleCounter - lastBeatTime; x = 0; display.print("C");
16
x = 0; volatile int thresh = 525; T = 512;
clearY();} volatile int amp = 100; lastBeatTime = sampleCounter;
display.display(); volatile boolean firstBeat = true; firstBeat = true;
delay(10);} volatile boolean secondBeat = false; secondBeat = false;
#include <Wire.h> void interruptSetup() { }
#include <math.h> TCCR2A = 0x02; sei();}
#include <Adafruit_GFX.h> TCCR2B = 0x06; void setup()
#include <Adafruit_SSD1306.h> OCR2A = 0X7C; {
#define pulsePin A0 TIMSK2 = 0x02; pinMode(btnPin, INPUT_PULLUP);
#define OLED_RESET 0 sei();} display.begin(SSD1306_SWITCHCAPVCC,
Adafruit_SSD1306 display(OLED_RESET); ISR(TIMER2_COMPA_vect) { 0x3C);
const int WIDTH = 128; cli(); delay(20);
const int HEIGHT = 64; Signal = analogRead(pulsePin); display.clearDisplay();
const int LENGTH = WIDTH; sampleCounter += 2; x = 0;
const int thermistor_output = A1; int N = sampleCounter - lastBeatTime; clearY();
int blinkPin = LED_BUILTIN; if (Signal < thresh && N > (IBI / 5) * 3) { pinMode(blinkPin, OUTPUT);
#define btnPin 2 if (Signal < T) { Serial.begin(38400);
volatile int BPM; T = Signal;}} interruptSetup();
volatile int Signal; if (Signal > thresh && Signal > P) { display.setCursor(0, 0);
volatile int IBI = 600; P = Signal;} display.print(" Calculating BPM ");
volatile boolean Pulse = false; if (N > 250) { Serial.println(" ");
volatile boolean QS = false; if ( (Signal > thresh) && (Pulse == false) Serial.println(" Calculating BPM ");
enum fcnMode { && (N > (IBI / 5) * 3) ) { display.display();
OFF, Pulse = true; }
LOGO, digitalWrite(blinkPin, HIGH); void loop() {
Beat, IBI = sampleCounter - lastBeatTime; buttonPressed();
TEMP, lastBeatTime = sampleCounter; setMode();}
NBSTATE if (secondBeat) { void buttonPressed() {
}; secondBeat = false; buttonState = pulseIn(btnPin, HIGH,
unsigned long buttonState = 0; for (int i = 0; i <= 9; i++) { 1000000);
int funcState = 0; rate[i] = IBI;}} if (buttonState > 50) {
unsigned long currentMillis1, if (firstBeat) { funcState += 1;
currentMillis2, currentMillis3; firstBeat = false; Serial.print("Button state n: ");
unsigned long previousMillis1, secondBeat = true; Serial.println(funcState);
previousMillis2, previousMillis3; sei(); }
const long interval1 = 100; return;} funcState = funcState % NBSTATE;
const long interval2 = 300; word runningTotal = 0; }
const long interval3 = 500; for (int i = 0; i <= 8; i++) { void setMode() {
int x; rate[i] = rate[i + 1]; Serial.print("Function : ");
int y[LENGTH]; runningTotal += rate[i];} Serial.println(funcState);
void clearY() rate[9] = IBI; switch (funcState) {
{for (int i = 0; i < LENGTH; i++) runningTotal += rate[9]; case OFF:
{y[i] = -1; }} runningTotal /= 10; break;
void drawY() BPM = 60000 / runningTotal; case LOGO:
{ display.drawPixel(0, y[0], WHITE); QS = true;}} display.clearDisplay();
for (int i = 1; i < LENGTH; i++) if (Signal < thresh && Pulse == true) { display.setTextSize(2);
{ if (y[i] != -1) digitalWrite(blinkPin, LOW); display.setTextColor(WHITE);
{ display.drawLine(i - 1, y[i - 1], i, y[i], Pulse = false; display.setCursor(30, 28);
WHITE); } else amp = P - T; display.print("Raksha");
{ break;}}} thresh = amp / 2 + T; break;
volatile int rate[10]; P = thresh; case Beat:
volatile unsigned long sampleCounter = 0; T = thresh;} bpm();
volatile unsigned long lastBeatTime = 0; if (N > 2500) { break;
volatile int P = 512; thresh = 512; case TEMP:
volatile int T = 512; P = 512; temp();
17
break;}} double output_voltage, display.setTextSize(0);
void bpm() thermistor_resistance, therm_res_ln, display.setCursor(0, 52);
{ temperature, tempf; display.print("Temperature in Farenheit
y[x] = map(Signal, 0, 1023, HEIGHT + 10, thermistor_adc_val = = ");
0); analogRead(thermistor_output); tempf = 9 * (temperature / 5) + 32;
drawY(); output_voltage = ( (thermistor_adc_val display.print(tempf);
x++; * 3.301) / 1023.0 ); delay(4000);
if (x >= WIDTH) thermistor_resistance = ( ( 3.301 * ( 10 }
{ / output_voltage ) ) - 10 ); int ThermistorPin = A1;
display.clearDisplay(); thermistor_resistance = int Vo;
display.setTextSize(1); thermistor_resistance * 1000 ; float R1 = 10000;
display.setTextColor(WHITE); therm_res_ln = float logR2, R2, T;
display.setCursor(0, 0); log(thermistor_resistance); float c1 = 1.009249522e-03, c2 =
display.print(" Heart Rate = "); temperature = ( 1 / ( 0.001129148 + ( 2.378405444e-04, c3 = 2.019202697e-
display.print(BPM); 0.000234125 * therm_res_ln ) + ( 07;
display.println(" BPM"); 0.0000000876741 * therm_res_ln * void setup() {
Serial.print(" BPM = "); therm_res_ln * therm_res_ln ) ) ); /* Serial.begin(9600);
Serial.println(BPM); Temperature in Kelvin */ }
display.setTextSize(0); temperature = temperature - 273.15; void loop() {
display.setCursor(0, 52); display.clearDisplay(); Vo = analogRead(ThermistorPin);
display.print(" IBI= "); display.setTextSize(1); R2 = R1 * (1023.0 / (float)Vo - 1.0);
display.print(IBI); display.setTextColor(WHITE); logR2 = log(R2);
display.print("mS"); display.setCursor(0, 0); T = (1.0 / (c1 + c2*logR2 +
x = 0; display.print("Temperature in Celsius = c3*logR2*logR2*logR2));
clearY(); } "); T = T - 273.15;
display.display(); display.print(temperature); T = (T * 9.0)/ 5.0 + 32.0;
delay(10); Serial.print(temperature); Serial.print("Temperature: ");
} y[x] = map(temperature, 0, 1023, HEIGHT Serial.print(T);
void temp() + 10, 0); Serial.println(" F");
{ drawY(); delay(500);
int thermistor_adc_val; x++; }
17