moha fehri
/
TEMPHUMRUCHE2
RUCHE
temphum.cpp@5:4510dda988cf, 2019-01-21 (annotated)
- Committer:
- moham
- Date:
- Mon Jan 21 11:35:50 2019 +0000
- Revision:
- 5:4510dda988cf
- Parent:
- 4:d4aa7422d519
ruche
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
moham | 4:d4aa7422d519 | 1 | #include "mbed.h" |
moham | 4:d4aa7422d519 | 2 | #include "DHT22.h" |
moham | 4:d4aa7422d519 | 3 | #include "string.h" |
moham | 5:4510dda988cf | 4 | #include "DS1820.h" |
moham | 4:d4aa7422d519 | 5 | DHT22 dht22(D3); |
moham | 5:4510dda988cf | 6 | DS1820 probe[1] = {A4}; |
moham | 5:4510dda988cf | 7 | |
moham | 4:d4aa7422d519 | 8 | Serial pc(USBTX,USBRX); |
moham | 5:4510dda988cf | 9 | |
moham | 4:d4aa7422d519 | 10 | int main() { |
moham | 4:d4aa7422d519 | 11 | |
moham | 4:d4aa7422d519 | 12 | pc.baud(9600); |
moham | 5:4510dda988cf | 13 | |
moham | 5:4510dda988cf | 14 | int i; |
moham | 5:4510dda988cf | 15 | int devices_found=0; |
moham | 5:4510dda988cf | 16 | const int MAX_PROBES = 2; |
moham | 5:4510dda988cf | 17 | float tempDs; //tempérarure de la sonde Ds18B20; |
moham | 5:4510dda988cf | 18 | |
moham | 5:4510dda988cf | 19 | //partie declarative DS18B20 |
moham | 5:4510dda988cf | 20 | pc.printf("Started\r\n"); |
moham | 5:4510dda988cf | 21 | pc.printf("search_ROM_setup\r\n"); |
moham | 5:4510dda988cf | 22 | probe[0].search_ROM_setup(); |
moham | 5:4510dda988cf | 23 | pc.printf("search_ROM\r\n"); |
moham | 5:4510dda988cf | 24 | |
moham | 5:4510dda988cf | 25 | while (probe[devices_found].search_ROM() and devices_found<MAX_PROBES-1) |
moham | 5:4510dda988cf | 26 | devices_found++; |
moham | 5:4510dda988cf | 27 | // If maximum number of probes are found, |
moham | 5:4510dda988cf | 28 | // bump the counter to include the last array entry |
moham | 5:4510dda988cf | 29 | |
moham | 5:4510dda988cf | 30 | |
moham | 5:4510dda988cf | 31 | //Fin de la partie declarative DS18B20 |
moham | 5:4510dda988cf | 32 | while(1) { |
moham | 5:4510dda988cf | 33 | |
moham | 5:4510dda988cf | 34 | probe[0].convert_temperature(DS1820::all_devices); |
moham | 5:4510dda988cf | 35 | for (i=0; i<devices_found; i++) { |
moham | 5:4510dda988cf | 36 | |
moham | 5:4510dda988cf | 37 | |
moham | 5:4510dda988cf | 38 | |
moham | 5:4510dda988cf | 39 | |
moham | 5:4510dda988cf | 40 | tempDs = probe[i].temperature('c'); |
moham | 5:4510dda988cf | 41 | pc.printf("Temperature: %.2f °C\r\n",tempDs); |
moham | 5:4510dda988cf | 42 | } |
moham | 5:4510dda988cf | 43 | wait(10); }} |