Example program for the DS1820 library. It searches for connected devices, reports their addresses, and then displays their temperatures.

Dependencies:   DS1820 mbed

Fork of DS1820_HelloWorld by Erik -

Revision:
5:a870fb672587
Parent:
3:f483abe4bc57
--- a/main.cpp	Fri Jan 13 18:30:37 2017 +0000
+++ b/main.cpp	Thu Mar 09 04:04:16 2017 +0000
@@ -1,5 +1,5 @@
 #define MULTIPLE_PROBES
-#define DATA_PIN        A0
+#define DATA_PIN        p25
 
 
 #ifdef MULTIPLE_PROBES
@@ -21,11 +21,22 @@
             break;
     }
     
-    printf("Found %d device(s)\r\n\n", num_devices);
+    printf("Found %d device(s)\r\n", num_devices);
+    unsigned long long fullName;
+    unsigned int firstName;
+    unsigned int lastName;
+    for (int i = 0; i<num_devices; i++) {
+        fullName = probe[i]->whoAmI();
+        firstName = fullName >> 32;
+        lastName = fullName;
+        printf("\tID %d = %x%x\r\n", i, firstName, lastName);
+    }
+    printf("\n");
+    
     while(1) {
         probe[0]->convertTemperature(true, DS1820::all_devices);         //Start temperature conversion, wait until ready
         for (int i = 0; i<num_devices; i++)
-            printf("Device %d returns %3.1foC\r\n", i, probe[i]->temperature());
+            printf("%3.1f C\t", i, probe[i]->temperature());
         printf("\r\n");
         wait(1);
     }