![](/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:
- 1:3fc11a745984
- Parent:
- 0:e030be8f0310
- Child:
- 2:0bfe25431e8e
--- a/main.cpp Mon Oct 07 10:03:30 2019 +0000 +++ b/main.cpp Mon Oct 07 18:13:11 2019 +0000 @@ -1,55 +1,59 @@ #include "mbed.h" - +#include "DS1820.h" +#include "SHT21_ncleee.h" +#include "Adafruit_TCS34725.h" +#include "ssd1306.h" Serial pc(SERIAL_TX, SERIAL_RX); -Serial nucleo(D1,D0); -//Ticker cadence; - -#include "DS1820.h" -DS1820 DS(D3); // capteur temperature sol +Serial nucleo(D1,D0); +I2C i2c(D4, D5); - -AnalogIn capteur_humidite_sol(A0); // capteur humidité sol +// capteur temperature sol +DS1820 DS(D3); +// capteur humidité sol +AnalogIn capteur_humidity_sol(A0); -#include "SHT21_ncleee.h" -I2C i2c(D4, D5); // capteur humidité & temp de l'air +// capteur humidité + température air SHT21 sht(&i2c); -#include "Adafruit_TCS34725.h" // capteur RGB +// capteur RGB Adafruit_TCS34725 RGBsens = Adafruit_TCS34725(&i2c, TCS34725_INTEGRATIONTIME_2_4MS, TCS34725_GAIN_16X); -AnalogIn ain(A1); // capteur lumière +// capteur lumière +AnalogIn ain(A1); -float temp_sol(void); -int fct_humidite_sol(void); -void fct_RGB(unsigned char *pr, unsigned char *pg, unsigned char *pb); -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); +// 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); +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); -int main() { - - float t; - unsigned char humidite_sol; - float temp_air; - unsigned char hum_air; + + float temperature_sol; + unsigned char humidity_sol; + float temperature_air; + unsigned char humidity_air; unsigned char pr, pg, pb; unsigned short lum; - //cadence.attach(&sendDataSigfox, ); +int main() { + + while(1) { - t = temp_sol(); - pc.printf("T sol = %.2f\n\r", t); + temperature_sol = temp_sol(); + pc.printf("T sol = %.2f\n\r", temperature_sol); - humidite_sol = fct_humidite_sol(); - pc.printf("H sol = %d\n\r", humidite_sol); + humidity_sol = fct_humidity_sol(); + pc.printf("H sol = %d\n\r", humidity_sol); - temp_air = sht.readTemp(); - pc.printf("temp_air = %.2f\n\r", temp_air); - hum_air = sht.readHumidity(); - pc.printf("hum_air = %d\n\r", hum_air); + temperature_air = sht.readTemp(); + pc.printf("temperature_air = %.2f\n\r", temperature_air); + humidity_air = sht.readHumidity(); + pc.printf("humidity_air = %d\n\r", humidity_air); fct_RGB(&pr, &pg, &pb); pc.printf("red=%d green=%d blue=%d\n\r", pr, pg, pb); @@ -57,8 +61,7 @@ lum = fct_lumiere(); pc.printf("lumiere = %d\n\r", lum); - - sendDataSigfox(t, &humidite_sol, temp_air, &hum_air, &lum, &pr, &pg, &pb); + sendDataSigfox(temperature_sol, &humidity_sol, temperature_air, &humidity_air, &lum, &pr, &pg, &pb); pc.printf("\n\r"); wait(30); @@ -75,12 +78,12 @@ return DS.temperature(); } -int fct_humidite_sol(void) +int fct_humidity_sol(void) { float val_min = 0.377; float val_max = 0.772; float mesure, mesure_etalonnee; - mesure = capteur_humidite_sol.read(); + mesure = capteur_humidity_sol.read(); mesure_etalonnee = (1-((mesure - val_min)/(val_max - val_min)))*100; return (int) mesure_etalonnee; }