projet d'environment

Dependencies:   mbed projet_embarque SigfoxToiture DHT DS1820

Files at this revision

API Documentation at this revision

Comitter:
liuyingshan
Date:
Tue Oct 01 13:23:57 2019 +0000
Commit message:
df

Changed in this revision

DHT.lib Show annotated file Show diff for this revision Revisions of this file
DS1820.lib Show annotated file Show diff for this revision Revisions of this file
SigfoxToiture.lib Show annotated file Show diff for this revision Revisions of this file
TCS34725.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /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
--- /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
--- /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
--- /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
--- /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);
+    }
+}
--- /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