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

Committer:
deece
Date:
Thu Jan 11 04:38:02 2018 +0000
Revision:
12:c11b1e5546b0
Parent:
10:4b88be251088
Child:
13:c91214d92d70
Broken, always gives a reading of 85C

Who changed what in which revision?

UserRevisionLine numberNew contents of line
hudakz 5:3c3ef17a17a6 1 #include "stm32f103c8t6.h"
hudakz 0:ab218237069e 2 #include "mbed.h"
deece 12:c11b1e5546b0 3 #include "DS1820.h"
deece 12:c11b1e5546b0 4
deece 12:c11b1e5546b0 5 #define DATA_PIN PA_7
deece 12:c11b1e5546b0 6
hudakz 0:ab218237069e 7 int main() {
deece 12:c11b1e5546b0 8 DS1820 probe(DATA_PIN);
hudakz 10:4b88be251088 9
hudakz 0:ab218237069e 10 while(1) {
deece 12:c11b1e5546b0 11 printf("Initiating temperature conversion\r\n");
deece 12:c11b1e5546b0 12 probe.convertTemperature(true, DS1820::all_devices); //Start temperature conversion, wait until ready
deece 12:c11b1e5546b0 13 double temperature = probe.temperature();
deece 12:c11b1e5546b0 14 int temp_integer = temperature;
deece 12:c11b1e5546b0 15 int temp_milli = (temperature - temp_integer) * 1000;
deece 12:c11b1e5546b0 16 printf("It is %d.%03dC\r\n", temp_integer, temp_milli);
deece 12:c11b1e5546b0 17 wait(1000);
hudakz 0:ab218237069e 18 }
hudakz 0:ab218237069e 19 }