-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathzebra_tracker.ino
69 lines (47 loc) · 1.17 KB
/
zebra_tracker.ino
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
Adafruit_GPS GPS;
PulseOximeter pox;
void setup() {
// temperature
pinMode(A1, INPUT);
// Vitals
pinMode(2, INPUT);
// Air Quality
pinMode(A2, INPUT);
pinMode(8, INPUT);
Serial.begin(9600);
// Networking
pinMode(0, OUTPUT);
}
void loop() {
// Temp
float temp = analogRead(A1) / 1023.0 * 5.0 * 100.0;
// GPS
string gpsResult = GPS.read();
string spO2_res = "";
string hb_res = "";
// Vitals
if (pox.begin()) {
spO2_res = pox.getSpO2();
hb_res = pox.getHeartRate();
}
// Air Quality
int analogResult = analogRead(A2);
string message = "{\"temp\":" + to_string(temp)
+ ",\"gps\":" + gpsResult
+ ",\"o2_pct:\":" + spO2_res
+ ",\"hb_res\":" + hb_res
+ ",\"ppma\":" + to_string(analogResult)
+ "}";
Serial.println(
message
);
// Networking
// Send
Serial.sendMessage(0, message);
// Print anything recieved
if (Serial.availableMessage() != 0) {
string mystr = Serial.readMessage();
Serial.println("GOSSIP:" + mystr);
}
delay(20000);
}