![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Plant Monitoring Project
Dependencies: mbed SHT21_ncleee WakeUp SSD1306 DHT Adafruit_TCS34725 DS1820
Diff: main.cpp
- Revision:
- 3:fc704c1d3087
- Parent:
- 2:0bfe25431e8e
- Child:
- 4:d7e305e06e1a
--- a/main.cpp Tue Oct 08 13:14:07 2019 +0000 +++ b/main.cpp Tue Oct 08 14:38:36 2019 +0000 @@ -31,7 +31,7 @@ // Définition de fonctions float temp_sol(void); int fct_humidity_sol(void); -void fct_RGB(unsigned char *pr, unsigned char *pg, unsigned char *pb); +void fct_RGB(unsigned char *pr, unsigned char *pg, unsigned char *pb, unsigned short *lux); float fct_lumiere(void); void sendDataSigfox(float tempSol, unsigned char *humSol, float tempAir, unsigned char *humAir, unsigned short *lux, unsigned char *R, unsigned char *G, unsigned char *B); void oledData(void); @@ -65,10 +65,10 @@ humidity_air = sht.readHumidity(); //pc.printf("humidity_air = %d\n\r", humidity_air); - fct_RGB(&pr, &pg, &pb); + fct_RGB(&pr, &pg, &pb, &lum); //pc.printf("red=%d green=%d blue=%d\n\r", pr, pg, pb); - lum = fct_lumiere(); + //lum = fct_lumiere(); //pc.printf("lumiere = %d\n\r", lum); oledData(); @@ -99,7 +99,7 @@ return (int) mesure_etalonnee; } -void fct_RGB(unsigned char *pr, unsigned char *pg, unsigned char *pb) +void fct_RGB(unsigned char *pr, unsigned char *pg, unsigned char *pb, unsigned short *lux) { int somme; uint16_t clear, red, green, blue; @@ -113,18 +113,17 @@ *pr = red*100/somme; *pg = green*100/somme; *pb = blue*100/somme; + *lux = clear; } float fct_lumiere() { - float convertedValue; - float valueIn; - float rawRange = 0xFFFF; // 3.3v + float valueIn, logLux; float logRange = 5.0; // 3.3v = 10^5 lux - valueIn = ain.read_u16(); - float logLux = valueIn * logRange / rawRange; - convertedValue = pow(10, logLux); - return convertedValue; + + valueIn = ain.read(); + logLux = valueIn * logRange; + return pow(10, logLux); }