Projet Long pour AGRAL

Dependencies:   mbed OneWire DHT22 TSL2561 SSD1306

Committer:
Pipou
Date:
Tue Sep 12 10:15:22 2017 +0000
Revision:
4:2767fb09ac47
Parent:
3:e369ee47403e
Child:
5:e3a7dc396048
Tout les capteurs (pas test?)

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
Pipou 4:2767fb09ac47 6 //Déclaration variables
Pipou 4:2767fb09ac47 7 TSL2561 Lum(PB_7,PB_6); // Luminosité (I2C:SDA,SCL)
Pipou 4:2767fb09ac47 8 DHT22 Tem_Hum_A(PA_11); // Température & Humidité air
Pipou 4:2767fb09ac47 9 OneWire Tem_S(PA_8); // Température sol
Pipou 4:2767fb09ac47 10 AnalogIn Hum_S(PA_0); // Huminidité sol
Pipou 4:2767fb09ac47 11 Serial pc(PA_2,PA_3); //Serial : Tx,Rx
Pipou 0:75cfe7e78e4b 12
Pipou 0:75cfe7e78e4b 13 int main() {
Pipou 4:2767fb09ac47 14 //OneWire Tem_S
pgeorge 2:1e52e7fab454 15 char _id[16];
Pipou 4:2767fb09ac47 16 DeviceAddresses* devAddresses = Tem_S.getFoundDevAddresses();
Pipou 4:2767fb09ac47 17 uint8_t foundNum = Tem_S.getFoundDevNum();
pgeorge 3:e369ee47403e 18
Pipou 0:75cfe7e78e4b 19 while(1) {
Pipou 4:2767fb09ac47 20 OneWireDeviceTemperature::startConversationForAll(&Tem_S, OWTEMP_11_BIT);
pgeorge 2:1e52e7fab454 21 for (uint8_t i = 0; i < foundNum; i++) {
Pipou 4:2767fb09ac47 22 OneWireDevice* owDevice = OneWireDeviceFactory::init(&Tem_S, (*devAddresses)[i]);
pgeorge 2:1e52e7fab454 23
pgeorge 2:1e52e7fab454 24 if (owDevice->getFamily() != ONEWIRE_DS18B20_FAMILY) // currently only DS18B20 supports
pgeorge 2:1e52e7fab454 25 continue;
pgeorge 2:1e52e7fab454 26
pgeorge 2:1e52e7fab454 27 owDevice->generateId(_id);
pgeorge 3:e369ee47403e 28
pgeorge 3:e369ee47403e 29
Pipou 4:2767fb09ac47 30 Tem_Hum_A.sample();
Pipou 4:2767fb09ac47 31 printf( "Lum: %f \tTemp_A: %d \tHum_A: %d \tTemp_S: %f \tHum_S: %f\r\n", Lum.lux(),Tem_Hum_A.getTemperature(), Tem_Hum_A.getHumidity(),owDevice->sendGetCommand(GET_TEMPERATURE),Hum_S.read());
pgeorge 2:1e52e7fab454 32 delete owDevice;
Pipou 4:2767fb09ac47 33 }
Pipou 4:2767fb09ac47 34 wait(5); // Frenquence : 200Hz
Pipou 0:75cfe7e78e4b 35 }
Pipou 0:75cfe7e78e4b 36 }
pgeorge 2:1e52e7fab454 37