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.

Files at this revision

API Documentation at this revision

Comitter:
Sissors
Date:
Tue Apr 08 09:59:18 2014 +0000
Parent:
6:abfdd851218a
Child:
8:d87e11e8d012
Commit message:
Added define for invalid conversion

Changed in this revision

DS1820.cpp Show annotated file Show diff for this revision Revisions of this file
DS1820.h Show annotated file Show diff for this revision Revisions of this file
--- a/DS1820.cpp	Wed Apr 02 19:10:34 2014 +0000
+++ b/DS1820.cpp	Tue Apr 08 09:59:18 2014 +0000
@@ -353,7 +353,7 @@
     read_RAM();
     if (RAM_checksum_error())
         // Indicate we got a CRC error
-        answer = -1000.0;
+        answer = invalid_conversion;
     else {
         reading = (RAM[1] << 8) + RAM[0];
         if (reading & 0x8000) { // negative degrees C
--- a/DS1820.h	Wed Apr 02 19:10:34 2014 +0000
+++ b/DS1820.h	Tue Apr 08 09:59:18 2014 +0000
@@ -54,6 +54,10 @@
     enum devices{
         this_device,     // command applies to only this device
         all_devices };   // command applies to all devices
+    
+    enum {
+        invalid_conversion = -1000
+    };
 
     /** Create a probe object connected to the specified pins
     *
@@ -91,7 +95,7 @@
       * probe to read its RAM, do CRC check and convert temperature on the LPC1768.
       *
       * @param scale, may be either 'c' or 'f'
-      * @returns temperature for that scale, or -1000.0 if CRC error detected.
+      * @returns temperature for that scale, or DS1820::invalid_conversion (-1000) if CRC error detected.
       */
     float temperature(char scale='c');