
Projet Long pour AGRAL
Dependencies: mbed OneWire DHT22 TSL2561 SSD1306
Diff: main.cpp
- Revision:
- 4:2767fb09ac47
- Parent:
- 3:e369ee47403e
- Child:
- 5:e3a7dc396048
--- a/main.cpp Tue Sep 12 09:04:46 2017 +0000 +++ b/main.cpp Tue Sep 12 10:15:22 2017 +0000 @@ -3,25 +3,23 @@ #include "TSL2561.h" #include "DHT22.h" -TSL2561 lum_sensor( PB_7, PB_6 ); -DHT22 dht22(PA_11); - -OneWire owBus(PA_8); - -DigitalOut myled(PB_3); -AnalogIn Hum(PA_0); //Entrée du capteur -Serial pc(PA_2,PA_3); //Tx,Rx +//Déclaration variables +TSL2561 Lum(PB_7,PB_6); // Luminosité (I2C:SDA,SCL) +DHT22 Tem_Hum_A(PA_11); // Température & Humidité air +OneWire Tem_S(PA_8); // Température sol +AnalogIn Hum_S(PA_0); // Huminidité sol +Serial pc(PA_2,PA_3); //Serial : Tx,Rx int main() { + //OneWire Tem_S char _id[16]; - DeviceAddresses* devAddresses = owBus.getFoundDevAddresses(); - uint8_t foundNum = owBus.getFoundDevNum(); + DeviceAddresses* devAddresses = Tem_S.getFoundDevAddresses(); + uint8_t foundNum = Tem_S.getFoundDevNum(); - //printf("OneWire: found %d devices\r\n", foundNum); while(1) { - OneWireDeviceTemperature::startConversationForAll(&owBus, OWTEMP_11_BIT); + OneWireDeviceTemperature::startConversationForAll(&Tem_S, OWTEMP_11_BIT); for (uint8_t i = 0; i < foundNum; i++) { - OneWireDevice* owDevice = OneWireDeviceFactory::init(&owBus, (*devAddresses)[i]); + OneWireDevice* owDevice = OneWireDeviceFactory::init(&Tem_S, (*devAddresses)[i]); if (owDevice->getFamily() != ONEWIRE_DS18B20_FAMILY) // currently only DS18B20 supports continue; @@ -29,12 +27,11 @@ owDevice->generateId(_id); - dht22.sample(); - printf( "Luminosity: %f \ttemp: %d \thum: %d \ttemp_sol: %f\r\n", lum_sensor.lux(),dht22.getTemperature(), dht22.getHumidity(),owDevice->sendGetCommand(GET_TEMPERATURE) ); + Tem_Hum_A.sample(); + 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()); delete owDevice; - } - - wait(5); + } + wait(5); // Frenquence : 200Hz } }