|
26 | 26 | Adafruit_NeoPixel pixels(1, PIN, NEO_GRB + NEO_KHZ800);
|
27 | 27 |
|
28 | 28 | // Maximum temperature value for armband's fever indicator
|
29 |
| -// NOTE: This is in degrees Fahrenheit, please adjust |
| 29 | +// NOTE: This is in degrees Fahrenheit |
30 | 30 | float fever_temp = 100.4;
|
31 | 31 |
|
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. |
34 | 34 | float temp_offset = 0.5;
|
35 | 35 |
|
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]; |
40 | 45 |
|
41 | 46 | // BLE Service
|
42 | 47 | BLEDfu bledfu; // OTA DFU service
|
@@ -124,28 +129,30 @@ void loop() {
|
124 | 129 | #warning "Must define TEMPERATURE_C or TEMPERATURE_F!"
|
125 | 130 | #endif
|
126 | 131 |
|
127 |
| - // add temp_offset |
| 132 | + // add temperature offset |
128 | 133 | temp += temp_offset;
|
129 | 134 |
|
130 | 135 | if (temp >= fever_temp) {
|
131 | 136 | pixels.setPixelColor(1, pixels.Color(255, 0, 0));
|
132 | 137 | pixels.show();
|
133 | 138 | }
|
| 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 | + } |
134 | 145 | else {
|
135 |
| - pixels.clear(); |
| 146 | + calibration_time-=1; |
136 | 147 | }
|
137 | 148 |
|
138 |
| - char buffer [8]; |
139 |
| - snprintf(buffer, sizeof(buffer) - 1, "%0.*f", 1, temp); |
140 |
| - bleuart.write(buffer); |
141 |
| - |
142 | 149 | // shutdown MSP9808 - power consumption ~0.1 mikro Ampere
|
143 | 150 | Serial.println("Shutting down MCP9808");
|
144 | 151 | tempsensor.shutdown_wake(1);
|
145 | 152 |
|
146 |
| - // sleep for interval minutes |
| 153 | + // sleep for sensor_delay minutes |
147 | 154 | // NOTE: NRF delay() puts mcu into a low-power sleep mode
|
148 |
| - delay(1000*60*interval); |
| 155 | + delay(1000*60*sensor_delay); |
149 | 156 | }
|
150 | 157 |
|
151 | 158 | void startAdv(void)
|
|
0 commit comments