Plant Monitoring Project
Dependencies: mbed SHT21_ncleee WakeUp SSD1306 DHT Adafruit_TCS34725 DS1820
main.hh@23:424b3149003b, 2019-11-28 (annotated)
- Committer:
- Germaint
- Date:
- Thu Nov 28 19:51:58 2019 +0000
- Revision:
- 23:424b3149003b
- Child:
- 24:6320b46719d6
mise en forme du code, facilite le debug
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Germaint | 23:424b3149003b | 1 | #include "define.hh" |
Germaint | 23:424b3149003b | 2 | #include "mbed.h" |
Germaint | 23:424b3149003b | 3 | #include "DS1820.h" |
Germaint | 23:424b3149003b | 4 | #include "SHT21_ncleee.h" |
Germaint | 23:424b3149003b | 5 | #include "Adafruit_TCS34725.h" |
Germaint | 23:424b3149003b | 6 | #include "ssd1306.h" |
Germaint | 23:424b3149003b | 7 | |
Germaint | 23:424b3149003b | 8 | #define DUREE_OFF 10 // Durée en seconde entre deux mesures |
Germaint | 23:424b3149003b | 9 | #define DUREE_ECRAN_ON 5 // Durée en seconde d'éveil de l'écran |
Germaint | 23:424b3149003b | 10 | |
Germaint | 23:424b3149003b | 11 | #define I2C_SDA D4 |
Germaint | 23:424b3149003b | 12 | #define I2C_SCL D5 |
Germaint | 23:424b3149003b | 13 | |
Germaint | 23:424b3149003b | 14 | Ticker timeScreen; |
Germaint | 23:424b3149003b | 15 | |
Germaint | 23:424b3149003b | 16 | #ifdef DEBUG |
Germaint | 23:424b3149003b | 17 | Serial pc(SERIAL_TX, SERIAL_RX); |
Germaint | 23:424b3149003b | 18 | #endif |
Germaint | 23:424b3149003b | 19 | |
Germaint | 23:424b3149003b | 20 | #ifdef SIGFOX |
Germaint | 23:424b3149003b | 21 | Serial wisol(D1,D0); |
Germaint | 23:424b3149003b | 22 | #endif |
Germaint | 23:424b3149003b | 23 | |
Germaint | 23:424b3149003b | 24 | I2C i2c(I2C_SDA, I2C_SCL); |
Germaint | 23:424b3149003b | 25 | |
Germaint | 23:424b3149003b | 26 | #ifdef OLED |
Germaint | 23:424b3149003b | 27 | SSD1306 oled(D12, A6); |
Germaint | 23:424b3149003b | 28 | #endif |
Germaint | 23:424b3149003b | 29 | |
Germaint | 23:424b3149003b | 30 | InterruptIn bouton(D10); |
Germaint | 23:424b3149003b | 31 | |
Germaint | 23:424b3149003b | 32 | // Capteurs |
Germaint | 23:424b3149003b | 33 | #ifdef FLOOR_TEMPERATURE |
Germaint | 23:424b3149003b | 34 | DS1820 DS(D2); // temperature sol |
Germaint | 23:424b3149003b | 35 | #endif |
Germaint | 23:424b3149003b | 36 | |
Germaint | 23:424b3149003b | 37 | #ifdef FLOOR_HUMIDITY |
Germaint | 23:424b3149003b | 38 | AnalogIn capteur_humidity_sol(A0); // humidité sol |
Germaint | 23:424b3149003b | 39 | #endif |
Germaint | 23:424b3149003b | 40 | |
Germaint | 23:424b3149003b | 41 | #ifdef AIR_PARAMETERS |
Germaint | 23:424b3149003b | 42 | SHT21 sht(&i2c); // humidité + température air |
Germaint | 23:424b3149003b | 43 | #endif |
Germaint | 23:424b3149003b | 44 | |
Germaint | 23:424b3149003b | 45 | #ifdef RGB |
Germaint | 23:424b3149003b | 46 | Adafruit_TCS34725 RGBsens = Adafruit_TCS34725(&i2c, TCS34725_INTEGRATIONTIME_154MS, TCS34725_GAIN_1X); // RGB |
Germaint | 23:424b3149003b | 47 | #endif |
Germaint | 23:424b3149003b | 48 | |
Germaint | 23:424b3149003b | 49 | // Fonctions |
Germaint | 23:424b3149003b | 50 | float temp_sol(void); |
Germaint | 23:424b3149003b | 51 | int fct_humidity_sol(void); |
Germaint | 23:424b3149003b | 52 | void fct_RGB(void); |
Germaint | 23:424b3149003b | 53 | void sendDataSigfox(void); |
Germaint | 23:424b3149003b | 54 | void oledData(void); |
Germaint | 23:424b3149003b | 55 | void readData(void); |
Germaint | 23:424b3149003b | 56 | void interruption_bouton(void); |
Germaint | 23:424b3149003b | 57 | void turnOffScreen(void); |
Germaint | 23:424b3149003b | 58 | void initOLED(void); |
Germaint | 23:424b3149003b | 59 | void mycallback(void); |
Germaint | 23:424b3149003b | 60 | |
Germaint | 23:424b3149003b | 61 | // Variables globales |
Germaint | 23:424b3149003b | 62 | bool oled_on = 0; // flag OLED |
Germaint | 23:424b3149003b | 63 | float temperature_sol; |
Germaint | 23:424b3149003b | 64 | unsigned char humidity_sol; |
Germaint | 23:424b3149003b | 65 | float temperature_air; |
Germaint | 23:424b3149003b | 66 | unsigned char humidity_air; |
Germaint | 23:424b3149003b | 67 | unsigned char pr, pg, pb; |
Germaint | 23:424b3149003b | 68 | unsigned short lum; |