Plant Monitoring Project

Dependencies:   mbed SHT21_ncleee WakeUp SSD1306 DHT Adafruit_TCS34725 DS1820

Committer:
Germaint
Date:
Thu Dec 12 16:25:33 2019 +0000
Revision:
32:4bb8ec535357
Parent:
31:45f4bfde0b9a
Child:
33:b576ea9bf0e3
Ajout interrupteur (probleme RGB);

Who changed what in which revision?

UserRevisionLine numberNew 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 23:424b3149003b 6 #include "SHT21_ncleee.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 23:424b3149003b 11
Germaint 32:4bb8ec535357 12 #define DUREE_OFF 2 // Durée en seconde entre deux mesures
Germaint 31:45f4bfde0b9a 13 #define DUREE_ECRAN_ON 10 // Durée en seconde d'éveil de l'écran
Germaint 23:424b3149003b 14
Germaint 23:424b3149003b 15 Ticker timeScreen;
Germaint 23:424b3149003b 16
Germaint 32:4bb8ec535357 17 #ifdef INTERRUPTEUR
Germaint 32:4bb8ec535357 18 DigitalOut interrupteur(D11);
Germaint 32:4bb8ec535357 19 #endif
Germaint 32:4bb8ec535357 20
Germaint 23:424b3149003b 21 #ifdef DEBUG
Germaint 23:424b3149003b 22 Serial pc(SERIAL_TX, SERIAL_RX);
Germaint 23:424b3149003b 23 #endif
Germaint 23:424b3149003b 24
Germaint 23:424b3149003b 25 #ifdef SIGFOX
Germaint 23:424b3149003b 26 Serial wisol(D1,D0);
Germaint 23:424b3149003b 27 #endif
Germaint 23:424b3149003b 28
Germaint 31:45f4bfde0b9a 29 I2C i2c_1(D4, D5);
Germaint 30:0a25c02e25d9 30 I2C i2c_2(D12,A6);
Germaint 23:424b3149003b 31
Germaint 23:424b3149003b 32 #ifdef OLED
Germaint 30:0a25c02e25d9 33 // D6 D9 D10 A4 D2
Germaint 30:0a25c02e25d9 34 SSD1306 oled(PB_1, PA_8, PA_11, PA_5, PA_12);
Germaint 23:424b3149003b 35 #endif
Germaint 23:424b3149003b 36
Germaint 30:0a25c02e25d9 37 InterruptIn bouton(A2);
Germaint 23:424b3149003b 38
Germaint 23:424b3149003b 39 // Capteurs
Germaint 23:424b3149003b 40 #ifdef FLOOR_TEMPERATURE
Germaint 31:45f4bfde0b9a 41 DS1820 ds1820(A3); // temperature sol
Germaint 23:424b3149003b 42 #endif
Germaint 23:424b3149003b 43
Germaint 23:424b3149003b 44 #ifdef FLOOR_HUMIDITY
Germaint 23:424b3149003b 45 AnalogIn capteur_humidity_sol(A0); // humidité sol
Germaint 23:424b3149003b 46 #endif
Germaint 23:424b3149003b 47
Germaint 23:424b3149003b 48 #ifdef AIR_PARAMETERS
Germaint 30:0a25c02e25d9 49 SHT21 sht(&i2c_1); // humidité + température air
Germaint 23:424b3149003b 50 #endif
Germaint 23:424b3149003b 51
Germaint 23:424b3149003b 52 #ifdef RGB
Germaint 30:0a25c02e25d9 53 Adafruit_TCS34725 RGBsens = Adafruit_TCS34725(&i2c_2, TCS34725_INTEGRATIONTIME_154MS, TCS34725_GAIN_1X); // RGB
Germaint 23:424b3149003b 54 #endif
Germaint 23:424b3149003b 55
Germaint 23:424b3149003b 56 // Fonctions
Germaint 31:45f4bfde0b9a 57 void temp_sol(void);
Germaint 23:424b3149003b 58 int fct_humidity_sol(void);
Germaint 23:424b3149003b 59 void fct_RGB(void);
Germaint 23:424b3149003b 60 void sendDataSigfox(void);
Germaint 23:424b3149003b 61 void oledData(void);
Germaint 23:424b3149003b 62 void readData(void);
Germaint 23:424b3149003b 63 void interruption_bouton(void);
Germaint 23:424b3149003b 64 void turnOffScreen(void);
Germaint 23:424b3149003b 65 void initOLED(void);
Germaint 23:424b3149003b 66
Germaint 23:424b3149003b 67 // Variables globales
Germaint 23:424b3149003b 68 bool oled_on = 0; // flag OLED
Germaint 23:424b3149003b 69 float temperature_sol;
Germaint 23:424b3149003b 70 unsigned char humidity_sol;
Germaint 23:424b3149003b 71 float temperature_air;
Germaint 23:424b3149003b 72 unsigned char humidity_air;
Germaint 23:424b3149003b 73 unsigned char pr, pg, pb;
Germaint 23:424b3149003b 74 unsigned short lum;