Projet Long pour AGRAL

Dependencies:   mbed OneWire DHT22 TSL2561 SSD1306

Committer:
pgeorge
Date:
Tue Sep 12 07:21:14 2017 +0000
Revision:
2:1e52e7fab454
Parent:
1:1b64ee29ae15
Child:
3:e369ee47403e
test temp sol

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Pipou 0:75cfe7e78e4b 1 #include "mbed.h"
pgeorge 2:1e52e7fab454 2 #include "OneWire.h"
pgeorge 2:1e52e7fab454 3
pgeorge 2:1e52e7fab454 4 OneWire owBus(PA_8);
Pipou 0:75cfe7e78e4b 5
Pipou 1:1b64ee29ae15 6 DigitalOut myled(PB_3);
Pipou 1:1b64ee29ae15 7 AnalogIn Hum(PA_0); //Entrée du capteur
Pipou 1:1b64ee29ae15 8 Serial pc(PA_2,PA_3); //Tx,Rx
Pipou 0:75cfe7e78e4b 9
Pipou 0:75cfe7e78e4b 10 int main() {
pgeorge 2:1e52e7fab454 11 char _id[16];
pgeorge 2:1e52e7fab454 12 DeviceAddresses* devAddresses = owBus.getFoundDevAddresses();
pgeorge 2:1e52e7fab454 13 uint8_t foundNum = owBus.getFoundDevNum();
pgeorge 2:1e52e7fab454 14 printf("OneWire: found %d devices\r\n", foundNum);
Pipou 0:75cfe7e78e4b 15 while(1) {
pgeorge 2:1e52e7fab454 16 OneWireDeviceTemperature::startConversationForAll(&owBus, OWTEMP_11_BIT);
pgeorge 2:1e52e7fab454 17 for (uint8_t i = 0; i < foundNum; i++) {
pgeorge 2:1e52e7fab454 18 OneWireDevice* owDevice = OneWireDeviceFactory::init(&owBus, (*devAddresses)[i]);
pgeorge 2:1e52e7fab454 19
pgeorge 2:1e52e7fab454 20 if (owDevice->getFamily() != ONEWIRE_DS18B20_FAMILY) // currently only DS18B20 supports
pgeorge 2:1e52e7fab454 21 continue;
pgeorge 2:1e52e7fab454 22
pgeorge 2:1e52e7fab454 23 owDevice->generateId(_id);
pgeorge 2:1e52e7fab454 24 printf("OneWire: device #%s = %.4f*C\r\n", _id, (float) owDevice->sendGetCommand(GET_TEMPERATURE));
pgeorge 2:1e52e7fab454 25 delete owDevice;
pgeorge 2:1e52e7fab454 26 }
Pipou 1:1b64ee29ae15 27
pgeorge 2:1e52e7fab454 28 wait(5);
Pipou 0:75cfe7e78e4b 29 }
Pipou 0:75cfe7e78e4b 30 }
pgeorge 2:1e52e7fab454 31