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

main.cpp

Committer:
deece
Date:
2018-01-11
Revision:
12:c11b1e5546b0
Parent:
10:4b88be251088
Child:
13:c91214d92d70

File content as of revision 12:c11b1e5546b0:

#include "stm32f103c8t6.h"
#include "mbed.h"
#include "DS1820.h"

#define DATA_PIN        PA_7
 
int main() {
    DS1820 probe(DATA_PIN);
    
    while(1) {
        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);
    }
}