Plant Monitoring Project

Dependencies:   mbed SHT21_ncleee WakeUp SSD1306 DHT Adafruit_TCS34725 DS1820

Files at this revision

API Documentation at this revision

Comitter:
Germaint
Date:
Mon Nov 04 09:00:13 2019 +0000
Parent:
18:d30cd2967da4
Child:
20:79f4ef29eafd
Commit message:
version fonctionnelle

Changed in this revision

WakeUp.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/WakeUp.lib	Mon Nov 04 09:00:13 2019 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/teams/Radiopotache/code/WakeUp/#b6bd5ab62934
--- a/main.cpp	Tue Oct 22 15:19:31 2019 +0000
+++ b/main.cpp	Mon Nov 04 09:00:13 2019 +0000
@@ -4,16 +4,20 @@
 #include "Adafruit_TCS34725.h"
 #include "ssd1306.h"
 
-#define DUREE_MESURE 3         // Durée en seconde entre deux mesures
-#define DUREE_ECRAN_ON 10       // Durée en seconde d'éveil de l'écran
+#define DUREE_MESURE 10         // Durée en seconde entre deux mesures
+#define DUREE_ECRAN_ON  5      // Durée en seconde d'éveil de l'écran
+
+#define I2C_SDA D4
+#define I2C_SCL D5
 
 Ticker timeScreen;
 
+
 //Serial pc(SERIAL_TX, SERIAL_RX);
 Serial nucleo(D1,D0);
 
-I2C i2c(D4, D5);                // Pour les deux capteurs i2c
-SSD1306 oled(D12, A6);
+I2C i2c(I2C_SDA, I2C_SCL);                // Pour les deux capteurs i2c
+SSD1306 oled(I2C_SDA, I2C_SCL);
 
 // capteur temperature sol
 DS1820 DS(D3); 
@@ -56,14 +60,18 @@
     //Initialisation de l'interruption
     bouton.fall(interruption_bouton);
     
-    oled.speed (SSD1306::Medium);
+    // Affichage logo pour initialisation
+    oled.wake();
     oled.init();
     oled.cls(0,1);
-    oled.set_contrast(200);
+    oled.locate(4,4);
+    oled.printf("2PA2S");
+    oled.redraw();
+    wait(1);
+    oled.cls(0,1);
     oled.sleep();
         
     while(1) {
-        
       readData();
       wait(DUREE_MESURE);
     }
@@ -116,14 +124,12 @@
     
 void oledData(void){
     if(!oled_on){
-        //pc.printf("Turning on screen\n\r");
         oled.wake();
         //oled.speed (SSD1306::Medium);
         //oled.init();
         //oled.set_contrast(200);
         oled_on = 1;
     }
-    //pc.printf("Displaying data\n\r");
     oled.cls(0,1);
     oled.locate(0,0);
     oled.printf("AIR T : %.1f", temperature_air);
@@ -154,19 +160,14 @@
 void interruption_bouton(){
     bouton.disable_irq();
     if(!oled_on){
-        //pc.printf("Interruption avec ecran eteint\n\r");
         oledData();
         timeScreen.attach(&turnOffScreen,DUREE_ECRAN_ON);
     }
-    /*else{
-        pc.printf("Interruption avec ecran allume\n\r");
-        readData();
-    }*/
+    
     bouton.enable_irq();
 }
 
 void turnOffScreen(void){
-    //pc.printf("Extinction ecran\n\r");
     timeScreen.detach();
     oled_on = 0;
     oled.sleep();