An example of how to communicate with 1Wire devices from the STM32F103C8T6 (on the cheap "Bluepill" board)

Dependencies:   DS1820 mbed-STM32F103C8T6 mbed

Fork of STM32F103C8T6_Hello by Zoltan Hudak

Revision:
12:c11b1e5546b0
Parent:
10:4b88be251088
Child:
13:c91214d92d70
--- a/main.cpp	Mon Jun 26 13:53:25 2017 +0000
+++ b/main.cpp	Thu Jan 11 04:38:02 2018 +0000
@@ -1,20 +1,19 @@
 #include "stm32f103c8t6.h"
 #include "mbed.h"
-  
+#include "DS1820.h"
+
+#define DATA_PIN        PA_7
+ 
 int main() {
-    confSysClock();     //Configure system clock (72MHz HSE clock, 48MHz USB clock)
-    
-    Serial      pc(PA_2, PA_3);
-    DigitalOut  myled(LED1);
+    DS1820 probe(DATA_PIN);
     
     while(1) {
-        // The on-board LED is connected, via a resistor, to +3.3V (not to GND). 
-        // So to turn the LED on or off we have to set it to 0 or 1 respectively
-        myled = 0;      // turn the LED on
-        wait_ms(200);   // 200 millisecond
-        myled = 1;      // turn the LED off
-        wait_ms(1000);  // 1000 millisecond
-        pc.printf("Blink\r\n");
+        printf("Initiating temperature conversion\r\n");
+        probe.convertTemperature(true, DS1820::all_devices);         //Start temperature conversion, wait until ready
+        double temperature = probe.temperature();
+        int temp_integer = temperature;
+        int temp_milli = (temperature - temp_integer) * 1000;
+        printf("It is %d.%03dC\r\n", temp_integer, temp_milli);
+        wait(1000);
     }
 }
- 
\ No newline at end of file