Professional Documents
Culture Documents
PRESENTED BY:
Mustafa Zia
Haider Badr
Abdul Latif Hisham
2ND STAGE (EVENING STUDY)
DR. OMAR YOUSSEF 16
TABLE OF CONTENTS:
INTRODUCTION…………………………………………….2-5
FEATURES……………………………………………………….6
SUPPLIES…………………………………………………....…….7
ASSEMBLE ……………….…………………………………....8-12
Schematic ……………………………………12
PROGRAMING …………………………………….……….13-14
CONCLUSION……………………………………………….14-15
CODE……………………………………………….…………16-18
2
VITALS MONITOR
INTRODUCTION:
3
know Heart Rate Variability (HRV) and body temperature. But
reading etc. Most use the LED and Photodiode based Photo
4
a unit of time (usually per minute). Heart rate varies for
rest. Babies have a much higher rate than adults around 120
bpm and older children have heart rate around 90 bpm. If the
5
temperature is 97 to 100 degrees Fahrenheit or 36.1 to 37.8
6
much needed during emergency period or for saving time of
FEATURES:
Battery-powered wearable
(IBI)
further analysis.
7
By sending the data to the cloud it creates a huge
to COVID-19.
SUPPLIES:
Hardware Needed:
pulse sensor×1
thermistor 10k×1
Arduino IDE
8
Hand tools and fabrication machines
3D Printer (generic)
ASSEMBLE:
vital signs measured, the heart rate (HR) calculation has been
9
monitoring technique to identify cardiovascular abnormalities
now, have not been enhanced to the point of offering the user
10
offers excellent potential to replace ECG recordings for the
all these data we can conclude that measuring the heart rate
11
In order to wear a wearable gadget, it should be enclosed in a
ahead and designed a case which can fit all my sensors and
MCUs.
12
Now we need to connect all the required components, earlier I
With ESP one can directly send the data to the cloud may be a
Schematic
13
The earlier cable-based connection had a lot of issues with
armature of a DC motor.
PROGRAMING:
14
The basic idea is like this.
15
and R is the thermistor resistance. Note that log () function in
Future enhancements:
anomaly.
Conclusion:
16
The best part of this device is, it is under 15$ which is a lot
government
CODE:
#include <math.h> const int LENGTH = WIDTH; void drawY()
#include <SPI.h> int blinkPin = LED_BUILTIN; {display.drawPixel(0, y[0],
#include <Wire.h> volatile int BPM; WHITE);
#include <Adafruit_GFX.h> volatile int Signal; for (int i = 1; i < LENGTH; i+
#include volatile int IBI = 600; +)
<Adafruit_SSD1306.h> volatile boolean Pulse = false; {
#define pulsePin A0 volatile boolean QS = false; if (y[i] != -1)
#define OLED_RESET 0 int x; {display.drawLine(i - 1, y[i -
Adafruit_SSD1306 int y[LENGTH]; 1], i, y[i], WHITE);
display(OLED_RESET); void clearY() } else
const int thermistor_output = { {break;}}}
A1; for (int i = 0; i < LENGTH; i+ volatile int rate[10];
const int WIDTH = 128; +) volatile unsigned long
const int HEIGHT = 64; {y[i] = -1;}} sampleCounter = 0;
17
volatile unsigned long QS = true;}} thermistor_resistance =
lastBeatTime = 0; if (Signal < thresh && Pulse thermistor_resistance * 1000 ;
volatile int P = 512; == true) { therm_res_ln =
volatile int T = 512; digitalWrite(blinkPin, LOW); log(thermistor_resistance);
volatile int thresh = 525; Pulse = false; temperature = ( 1 /
volatile int amp = 100; amp = P - T; ( 0.001129148 + ( 0.000234125
volatile boolean firstBeat = true; thresh = amp / 2 + T; * therm_res_ln ) +
volatile boolean secondBeat = P = thresh; ( 0.0000000876741 *
false; T = thresh; therm_res_ln * therm_res_ln *
void interruptSetup() { } therm_res_ln ) ) ); /*
TCCR2A = 0x02; if (N > 2500) { Temperature in Kelvin */
TCCR2B = 0x06; thresh = 512; temperature = temperature -
OCR2A = 0X7C; P = 512; 273.15;
TIMSK2 = 0x02; T = 512; display.clearDisplay();
sei();} lastBeatTime = display.setTextSize(1);
ISR(TIMER2_COMPA_vect) { sampleCounter; display.setTextColor(WHITE
cli(); firstBeat = true; );
Signal = secondBeat = false;} display.setCursor(0, 0);
analogRead(pulsePin); sei(); display.print(" Heart Rate =
sampleCounter += 2; }// end isr ");
int N = sampleCounter - void setup() display.print(BPM);
lastBeatTime; { display.println(" BPM");
if (Signal < thresh && N > display.begin(SSD1306_SWIT Serial.write(BPM);
(IBI / 5) * 3) { CHCAPVCC, 0x3C); display.setTextSize(0);
if (Signal < T) {T = Signal;}} delay(20); display.setCursor(0, 52);
if (Signal > thresh && Signal display.clearDisplay(); display.print("IBI:");
> P) { x = 0; display.print(IBI);
P = Signal;} clearY(); display.print("mS");
if (N > 250) { pinMode(blinkPin, OUTPUT); display.setCursor(60, 52);
if ( (Signal > thresh) && Serial.begin(115200); display.print("Temp:");
(Pulse == false) && (N > (IBI / interruptSetup(); display.print(temperature);
5) * 3) ) { display.clearDisplay(); display.print("C");
Pulse = true; display.setTextSize(2); x = 0;
digitalWrite(blinkPin, display.setCursor(0,28); clearY();}
HIGH); display.print("Raksha"); display.display();
IBI = sampleCounter - display.display(); delay(10);}
lastBeatTime; delay(500);} #include <Wire.h>
lastBeatTime = void loop() #include <math.h>
sampleCounter; {y[x] = map(Signal, 0, 1023, #include <Adafruit_GFX.h>
if (secondBeat) { HEIGHT + 10, 0); #include
secondBeat = false; drawY(); <Adafruit_SSD1306.h>
for (int i = 0; i <= 9; i++) { x++; #define pulsePin A0
rate[i] = IBI;}} if (x >= WIDTH) #define OLED_RESET 0
if (firstBeat) { { int thermistor_adc_val; Adafruit_SSD1306
firstBeat = false; double output_voltage, display(OLED_RESET);
secondBeat = true; thermistor_resistance, const int WIDTH = 128;
sei(); therm_res_ln, temperature, const int HEIGHT = 64;
return;} tempf; const int LENGTH = WIDTH;
word runningTotal = 0; thermistor_adc_val = const int thermistor_output =
for (int i = 0; i <= 8; i++) { analogRead(thermistor_output); A1;
rate[i] = rate[i + 1]; output_voltage = int blinkPin = LED_BUILTIN;
runningTotal += rate[i];} ( (thermistor_adc_val * 3.301) / #define btnPin 2
rate[9] = IBI; 1023.0 ); volatile int BPM;
runningTotal += rate[9]; thermistor_resistance = volatile int Signal;
runningTotal /= 10; ( ( 3.301 * ( 10 / volatile int IBI = 600;
BPM = 60000 / output_voltage ) ) - 10 ); volatile boolean Pulse = false;
runningTotal; volatile boolean QS = false;
18
enum fcnMode { if (Signal < thresh && N > pinMode(btnPin,
OFF, (IBI / 5) * 3) { INPUT_PULLUP);
LOGO, if (Signal < T) { display.begin(SSD1306_SWIT
Beat, T = Signal;}} CHCAPVCC, 0x3C);
TEMP, if (Signal > thresh && Signal delay(20);
NBSTATE > P) { display.clearDisplay();
}; P = Signal;} x = 0;
unsigned long buttonState = 0; if (N > 250) { clearY();
int funcState = 0; if ( (Signal > thresh) && pinMode(blinkPin, OUTPUT);
unsigned long currentMillis1, (Pulse == false) && (N > (IBI / Serial.begin(38400);
currentMillis2, currentMillis3; 5) * 3) ) { interruptSetup();
unsigned long previousMillis1, Pulse = true; display.setCursor(0, 0);
previousMillis2, digitalWrite(blinkPin, display.print(" Calculating
previousMillis3; HIGH); BPM ");
const long interval1 = 100; IBI = sampleCounter - Serial.println(" ");
const long interval2 = 300; lastBeatTime; Serial.println(" Calculating
const long interval3 = 500; lastBeatTime = BPM ");
int x; sampleCounter; display.display();
int y[LENGTH]; if (secondBeat) { }
void clearY() secondBeat = false; void loop() {
{for (int i = 0; i < LENGTH; i+ for (int i = 0; i <= 9; i++) { buttonPressed();
+) rate[i] = IBI;}} setMode();}
{y[i] = -1; }} if (firstBeat) { void buttonPressed() {
void drawY() firstBeat = false; buttonState = pulseIn(btnPin,
{ display.drawPixel(0, y[0], secondBeat = true; HIGH, 1000000);
WHITE); sei(); if (buttonState > 50) {
for (int i = 1; i < LENGTH; i+ return;} funcState += 1;
+) word runningTotal = 0; Serial.print("Button state n:
{ if (y[i] != -1) for (int i = 0; i <= 8; i++) { ");
{ display.drawLine(i - 1, y[i - rate[i] = rate[i + 1]; Serial.println(funcState);
1], i, y[i], WHITE); } else runningTotal += rate[i];} }
{ break;}}} rate[9] = IBI; funcState = funcState %
volatile int rate[10]; runningTotal += rate[9]; NBSTATE;
volatile unsigned long runningTotal /= 10; }
sampleCounter = 0; BPM = 60000 / void setMode() {
volatile unsigned long runningTotal; Serial.print("Function : ");
lastBeatTime = 0; QS = true;}} Serial.println(funcState);
volatile int P = 512; if (Signal < thresh && Pulse switch (funcState) {
volatile int T = 512; == true) { case OFF:
volatile int thresh = 525; digitalWrite(blinkPin, LOW); break;
volatile int amp = 100; Pulse = false; case LOGO:
volatile boolean firstBeat = true; amp = P - T; display.clearDisplay();
volatile boolean secondBeat = thresh = amp / 2 + T; display.setTextSize(2);
false; P = thresh; display.setTextColor(WHIT
void interruptSetup() { T = thresh;} E);
TCCR2A = 0x02; if (N > 2500) { display.setCursor(30, 28);
TCCR2B = 0x06; thresh = 512; display.print("Raksha");
OCR2A = 0X7C; P = 512; break;
TIMSK2 = 0x02; T = 512; case Beat:
sei();} lastBeatTime = bpm();
ISR(TIMER2_COMPA_vect) { sampleCounter; break;
cli(); firstBeat = true; case TEMP:
Signal = secondBeat = false; temp();
analogRead(pulsePin); } break;}}
sampleCounter += 2; sei();} void bpm()
int N = sampleCounter - void setup() {
lastBeatTime; {
19
y[x] = map(Signal, 0, 1023, thermistor_adc_val = display.setCursor(0, 52);
HEIGHT + 10, 0); analogRead(thermistor_output); display.print("Temperature in
drawY(); output_voltage = Farenheit = ");
x++; ( (thermistor_adc_val * 3.301) / tempf = 9 * (temperature / 5) +
if (x >= WIDTH) 1023.0 ); 32;
{ thermistor_resistance = display.print(tempf);
display.clearDisplay(); ( ( 3.301 * ( 10 / delay(4000);
display.setTextSize(1); output_voltage ) ) - 10 ); }
display.setTextColor(WHITE thermistor_resistance = int ThermistorPin = A1;
); thermistor_resistance * 1000 ; int Vo;
display.setCursor(0, 0); therm_res_ln = float R1 = 10000;
display.print(" Heart Rate = log(thermistor_resistance); float logR2, R2, T;
"); temperature = ( 1 / float c1 = 1.009249522e-03, c2
display.print(BPM); ( 0.001129148 + ( 0.000234125 = 2.378405444e-04, c3 =
display.println(" BPM"); * therm_res_ln ) + 2.019202697e-07;
Serial.print(" BPM = "); ( 0.0000000876741 * void setup() {
Serial.println(BPM); therm_res_ln * therm_res_ln * Serial.begin(9600);
display.setTextSize(0); therm_res_ln ) ) ); /* }
display.setCursor(0, 52); Temperature in Kelvin */ void loop() {
display.print(" IBI= "); temperature = temperature - Vo =
display.print(IBI); 273.15; analogRead(ThermistorPin);
display.print("mS"); display.clearDisplay(); R2 = R1 * (1023.0 / (float)Vo -
x = 0; display.setTextSize(1); 1.0);
clearY(); } display.setTextColor(WHITE); logR2 = log(R2);
display.display(); display.setCursor(0, 0); T = (1.0 / (c1 + c2*logR2 +
delay(10); display.print("Temperature in c3*logR2*logR2*logR2));
} Celsius = "); T = T - 273.15;
void temp() display.print(temperature); T = (T * 9.0)/ 5.0 + 32.0;
{ Serial.print(temperature); Serial.print("Temperature: ");
int thermistor_adc_val; y[x] = map(temperature, 0, Serial.print(T);
double output_voltage, 1023, HEIGHT + 10, 0); Serial.println(" F");
thermistor_resistance, drawY(); delay(500);
therm_res_ln, temperature, x++; }
tempf; display.setTextSize(0);
20