Plant Monitoring Project
Dependencies: mbed SHT21_ncleee WakeUp SSD1306 DHT Adafruit_TCS34725 DS1820
main.hh@36:9976876a2fee, 2020-01-13 (annotated)
- Committer:
- Germaint
- Date:
- Mon Jan 13 10:40:05 2020 +0000
- Revision:
- 36:9976876a2fee
- Parent:
- 35:d87c1391706a
Foctionnel sans SB (40 sec entre deux mesures)
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Germaint | 25:77322fbe298e | 1 | #pragma once |
Germaint | 25:77322fbe298e | 2 | |
Germaint | 23:424b3149003b | 3 | #include "define.hh" |
Germaint | 23:424b3149003b | 4 | #include "mbed.h" |
Germaint | 23:424b3149003b | 5 | #include "DS1820.h" |
Germaint | 34:fb1b9c5e5cf3 | 6 | #include "DHT.h" |
Germaint | 23:424b3149003b | 7 | #include "Adafruit_TCS34725.h" |
Germaint | 23:424b3149003b | 8 | #include "ssd1306.h" |
Germaint | 30:0a25c02e25d9 | 9 | #include "standard_font.h" |
Germaint | 30:0a25c02e25d9 | 10 | #include "bold_font.h" |
Germaint | 34:fb1b9c5e5cf3 | 11 | #include "WakeUp.h" |
Germaint | 23:424b3149003b | 12 | |
Germaint | 35:d87c1391706a | 13 | #define DUREE_OFF 30 // Durée en seconde entre deux mesures + 8 secondes pour le module sigfox dans le code |
Germaint | 34:fb1b9c5e5cf3 | 14 | #define DUREE_ECRAN_ON 10 // Durée en seconde d'éveil de l'écran |
Germaint | 23:424b3149003b | 15 | |
Germaint | 34:fb1b9c5e5cf3 | 16 | #define NB_MESURES 100 |
Germaint | 34:fb1b9c5e5cf3 | 17 | |
Germaint | 34:fb1b9c5e5cf3 | 18 | #define BATTERIE_MIN 30 |
Germaint | 35:d87c1391706a | 19 | #define BATTERIE_MAX 39 |
Germaint | 34:fb1b9c5e5cf3 | 20 | |
Germaint | 23:424b3149003b | 21 | |
Germaint | 32:4bb8ec535357 | 22 | #ifdef INTERRUPTEUR |
Germaint | 32:4bb8ec535357 | 23 | DigitalOut interrupteur(D11); |
Germaint | 32:4bb8ec535357 | 24 | #endif |
Germaint | 32:4bb8ec535357 | 25 | |
Germaint | 23:424b3149003b | 26 | #ifdef DEBUG |
Germaint | 23:424b3149003b | 27 | Serial pc(SERIAL_TX, SERIAL_RX); |
Germaint | 23:424b3149003b | 28 | #endif |
Germaint | 23:424b3149003b | 29 | |
Germaint | 23:424b3149003b | 30 | #ifdef SIGFOX |
Germaint | 23:424b3149003b | 31 | Serial wisol(D1,D0); |
Germaint | 23:424b3149003b | 32 | #endif |
Germaint | 23:424b3149003b | 33 | |
Germaint | 34:fb1b9c5e5cf3 | 34 | //I2C i2c_1(D4, D5); |
Germaint | 30:0a25c02e25d9 | 35 | I2C i2c_2(D12,A6); |
Germaint | 23:424b3149003b | 36 | |
Germaint | 23:424b3149003b | 37 | #ifdef OLED |
Germaint | 30:0a25c02e25d9 | 38 | // D6 D9 D10 A4 D2 |
Germaint | 30:0a25c02e25d9 | 39 | SSD1306 oled(PB_1, PA_8, PA_11, PA_5, PA_12); |
Germaint | 23:424b3149003b | 40 | #endif |
Germaint | 23:424b3149003b | 41 | |
Germaint | 34:fb1b9c5e5cf3 | 42 | //Mesure niveau batterie |
Germaint | 34:fb1b9c5e5cf3 | 43 | #ifdef BATTERY_LVL |
Germaint | 34:fb1b9c5e5cf3 | 44 | AnalogIn battery(A1); |
Germaint | 34:fb1b9c5e5cf3 | 45 | #endif |
Germaint | 34:fb1b9c5e5cf3 | 46 | |
Germaint | 30:0a25c02e25d9 | 47 | InterruptIn bouton(A2); |
Germaint | 23:424b3149003b | 48 | |
Germaint | 23:424b3149003b | 49 | // Capteurs |
Germaint | 23:424b3149003b | 50 | #ifdef FLOOR_TEMPERATURE |
Germaint | 31:45f4bfde0b9a | 51 | DS1820 ds1820(A3); // temperature sol |
Germaint | 23:424b3149003b | 52 | #endif |
Germaint | 23:424b3149003b | 53 | |
Germaint | 23:424b3149003b | 54 | #ifdef FLOOR_HUMIDITY |
Germaint | 23:424b3149003b | 55 | AnalogIn capteur_humidity_sol(A0); // humidité sol |
Germaint | 23:424b3149003b | 56 | #endif |
Germaint | 23:424b3149003b | 57 | |
Germaint | 23:424b3149003b | 58 | |
Germaint | 23:424b3149003b | 59 | #ifdef RGB |
Germaint | 30:0a25c02e25d9 | 60 | Adafruit_TCS34725 RGBsens = Adafruit_TCS34725(&i2c_2, TCS34725_INTEGRATIONTIME_154MS, TCS34725_GAIN_1X); // RGB |
Germaint | 23:424b3149003b | 61 | #endif |
Germaint | 23:424b3149003b | 62 | |
Germaint | 34:fb1b9c5e5cf3 | 63 | #ifdef AIR_PARAMETERS_DHT22 |
Germaint | 34:fb1b9c5e5cf3 | 64 | DHT dht_sensor(D5, 22); |
Germaint | 34:fb1b9c5e5cf3 | 65 | #endif |
Germaint | 34:fb1b9c5e5cf3 | 66 | |
Germaint | 23:424b3149003b | 67 | // Fonctions |
Germaint | 34:fb1b9c5e5cf3 | 68 | void air_temp_hum(void); |
Germaint | 31:45f4bfde0b9a | 69 | void temp_sol(void); |
Germaint | 23:424b3149003b | 70 | int fct_humidity_sol(void); |
Germaint | 23:424b3149003b | 71 | void fct_RGB(void); |
Germaint | 23:424b3149003b | 72 | void sendDataSigfox(void); |
Germaint | 23:424b3149003b | 73 | void oledData(void); |
Germaint | 23:424b3149003b | 74 | void readData(void); |
Germaint | 23:424b3149003b | 75 | void interruption_bouton(void); |
Germaint | 23:424b3149003b | 76 | void turnOffScreen(void); |
Germaint | 23:424b3149003b | 77 | void initOLED(void); |
Germaint | 34:fb1b9c5e5cf3 | 78 | void readBatteryLvl(void); |
Germaint | 34:fb1b9c5e5cf3 | 79 | |
Germaint | 23:424b3149003b | 80 | |
Germaint | 23:424b3149003b | 81 | // Variables globales |
Germaint | 23:424b3149003b | 82 | bool oled_on = 0; // flag OLED |
Germaint | 23:424b3149003b | 83 | float temperature_sol; |
Germaint | 23:424b3149003b | 84 | unsigned char humidity_sol; |
Germaint | 23:424b3149003b | 85 | float temperature_air; |
Germaint | 23:424b3149003b | 86 | unsigned char humidity_air; |
Germaint | 23:424b3149003b | 87 | unsigned char pr, pg, pb; |
Germaint | 23:424b3149003b | 88 | unsigned short lum; |
Germaint | 34:fb1b9c5e5cf3 | 89 | char vBat; |
Germaint | 34:fb1b9c5e5cf3 | 90 | bool flag_readData = true; |