Plant Monitoring Project

Dependencies:   mbed SHT21_ncleee WakeUp SSD1306 DHT Adafruit_TCS34725 DS1820

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.hh Source File

main.hh

00001 #pragma once
00002 
00003 #include "define.hh"
00004 #include "mbed.h"
00005 #include "DS1820.h"
00006 #include "DHT.h"
00007 #include "Adafruit_TCS34725.h"
00008 #include "ssd1306.h"
00009 #include "standard_font.h"
00010 #include "bold_font.h"
00011 #include "WakeUp.h"
00012 
00013 #define DUREE_OFF 30                        // Durée en seconde entre deux mesures + 8 secondes pour le module sigfox dans le code
00014 #define DUREE_ECRAN_ON  10                 // Durée en seconde d'éveil de l'écran
00015 
00016 #define NB_MESURES 100
00017 
00018 #define BATTERIE_MIN 30
00019 #define BATTERIE_MAX 39
00020 
00021 
00022 #ifdef INTERRUPTEUR
00023 DigitalOut interrupteur(D11);
00024 #endif
00025 
00026 #ifdef DEBUG
00027 Serial pc(SERIAL_TX, SERIAL_RX);
00028 #endif
00029 
00030 #ifdef SIGFOX
00031 Serial wisol(D1,D0);
00032 #endif
00033 
00034 //I2C i2c_1(D4, D5);
00035 I2C i2c_2(D12,A6);
00036 
00037 #ifdef OLED
00038 // D6 D9 D10 A4 D2
00039 SSD1306 oled(PB_1, PA_8, PA_11, PA_5, PA_12);
00040 #endif
00041 
00042 //Mesure niveau batterie
00043 #ifdef BATTERY_LVL
00044 AnalogIn battery(A1);
00045 #endif
00046 
00047 InterruptIn bouton(A2);
00048 
00049 // Capteurs
00050 #ifdef FLOOR_TEMPERATURE
00051 DS1820 ds1820(A3);                              // temperature sol
00052 #endif
00053 
00054 #ifdef FLOOR_HUMIDITY
00055 AnalogIn capteur_humidity_sol(A0);          // humidité sol
00056 #endif
00057 
00058 
00059 #ifdef RGB
00060 Adafruit_TCS34725 RGBsens = Adafruit_TCS34725(&i2c_2, TCS34725_INTEGRATIONTIME_154MS, TCS34725_GAIN_1X);  // RGB
00061 #endif
00062 
00063 #ifdef AIR_PARAMETERS_DHT22
00064 DHT dht_sensor(D5, 22);
00065 #endif
00066 
00067 // Fonctions
00068 void    air_temp_hum(void);
00069 void    temp_sol(void);
00070 int     fct_humidity_sol(void);
00071 void    fct_RGB(void);
00072 void    sendDataSigfox(void);
00073 void    oledData(void);
00074 void    readData(void);
00075 void    interruption_bouton(void);
00076 void    turnOffScreen(void);
00077 void    initOLED(void);
00078 void    readBatteryLvl(void);
00079 
00080 
00081 // Variables globales
00082 bool            oled_on = 0;             // flag OLED
00083 float           temperature_sol;
00084 unsigned char   humidity_sol;
00085 float           temperature_air;
00086 unsigned char   humidity_air;
00087 unsigned char   pr, pg, pb;
00088 unsigned short  lum;
00089 char            vBat;
00090 bool            flag_readData = true;