Skip to content

Commit bf989b0

Browse files
author
brentru
committed
wait 12min before sending calibrated temperature to uart, move transmit buffer to global
1 parent a392cd0 commit bf989b0

File tree

1 file changed

+22
-15
lines changed

1 file changed

+22
-15
lines changed

Wearable_BLE_Temperature_Monitor/ble_temp_monitor.ino

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,22 @@
2626
Adafruit_NeoPixel pixels(1, PIN, NEO_GRB + NEO_KHZ800);
2727

2828
// Maximum temperature value for armband's fever indicator
29-
// NOTE: This is in degrees Fahrenheit, please adjust
29+
// NOTE: This is in degrees Fahrenheit
3030
float fever_temp = 100.4;
3131

32-
// offset is +0.5-1.0 degrees to make
33-
// axillary temperature comparible to ear or temporal.
32+
// temperature calibration offset is +0.5 to +1.0 degree
33+
// to make axillary temperature comparible to ear or temporal.
3434
float temp_offset = 0.5;
3535

36-
// Sensor read timeout, in minutes
37-
// NOTE: Measuring your armpit temperature for a minimum
38-
// of 12 minutes is equivalent to measuring your core body temperature.
39-
const long interval = 1;
36+
// Sensor read delay, in minutes
37+
int sensor_delay = 1;
38+
39+
// Measuring your armpit temperature for a minimum of 12 minutes
40+
// is equivalent to measuring your core body temperature.
41+
int calibration_time = 12;
42+
43+
// BLE transmit buffer
44+
char temperature_buf [8];
4045

4146
// BLE Service
4247
BLEDfu bledfu; // OTA DFU service
@@ -124,28 +129,30 @@ void loop() {
124129
#warning "Must define TEMPERATURE_C or TEMPERATURE_F!"
125130
#endif
126131

127-
// add temp_offset
132+
// add temperature offset
128133
temp += temp_offset;
129134

130135
if (temp >= fever_temp) {
131136
pixels.setPixelColor(1, pixels.Color(255, 0, 0));
132137
pixels.show();
133138
}
139+
140+
snprintf(temperature_buf, sizeof(temperature_buf) - 1, "%0.*f", 1, temp);
141+
if (calibration_time == 0) {
142+
// write to UART
143+
bleuart.write(temperature_buf);
144+
}
134145
else {
135-
pixels.clear();
146+
calibration_time-=1;
136147
}
137148

138-
char buffer [8];
139-
snprintf(buffer, sizeof(buffer) - 1, "%0.*f", 1, temp);
140-
bleuart.write(buffer);
141-
142149
// shutdown MSP9808 - power consumption ~0.1 mikro Ampere
143150
Serial.println("Shutting down MCP9808");
144151
tempsensor.shutdown_wake(1);
145152

146-
// sleep for interval minutes
153+
// sleep for sensor_delay minutes
147154
// NOTE: NRF delay() puts mcu into a low-power sleep mode
148-
delay(1000*60*interval);
155+
delay(1000*60*sensor_delay);
149156
}
150157

151158
void startAdv(void)

0 commit comments

Comments
 (0)