moha fehri
/
TEMPHUMRUCHE2
RUCHE
Diff: temphum.cpp
- Revision:
- 5:4510dda988cf
- Parent:
- 4:d4aa7422d519
--- a/temphum.cpp Tue Jan 15 16:47:09 2019 +0000 +++ b/temphum.cpp Mon Jan 21 11:35:50 2019 +0000 @@ -1,17 +1,43 @@ #include "mbed.h" #include "DHT22.h" #include "string.h" +#include "DS1820.h" DHT22 dht22(D3); +DS1820 probe[1] = {A4}; + Serial pc(USBTX,USBRX); + int main() { pc.baud(9600); - int humidite; - int temperature; - while(1) { - - dht22.sample() ; - humidite=dht22.getHumidity()/10.0; - temperature=dht22.getTemperature()/10.0; - pc.printf("temperature: %d humidity: %d\n\r",temperature,humidite); - wait(1); }} \ No newline at end of file + + int i; + int devices_found=0; + const int MAX_PROBES = 2; + float tempDs; //tempérarure de la sonde Ds18B20; + + //partie declarative DS18B20 + pc.printf("Started\r\n"); + pc.printf("search_ROM_setup\r\n"); + probe[0].search_ROM_setup(); + pc.printf("search_ROM\r\n"); + + while (probe[devices_found].search_ROM() and devices_found<MAX_PROBES-1) + devices_found++; + // If maximum number of probes are found, + // bump the counter to include the last array entry + + + //Fin de la partie declarative DS18B20 + while(1) { + + probe[0].convert_temperature(DS1820::all_devices); + for (i=0; i<devices_found; i++) { + + + + + tempDs = probe[i].temperature('c'); + pc.printf("Temperature: %.2f °C\r\n",tempDs); + } + wait(10); }} \ No newline at end of file