ze

Dependencies:   mbed WakeUp OneWire

main.cpp

Committer:
mangalho_eanes
Date:
2020-11-22
Revision:
2:15f2d7d650bb
Parent:
1:f4088d23f670

File content as of revision 2:15f2d7d650bb:


#include "mbed.h"
#include "DS1820.h"
 
DS1820  ds1820(D9); 
Serial pc(USBTX,USBRX);
 
float sonde_f = 0;

int main() 
{

//------DS18B20------//
    while (1){
    if(ds1820.begin()) {
        ds1820.startConversion();    
        ThisThread::sleep_for(1000);  
        sonde_f = ds1820.read();
        pc.printf("%f", sonde_f);
    }
    else pc.printf("DS18B20 not found");
    }
    /*
    if(ds1820.begin()) { // si bus OneWire prêt (connexion entre maître et esclave)
        while(1) {
            
            wait_us(10000000);
            ds1820.startConversion();    
            ThisThread::sleep_for(1000);  
            printf("T = %4.2f\r\n", ds1820.read()); // renvoi temp dans le format "....,.." avec 0.0625 de résolution
        }
    } else
        pc.printf("Error DS1820 : not found.\r\n");
*/
}