Projet Long pour AGRAL

Dependencies:   mbed OneWire DHT22 TSL2561 SSD1306

Committer:
pgeorge
Date:
Tue Sep 12 09:04:46 2017 +0000
Revision:
3:e369ee47403e
Parent:
2:1e52e7fab454
Child:
4:2767fb09ac47
test capteurs:; -DHT22; -lux; -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 3:e369ee47403e 3 #include "TSL2561.h"
pgeorge 3:e369ee47403e 4 #include "DHT22.h"
pgeorge 3:e369ee47403e 5
pgeorge 3:e369ee47403e 6 TSL2561 lum_sensor( PB_7, PB_6 );
pgeorge 3:e369ee47403e 7 DHT22 dht22(PA_11);
pgeorge 2:1e52e7fab454 8
pgeorge 2:1e52e7fab454 9 OneWire owBus(PA_8);
Pipou 0:75cfe7e78e4b 10
Pipou 1:1b64ee29ae15 11 DigitalOut myled(PB_3);
Pipou 1:1b64ee29ae15 12 AnalogIn Hum(PA_0); //Entrée du capteur
Pipou 1:1b64ee29ae15 13 Serial pc(PA_2,PA_3); //Tx,Rx
Pipou 0:75cfe7e78e4b 14
Pipou 0:75cfe7e78e4b 15 int main() {
pgeorge 2:1e52e7fab454 16 char _id[16];
pgeorge 2:1e52e7fab454 17 DeviceAddresses* devAddresses = owBus.getFoundDevAddresses();
pgeorge 2:1e52e7fab454 18 uint8_t foundNum = owBus.getFoundDevNum();
pgeorge 3:e369ee47403e 19
pgeorge 3:e369ee47403e 20 //printf("OneWire: found %d devices\r\n", foundNum);
Pipou 0:75cfe7e78e4b 21 while(1) {
pgeorge 2:1e52e7fab454 22 OneWireDeviceTemperature::startConversationForAll(&owBus, OWTEMP_11_BIT);
pgeorge 2:1e52e7fab454 23 for (uint8_t i = 0; i < foundNum; i++) {
pgeorge 2:1e52e7fab454 24 OneWireDevice* owDevice = OneWireDeviceFactory::init(&owBus, (*devAddresses)[i]);
pgeorge 2:1e52e7fab454 25
pgeorge 2:1e52e7fab454 26 if (owDevice->getFamily() != ONEWIRE_DS18B20_FAMILY) // currently only DS18B20 supports
pgeorge 2:1e52e7fab454 27 continue;
pgeorge 2:1e52e7fab454 28
pgeorge 2:1e52e7fab454 29 owDevice->generateId(_id);
pgeorge 3:e369ee47403e 30
pgeorge 3:e369ee47403e 31
pgeorge 3:e369ee47403e 32 dht22.sample();
pgeorge 3:e369ee47403e 33 printf( "Luminosity: %f \ttemp: %d \thum: %d \ttemp_sol: %f\r\n", lum_sensor.lux(),dht22.getTemperature(), dht22.getHumidity(),owDevice->sendGetCommand(GET_TEMPERATURE) );
pgeorge 2:1e52e7fab454 34 delete owDevice;
pgeorge 2:1e52e7fab454 35 }
Pipou 1:1b64ee29ae15 36
pgeorge 2:1e52e7fab454 37 wait(5);
Pipou 0:75cfe7e78e4b 38 }
Pipou 0:75cfe7e78e4b 39 }
pgeorge 2:1e52e7fab454 40