supprimer les warnings

Dependencies:   mbed projet_embarque WakeUp SigfoxToiture DHT DS1820

Committer:
3874313
Date:
Tue Oct 15 13:08:34 2019 +0000
Revision:
4:54e0220b3d83
Parent:
3:6af60ea9a240
Child:
5:a5a213701cd1
tous marche

Who changed what in which revision?

UserRevisionLine numberNew contents of line
liuyingshan 0:8fc2f1479292 1 #include"mbed.h"
liuyingshan 0:8fc2f1479292 2 #include"DS1820.h"
liuyingshan 0:8fc2f1479292 3 #include"DHT.h"
liuyingshan 0:8fc2f1479292 4 #include "TCS34725.h"
liuyingshan 0:8fc2f1479292 5 #include "Sigfox.h"
3874313 3:6af60ea9a240 6 #include "WakeUp.h"
liuyingshan 0:8fc2f1479292 7 #include <math.h>
liuyingshan 0:8fc2f1479292 8
liuyingshan 0:8fc2f1479292 9 #define GROVE_MOIST_MIN 0
liuyingshan 0:8fc2f1479292 10 #define GROVE_MOIST_MAX 0.55
3874313 3:6af60ea9a240 11 #define LOG_RANGE 5.0f
liuyingshan 0:8fc2f1479292 12
liuyingshan 0:8fc2f1479292 13 float Temp_Sol;
liuyingshan 0:8fc2f1479292 14 float Temp_Air;
liuyingshan 0:8fc2f1479292 15 float Humi_Air;
liuyingshan 0:8fc2f1479292 16 float Humi_Sol;
liuyingshan 0:8fc2f1479292 17 float Lumiere;
liuyingshan 0:8fc2f1479292 18 uint16_t r;
liuyingshan 0:8fc2f1479292 19 uint16_t g;
liuyingshan 0:8fc2f1479292 20 uint16_t b;
liuyingshan 0:8fc2f1479292 21 uint16_t c;
liuyingshan 0:8fc2f1479292 22
liuyingshan 0:8fc2f1479292 23 DHT dht22(D6,DHT22);//pin,type
liuyingshan 0:8fc2f1479292 24 DS1820 ds1820(A0);//pin
liuyingshan 0:8fc2f1479292 25 TCS34725 tcs34725(D4,D5); //I2C sda and scl
liuyingshan 0:8fc2f1479292 26 AnalogIn humigrove(A1);
liuyingshan 0:8fc2f1479292 27 AnalogIn lumiere(A5);
3874313 2:17db0f2dea0b 28 DigitalOut ledTest(LED1);
3874313 3:6af60ea9a240 29 DigitalOut mos(D9);
liuyingshan 0:8fc2f1479292 30
liuyingshan 0:8fc2f1479292 31 void ReadTempHumiAir(){
liuyingshan 0:8fc2f1479292 32 int err=1;
liuyingshan 0:8fc2f1479292 33 while(err!=0){
liuyingshan 0:8fc2f1479292 34 err=dht22.readData();
3874313 3:6af60ea9a240 35 //ledTest = 1;
liuyingshan 0:8fc2f1479292 36 wait(1);
liuyingshan 0:8fc2f1479292 37 }
liuyingshan 0:8fc2f1479292 38 if(err==0){
liuyingshan 0:8fc2f1479292 39 Temp_Air= dht22.ReadTemperature(CELCIUS);
liuyingshan 0:8fc2f1479292 40 Humi_Air=dht22.ReadHumidity();
3874313 3:6af60ea9a240 41 //ledTest = 0;
liuyingshan 0:8fc2f1479292 42 }
3874313 2:17db0f2dea0b 43
liuyingshan 0:8fc2f1479292 44 }
liuyingshan 0:8fc2f1479292 45
liuyingshan 0:8fc2f1479292 46 void ReadTempSol(){
liuyingshan 0:8fc2f1479292 47 if (ds1820.begin()) {
liuyingshan 0:8fc2f1479292 48 ds1820.startConversion(); // start temperature conversion from analog to digital
liuyingshan 0:8fc2f1479292 49 wait(1); // let DS1820 complete the temperature conversion
liuyingshan 0:8fc2f1479292 50 Temp_Sol = ds1820.read();
liuyingshan 0:8fc2f1479292 51 }
liuyingshan 0:8fc2f1479292 52 }
liuyingshan 0:8fc2f1479292 53
liuyingshan 0:8fc2f1479292 54 void ReadRGBC(){
liuyingshan 0:8fc2f1479292 55 if(tcs34725.init(TCS34725_INTEGRATIONTIME_101MS, TCS34725_GAIN_60X)){
liuyingshan 0:8fc2f1479292 56 tcs34725.getColor(r,g,b,c);
liuyingshan 0:8fc2f1479292 57 r/=256;
liuyingshan 0:8fc2f1479292 58 g/=256;
liuyingshan 0:8fc2f1479292 59 b/=256;
liuyingshan 0:8fc2f1479292 60 c/=256;
liuyingshan 0:8fc2f1479292 61 }
liuyingshan 0:8fc2f1479292 62 }
liuyingshan 0:8fc2f1479292 63
liuyingshan 0:8fc2f1479292 64 void ReadHumiSol(){
liuyingshan 0:8fc2f1479292 65 float grove_moist=humigrove.read();
liuyingshan 0:8fc2f1479292 66 Humi_Sol= ((grove_moist-GROVE_MOIST_MIN) / (GROVE_MOIST_MAX - GROVE_MOIST_MIN)) * 100;
liuyingshan 0:8fc2f1479292 67 }
liuyingshan 0:8fc2f1479292 68
liuyingshan 0:8fc2f1479292 69 void ReadLumi(){
3874313 3:6af60ea9a240 70 float raw=lumiere.read();
3874313 4:54e0220b3d83 71 float loglux=raw*LOG_RANGE;
3874313 4:54e0220b3d83 72 Lumiere=(float)(pow(10,loglux)*255.0f)/10000;
3874313 3:6af60ea9a240 73 //Lumiere=loglux;
liuyingshan 0:8fc2f1479292 74 }
liuyingshan 0:8fc2f1479292 75
liuyingshan 0:8fc2f1479292 76 int main(){
liuyingshan 0:8fc2f1479292 77 //Serial at(D1,D0);
liuyingshan 0:8fc2f1479292 78 Sigfox sigfox(D1,D0);
3874313 3:6af60ea9a240 79 /*ledTest = 1;
3874313 3:6af60ea9a240 80 wait(20);
3874313 3:6af60ea9a240 81 ledTest = 0;
3874313 3:6af60ea9a240 82 wait(5);*/
3874313 3:6af60ea9a240 83 WakeUp::calibrate();
3874313 3:6af60ea9a240 84 //wait(30);
liuyingshan 0:8fc2f1479292 85
liuyingshan 0:8fc2f1479292 86 while(1){
3874313 3:6af60ea9a240 87 WakeUp::set(120);
3874313 3:6af60ea9a240 88 mos = 0;
3874313 3:6af60ea9a240 89 sigfox.wake();
3874313 3:6af60ea9a240 90 wait(2);
liuyingshan 0:8fc2f1479292 91 ReadTempHumiAir();
liuyingshan 0:8fc2f1479292 92 ReadTempSol();
liuyingshan 0:8fc2f1479292 93 ReadRGBC();
liuyingshan 0:8fc2f1479292 94 ReadHumiSol();
3874313 2:17db0f2dea0b 95 wait(1);
liuyingshan 0:8fc2f1479292 96 ReadLumi();
liuyingshan 0:8fc2f1479292 97 wait(1);
liuyingshan 0:8fc2f1479292 98 printf("R:%d, G:%d, B:%d\n\r", r, g, b);
3874313 2:17db0f2dea0b 99 sigfox.send((s16)(Temp_Air*10),(u16)(Humi_Air*10),(s16)(Temp_Sol*10),(u16)(Humi_Sol*10),
liuyingshan 0:8fc2f1479292 100 (u8)Lumiere,(u8)r,(u8)g,(u8)b);
3874313 3:6af60ea9a240 101 wait(10);
3874313 3:6af60ea9a240 102 mos = 1;
3874313 3:6af60ea9a240 103 //wait(10);
3874313 3:6af60ea9a240 104 sigfox.sleep();
3874313 3:6af60ea9a240 105 deepsleep();
liuyingshan 0:8fc2f1479292 106 }
liuyingshan 0:8fc2f1479292 107 }