Library for reading temperature from DS1820, DS18B20 and DS1822

Dependencies:   LinkedList

Dependents:   heatmap BLE_Temperature BLE_Temperature_Exercise F334andDS18B20 ... more

Fork of DS1820 by David Pairman

HelloWorld: http://mbed.org/users/Sissors/code/DS1820_HelloWorld/

Library should currently work on all mbed targets, let me know if there is an issue. First however make sure you have latest version of mbed library and this library.

Revision:
10:d297ce9ce422
Parent:
9:3821ca0b7f14
Child:
11:1a3c3002b50c
--- a/DS1820.cpp	Thu Jan 29 19:27:32 2015 +0000
+++ b/DS1820.cpp	Fri Jan 30 11:07:10 2015 +0000
@@ -361,18 +361,16 @@
         }
         answer = reading +0.0; // convert to floating point
         if ((FAMILY_CODE == FAMILY_CODE_DS18B20 ) || (FAMILY_CODE == FAMILY_CODE_DS1822 )) {
-            answer = answer / 8.0;
+            answer = answer / 16.0;
         }
         else {
             remaining_count = RAM[6];
             count_per_degree = RAM[7];
-            answer = answer - 0.25 + (count_per_degree - remaining_count) / count_per_degree;
+            answer = floor(answer/2.0) - 0.25 + (count_per_degree - remaining_count) / count_per_degree;
         }
-        if (scale=='C' or scale=='c')
-            answer = answer / 2.0;
-        else
+        if (scale=='F' or scale=='f')
             // Convert to deg F
-            answer = answer * 9.0 / 10.0 + 32.0;
+            answer = answer * 9.0 / 5.0 + 32.0;
     }
     return answer;
 }