-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathvitalsArduinoCode.ino
More file actions
161 lines (133 loc) · 2.95 KB
/
vitalsArduinoCode.ino
File metadata and controls
161 lines (133 loc) · 2.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
/* Arduino for Kumbha Data collection of Vitals
Shield Used - Cooking Hacks eHealth Platform v2.0
https://www.cooking-hacks.com/documentation/tutorials/ehealth-biometric-sensor-platform-arduino-raspberry-pi-medical
Sensors Used
1- Temperature
2- Skin Response
3- Pulse Oximetry
4- Blood Pressure
Author:- Akshat Wahi
Date Created :- 18 August 2015
Date Modified :- 18 August 2015
*/
#include <eHealth.h>;
#include <PinChangeInt.h>
char input = '\n';
unsigned long current_time;
int cont = 0;
void setup()
{
Serial.begin(9600);
delay(100);
eHealth.initPulsioximeter();
//Attach the inttruptions for using the pulsioximeter.
PCintPort::attachInterrupt(6, readPulsioximeter, RISING);
}
void loop()
{
switch (input)
{
case 't':
send_temperature();
break;
case 's':
send_skin_reading();
break;
case 'p':
send_pulseox();
break;
case 'd':
//do nothing
break;
default:
//do nothing
break;
}
}
void serialEvent()
{
while (Serial.available())
{
input = (char)Serial.read();
}
if(input == 's')
{
current_time = millis();
}
}
void send_temperature()
{
float temp[10], avg_temp = 0.0;
for (int x = 0; x < 10; x++)
{
temp[x] = eHealth.getTemperature();
delay(20); //delay between each temperature read
}
for (int x = 0; x < 10; x++)
{
avg_temp += temp[x];
}
avg_temp /= 10;
Serial.println(avg_temp);
// Serial.print("t");
// Serial.print(avg_temp);
// Serial.println("#");
}
void send_skin_reading()
{
float temp[3], avg_cond=0.0, avg_res= 0.0, avg_vol=0.0;
unsigned long time_diff;
/*
for(int x=0;x<4;x++)
{
temp[0][x] = eHealth.getSkinConductance();
temp[1][x] = eHealth.getSkinResistance();
temp[2][x] = eHealth.getSkinConductanceVoltage();
delay(20);
}
for(int x=0;x<4;x++)
{
avg_cond += temp[0][x];
avg_res += temp[1][x];
avg_vol += temp[2][x];
}
avg_cond /=4;
avg_res /=4;
avg_vol /=4;
*/
time_diff = (unsigned long)(millis() - current_time);
temp[0] = eHealth.getSkinConductance();
temp[1] = eHealth.getSkinResistance();
temp[2] = eHealth.getSkinConductanceVoltage();
Serial.print(time_diff);
Serial.print(",");
Serial.print(temp[0]);
Serial.print(",");
Serial.print(temp[1]);
Serial.print(",");
Serial.println(temp[2]);
delay(100);
// Serial.print("s");
// Serial.print(avg_cond);
// Serial.print("#");
// Serial.print(avg_res);
// Serial.print("#");
// Serial.print(avg_vol);
// Serial.println("#");
}
void send_pulseox()
{
Serial.print(eHealth.getBPM());
Serial.print(",");
Serial.println(eHealth.getOxygenSaturation());
delay(100);
}
//Include always this code when using the pulsioximeter sensor
//=========================================================================
void readPulsioximeter(){
cont ++;
if (cont == 50) { //Get only of one 50 measures to reduce the latency
eHealth.readPulsioximeter();
cont = 0;
}
}