A DS1820 temperature sensor test.

Dependencies:   DS1820 mbed

Files at this revision

API Documentation at this revision

Comitter:
mingjunxu
Date:
Wed Dec 06 11:29:36 2017 +0000
Commit message:
A simple DS1820 temperture sensor One Wire Test.

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.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r 3f2965cd42bc DS1820.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/DS1820.lib	Wed Dec 06 11:29:36 2017 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/Sissors/code/DS1820/#236eb8f8e73a
diff -r 000000000000 -r 3f2965cd42bc main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Wed Dec 06 11:29:36 2017 +0000
@@ -0,0 +1,22 @@
+#include "mbed.h"
+#include "DS1820.h"
+#define DATA_PIN D12 
+/*on the DATA_PIN (a 4.7K resistor tp VCC is necessary)*/
+ 
+DS1820 probe(DATA_PIN);
+ 
+int main() {  
+    // Initialize the probe array to DS1820 objects
+    DS1820::unassignedProbe(DATA_PIN);
+    float celsius, fahrenheit;
+
+    printf("A simple DS1820 Test:\r\n");
+    while(1) {
+        probe.convertTemperature(true, DS1820::all_devices);         //Start temperature conversion, wait until ready
+        celsius = probe.temperature();
+        fahrenheit = celsius * 1.8f + 32.0f;
+        printf("Temperture = %.1f celsius, %.1f fahrenheit.\r\n",celsius, fahrenheit);
+        wait(1);
+    }
+    
+}
diff -r 000000000000 -r 3f2965cd42bc mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Wed Dec 06 11:29:36 2017 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/e7ca05fa8600
\ No newline at end of file