projet d'environment
Dependencies: mbed projet_embarque SigfoxToiture DHT DS1820
Revision 0:8fc2f1479292, committed 2019-10-01
- Comitter:
- liuyingshan
- Date:
- Tue Oct 01 13:23:57 2019 +0000
- Commit message:
- df
Changed in this revision
diff -r 000000000000 -r 8fc2f1479292 DHT.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/DHT.lib Tue Oct 01 13:23:57 2019 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/Wimpie/code/DHT/#9b5b3200688f
diff -r 000000000000 -r 8fc2f1479292 DS1820.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/DS1820.lib Tue Oct 01 13:23:57 2019 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/hudakz/code/DS1820/#db94b6510df6
diff -r 000000000000 -r 8fc2f1479292 SigfoxToiture.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SigfoxToiture.lib Tue Oct 01 13:23:57 2019 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/3874313/code/SigfoxToiture/#11f6ddd8fdbe
diff -r 000000000000 -r 8fc2f1479292 TCS34725.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TCS34725.lib Tue Oct 01 13:23:57 2019 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/liuyingshan/code/projet_embarque/#78f18887fd75
diff -r 000000000000 -r 8fc2f1479292 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Tue Oct 01 13:23:57 2019 +0000 @@ -0,0 +1,91 @@ +#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); + +void ReadTempHumiAir(){ + int err=1; + while(err!=0){ + err=dht22.readData(); + wait(1); + } + if(err==0){ + Temp_Air= dht22.ReadTemperature(CELCIUS); + Humi_Air=dht22.ReadHumidity(); + } + } + +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); + DigitalOut led(LED1);//test + + while(1){ + ReadTempHumiAir(); + ReadTempSol(); + ReadRGBC(); + ReadHumiSol(); + led=1;//test + wait(1); + led=0;//test + ReadLumi(); + wait(1); + printf("R:%d, G:%d, B:%d\n\r", r, g, b); + sigfox.send((s16)(Temp_Air*10.0),(u16)(Humi_Air*10.0),(s16)(Temp_Sol*10.0),(u16)(Humi_Sol*10.0), + (u8)Lumiere,(u8)r,(u8)g,(u8)b); + wait(120); + } +}
diff -r 000000000000 -r 8fc2f1479292 mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Tue Oct 01 13:23:57 2019 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400 \ No newline at end of file