supprimer les warnings

Dependencies:   mbed projet_embarque WakeUp SigfoxToiture DHT DS1820

Committer:
liuyingshan
Date:
Tue Oct 01 13:23:57 2019 +0000
Revision:
0:8fc2f1479292
Child:
1:61623b5d178c
df

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