1919// Read temperature in degrees Fahrenheit
2020#define TEMPERATURE_F
2121// uncomment the following line if you want to read temperature in degrees Celsius
22- // #define TEMPERATURE_C
22+ // #define TEMPERATURE_C
2323
2424// Feather NRF52840 Built-in NeoPixel
2525#define PIN 16
@@ -36,7 +36,7 @@ float temp_offset = 0.5;
3636// Sensor read timeout, in minutes
3737// NOTE: Measuring your armpit temperature for a minimum
3838// of 12 minutes is equivalent to measuring your core body temperature.
39- const long interval = 6 ;
39+ const long interval = 1 ;
4040
4141// BLE Service
4242BLEDfu bledfu; // OTA DFU service
@@ -47,7 +47,6 @@ BLEBas blebas; // battery
4747// Create the MCP9808 temperature sensor object
4848Adafruit_MCP9808 tempsensor = Adafruit_MCP9808();
4949
50-
5150void setup () {
5251 Serial.begin (115200 );
5352 Serial.println (" Wearable BlueFruit Temperature Sensor" );
@@ -113,16 +112,16 @@ void loop() {
113112
114113 // read and print the temperature
115114 Serial.print (" Temp: " );
116- #ifdef TEMPERATURE_F
115+ #if defined( TEMPERATURE_F)
117116 float temp = tempsensor.readTempF ();
118117 Serial.print (temp);
119118 Serial.println (" *F." );
120- #endif
121-
122- #ifdef TEMPERATURE_C
119+ #elif defined(TEMPERATURE_C)
123120 float temp = tempsensor.readTempC ();
124121 Serial.print (temp);
125122 Serial.println (" *C." );
123+ #else
124+ #warning "Must define TEMPERATURE_C or TEMPERATURE_F!"
126125 #endif
127126
128127 // add temp_offset
@@ -137,21 +136,18 @@ void loop() {
137136 }
138137
139138 char buffer [8 ];
140- snprintf (buffer, sizeof (buffer) - 1 , " %0.*f" , 2 , temp);
139+ snprintf (buffer, sizeof (buffer) - 1 , " %0.*f" , 1 , temp);
141140 bleuart.write (buffer);
142141
143142 // shutdown MSP9808 - power consumption ~0.1 mikro Ampere
144143 Serial.println (" Shutting down MCP9808" );
145144 tempsensor.shutdown_wake (1 );
146145
147146 // 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
150148 delay (1000 *60 *interval);
151-
152149}
153150
154-
155151void startAdv (void )
156152{
157153 // Advertising packet
0 commit comments