supprimer les warnings
Dependencies: mbed projet_embarque WakeUp SigfoxToiture DHT DS1820
main.cpp
- Committer:
- 3874313
- Date:
- 2019-10-01
- Revision:
- 2:17db0f2dea0b
- Parent:
- 1:61623b5d178c
- Child:
- 3:6af60ea9a240
File content as of revision 2:17db0f2dea0b:
#include"mbed.h" #include"DS1820.h" #include"DHT.h" #include "TCS34725.h" #include "Sigfox.h" #include <math.h> #define GROVE_MOIST_MIN 0 #define GROVE_MOIST_MAX 0.55 #define LOG_RANGE 5 #define RAW_RANGE 1024 float Temp_Sol; float Temp_Air; float Humi_Air; float Humi_Sol; float Lumiere; uint16_t r; uint16_t g; uint16_t b; uint16_t c; DHT dht22(D6,DHT22);//pin,type DS1820 ds1820(A0);//pin TCS34725 tcs34725(D4,D5); //I2C sda and scl AnalogIn humigrove(A1); AnalogIn lumiere(A5); DigitalOut ledTest(LED1); void ReadTempHumiAir(){ int err=1; while(err!=0){ err=dht22.readData(); ledTest = 1; wait(1); } if(err==0){ Temp_Air= dht22.ReadTemperature(CELCIUS); Humi_Air=dht22.ReadHumidity(); ledTest = 0; } } void ReadTempSol(){ if (ds1820.begin()) { ds1820.startConversion(); // start temperature conversion from analog to digital wait(1); // let DS1820 complete the temperature conversion Temp_Sol = ds1820.read(); } } void ReadRGBC(){ if(tcs34725.init(TCS34725_INTEGRATIONTIME_101MS, TCS34725_GAIN_60X)){ tcs34725.getColor(r,g,b,c); r/=256; g/=256; b/=256; c/=256; } } void ReadHumiSol(){ float grove_moist=humigrove.read(); Humi_Sol= ((grove_moist-GROVE_MOIST_MIN) / (GROVE_MOIST_MAX - GROVE_MOIST_MIN)) * 100; } void ReadLumi(){ int raw=lumiere.read(); float loglux=raw*LOG_RANGE/RAW_RANGE; Lumiere=pow(10,loglux); } int main(){ //Serial at(D1,D0); Sigfox sigfox(D1,D0); while(1){ ReadTempHumiAir(); ReadTempSol(); ReadRGBC(); ReadHumiSol(); wait(1); ReadLumi(); wait(1); printf("R:%d, G:%d, B:%d\n\r", r, g, b); sigfox.send((s16)(Temp_Air*10),(u16)(Humi_Air*10),(s16)(Temp_Sol*10),(u16)(Humi_Sol*10), (u8)Lumiere,(u8)r,(u8)g,(u8)b); wait(120); /*printf("R:%d, G:%d, B:%d, temp: %f, hum: %f\r", r, g, b, Temp_Air, Humi_Air); wait(0.5);*/ } }