speed test for ds1820 sensors

Dependencies:   DS1820 mbed-rtos mbed

Files at this revision

API Documentation at this revision

Comitter:
bdk9
Date:
Tue Nov 29 17:24:12 2016 +0000
Commit message:
published

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
mbed-rtos.lib Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/DS1820.lib	Tue Nov 29 17:24:12 2016 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/users/Sissors/code/DS1820/#51a5011dc0ad
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Tue Nov 29 17:24:12 2016 +0000
@@ -0,0 +1,41 @@
+#include "mbed.h"
+#include "DS1820.h"
+
+#define NUM_DS1820      3
+#define PIN_DS1820      D2
+
+// DEVICES 
+double temperatures[NUM_DS1820];
+DS1820* thermometers[NUM_DS1820];
+Serial pc(USBTX, USBRX);
+
+// Discover DS1820 probes on pin defined by PIN_DS1820
+void ds1820_init() {
+    // Initialize the thermometer array to DS1820 objects
+    int num_devices = 0;
+    while(DS1820::unassignedProbe(PIN_DS1820)) {
+        thermometers[num_devices] = new DS1820(PIN_DS1820);
+        num_devices++;
+        if (num_devices == NUM_DS1820)
+            break;
+    }
+    pc.printf("Found %d device(s)\r\n\n", num_devices);   
+}
+
+void read_temps() {
+    double temp;
+    thermometers[0]->convertTemperature(false, DS1820::all_devices);
+    for (int i=0; i<NUM_DS1820; i++) {
+        temp = (double) thermometers[i]->temperature();
+        temperatures[i] = temp;
+    }
+}
+int main()
+{
+    ds1820_init();
+    pc.printf("HELLOP");
+    while(1) {
+        read_temps();   
+        pc.printf("%.3f %.3f %.3f\n" , temperatures[0], temperatures[1], temperatures[2]);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed-rtos.lib	Tue Nov 29 17:24:12 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed-rtos/#58563e6cba1e
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Tue Nov 29 17:24:12 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/d75b3fe1f5cb
\ No newline at end of file