19
19
// Read temperature in degrees Fahrenheit
20
20
#define TEMPERATURE_F
21
21
// uncomment the following line if you want to read temperature in degrees Celsius
22
- // #define TEMPERATURE_C
22
+ // #define TEMPERATURE_C
23
23
24
24
// Feather NRF52840 Built-in NeoPixel
25
25
#define PIN 16
@@ -36,7 +36,7 @@ float temp_offset = 0.5;
36
36
// Sensor read timeout, in minutes
37
37
// NOTE: Measuring your armpit temperature for a minimum
38
38
// of 12 minutes is equivalent to measuring your core body temperature.
39
- const long interval = 6 ;
39
+ const long interval = 1 ;
40
40
41
41
// BLE Service
42
42
BLEDfu bledfu; // OTA DFU service
@@ -47,7 +47,6 @@ BLEBas blebas; // battery
47
47
// Create the MCP9808 temperature sensor object
48
48
Adafruit_MCP9808 tempsensor = Adafruit_MCP9808();
49
49
50
-
51
50
void setup () {
52
51
Serial.begin (115200 );
53
52
Serial.println (" Wearable BlueFruit Temperature Sensor" );
@@ -113,16 +112,16 @@ void loop() {
113
112
114
113
// read and print the temperature
115
114
Serial.print (" Temp: " );
116
- #ifdef TEMPERATURE_F
115
+ #if defined( TEMPERATURE_F)
117
116
float temp = tempsensor.readTempF ();
118
117
Serial.print (temp);
119
118
Serial.println (" *F." );
120
- #endif
121
-
122
- #ifdef TEMPERATURE_C
119
+ #elif defined(TEMPERATURE_C)
123
120
float temp = tempsensor.readTempC ();
124
121
Serial.print (temp);
125
122
Serial.println (" *C." );
123
+ #else
124
+ #warning "Must define TEMPERATURE_C or TEMPERATURE_F!"
126
125
#endif
127
126
128
127
// add temp_offset
@@ -137,21 +136,18 @@ void loop() {
137
136
}
138
137
139
138
char buffer [8 ];
140
- snprintf (buffer, sizeof (buffer) - 1 , " %0.*f" , 2 , temp);
139
+ snprintf (buffer, sizeof (buffer) - 1 , " %0.*f" , 1 , temp);
141
140
bleuart.write (buffer);
142
141
143
142
// shutdown MSP9808 - power consumption ~0.1 mikro Ampere
144
143
Serial.println (" Shutting down MCP9808" );
145
144
tempsensor.shutdown_wake (1 );
146
145
147
146
// sleep for interval minutes
148
- // NOTE: NRF delay puts the MCU into a sleep mode:
149
- // (https://www.freertos.org/low-power-tickless-rtos.html)
147
+ // NOTE: NRF delay() puts mcu into a low-power sleep mode
150
148
delay (1000 *60 *interval);
151
-
152
149
}
153
150
154
-
155
151
void startAdv (void )
156
152
{
157
153
// Advertising packet
0 commit comments