correct negative temperature
authorDobrica Pavlinusic <dpavlin@rot13.org>
Sun, 28 Dec 2014 09:52:56 +0000 (10:52 +0100)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Sun, 28 Dec 2014 09:52:56 +0000 (10:52 +0100)
outdoor_temperature_sensor/outdoor_temperature_sensor.ino

index cce90f0..644591f 100644 (file)
@@ -153,7 +153,9 @@ if (DEBUG) {
 }
 
     Serial.print("temp=");
-    Serial.print((( myData1 >> 8 ) & 0xFFF ) / 10.0, 1);
+    int temp = ( myData1 >> 8 ) & 0xFFF;
+    if ( temp & 0x800 ) temp = temp | 0xF000;
+    Serial.print(temp / 10.0, 1);
 
     Serial.print(" humidity=");
     Serial.print( myData1 & 0xFF );