Dual DS18B20 Serial Temp logger

Dependencies:   DS1820 mbed

Fork of DS1820_HelloWorld by Erik -

Import program

00001 
00002 #include "mbed.h"
00003 #include "DS1820.h"
00004  
00005 DS1820 probeInt(A0);
00006 DS1820 probeExt(A1);
00007 Timer t;
00008 int main() {
00009      probeInt.unassignedProbe(A0);
00010      
00011      probeExt.unassignedProbe(A1);
00012      
00013      while(1) {
00014          probeInt.convertTemperature(true, DS1820::all_devices);  // Start temperature conversion
00015          printf("TempInt value=%f\r\n", probeInt.temperature());     
00016 
00017          probeExt.convertTemperature(true, DS1820::all_devices);  // Start temperature conversion
00018          printf("TempRoom value=%f\r\n", probeExt.temperature());
00019      }
00020 }
00021 

Files at this revision

API Documentation at this revision

Comitter:
rlanghbv
Date:
Thu Nov 23 08:19:49 2017 +0000
Parent:
4:01060b5e01b4
Child:
6:ba8f89d2098b
Commit message:
First Commit

Changed in this revision

DS1820.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/DS1820.lib	Fri Jan 13 18:30:37 2017 +0000
+++ b/DS1820.lib	Thu Nov 23 08:19:49 2017 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/Sissors/code/DS1820/#c591209285e9
+http://mbed.org/users/Sissors/code/DS1820/#236eb8f8e73a
--- a/main.cpp	Fri Jan 13 18:30:37 2017 +0000
+++ b/main.cpp	Thu Nov 23 08:19:49 2017 +0000
@@ -1,49 +1,20 @@
-#define MULTIPLE_PROBES
-#define DATA_PIN        A0
-
-
-#ifdef MULTIPLE_PROBES
 
 #include "mbed.h"
 #include "DS1820.h"
+ 
+DS1820 probeInt(A0);
+DS1820 probeExt(A1);
+Timer t;
+int main() {
+     probeInt.unassignedProbe(A0);
+     
+     probeExt.unassignedProbe(A1);
+     
+     while(1) {
+         probeInt.convertTemperature(true, DS1820::all_devices);         //Start temperature conversion, wait until ready
+         printf("TempInt value=%f\r\n", probeInt.temperature());     
 
-#define MAX_PROBES      16
- 
-DS1820* probe[MAX_PROBES];
- 
-int main() {  
-    // Initialize the probe array to DS1820 objects
-    int num_devices = 0;
-    while(DS1820::unassignedProbe(DATA_PIN)) {
-        probe[num_devices] = new DS1820(DATA_PIN);
-        num_devices++;
-        if (num_devices == MAX_PROBES)
-            break;
-    }
-    
-    printf("Found %d device(s)\r\n\n", num_devices);
-    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("\r\n");
-        wait(1);
-    }
-    
-}
-
-#else
-#include "mbed.h"
-#include "DS1820.h"
- 
-DS1820 probe(DATA_PIN);
- 
-int main() {
-    while(1) {
-        probe.convertTemperature(true, DS1820::all_devices);         //Start temperature conversion, wait until ready
-        printf("It is %3.1foC\r\n", probe.temperature());
-        wait(1);
-    }
-}
-
-#endif
\ No newline at end of file
+         probeExt.convertTemperature(true, DS1820::all_devices);         //Start temperature conversion, wait until ready             
+         printf("TempRoom value=%f\r\n", probeExt.temperature());
+     }
+}
\ No newline at end of file