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:
Thu Dec 12 16:01:01 2019 +0000
Parent:
30:0a25c02e25d9
Child:
32:4bb8ec535357
Commit message:
Code fonctionnel nouveau PCB

Changed in this revision

DS1820.lib Show annotated file Show diff for this revision Revisions of this file
define.hh 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
main.hh Show annotated file Show diff for this revision Revisions of this file
--- a/DS1820.lib	Wed Dec 11 17:26:05 2019 +0000
+++ b/DS1820.lib	Thu Dec 12 16:01:01 2019 +0000
@@ -1,1 +1,1 @@
-https://os.mbed.com/users/Sissors/code/DS1820/#236eb8f8e73a
+https://os.mbed.com/users/hudakz/code/DS1820/#db94b6510df6
--- a/define.hh	Wed Dec 11 17:26:05 2019 +0000
+++ b/define.hh	Thu Dec 12 16:01:01 2019 +0000
@@ -1,9 +1,10 @@
 #pragma once
 
 //#define DEBUG
-// #define SIGFOX
-//#define FLOOR_TEMPERATURE
-//#define FLOOR_HUMIDITY
-//#define AIR_PARAMETERS
-//#define RGB
+//#define SIGFOX
+#define FLOOR_TEMPERATURE
+#define FLOOR_HUMIDITY
+#define AIR_PARAMETERS
+#define RGB
 #define OLED
+#define INTERRUPTEUR
--- a/main.cpp	Wed Dec 11 17:26:05 2019 +0000
+++ b/main.cpp	Thu Dec 12 16:01:01 2019 +0000
@@ -14,18 +14,28 @@
 }
 
 #ifdef FLOOR_TEMPERATURE
-float temp_sol()
+void temp_sol()
 {
-    DS.convertTemperature(true, DS1820::all_devices);
-    if (DS.unassignedProbe(D2)){
-        #ifdef DEBUG
-        pc.printf( "D3 not assigned\n\r");
-        #endif
+    int result = 0;
+    ds1820.begin();
+    ds1820.startConversion();   // start temperature conversion from analog to digital
+    wait(1.0);                  // let DS1820 complete the temperature conversion
+    result = ds1820.read(temperature_sol); // read temperature from DS1820 and perform cyclic redundancy check (CRC)
+    #ifdef DEBUG
+    switch (result) {
+        case 0:                 // no errors -> 'temp' contains the value of measured temperature
+            pc.printf("temp = %3.1f C\r\n", temperature_sol);
+            break;
+
+        case 1:                 // no sensor present -> 'temp' is not updated
+            pc.printf("no sensor present\n\r");
+            break;
+
+        case 2:                 // CRC error -> 'temp' is not updated
+            pc.printf("CRC error\r\n");
     }
-    #ifdef DEBUG
-    pc.printf("temp sol: %.1f\n\r", DS.temperature());
     #endif
-    return DS.temperature();
+    
 }
 #endif
 
@@ -114,7 +124,7 @@
     pc.printf("Reading Data\n\r");
     #endif
     #ifdef FLOOR_TEMPERATURE
-    temperature_sol = temp_sol();
+    temp_sol();
     #endif
     #ifdef FLOOR_HUMIDITY
     humidity_sol = fct_humidity_sol();
--- a/main.hh	Wed Dec 11 17:26:05 2019 +0000
+++ b/main.hh	Thu Dec 12 16:01:01 2019 +0000
@@ -9,11 +9,8 @@
 #include "standard_font.h"
 #include "bold_font.h"
 
-#define DUREE_OFF 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
+#define DUREE_OFF 5                          // Durée en seconde entre deux mesures
+#define DUREE_ECRAN_ON  10                   // Durée en seconde d'éveil de l'écran
 
 Ticker timeScreen;
 
@@ -25,7 +22,7 @@
 Serial wisol(D1,D0);
 #endif
 
-I2C i2c_1(I2C_SDA, I2C_SCL);
+I2C i2c_1(D4, D5);
 I2C i2c_2(D12,A6);
 
 #ifdef OLED
@@ -37,7 +34,7 @@
 
 // Capteurs
 #ifdef FLOOR_TEMPERATURE
-DS1820 DS(A3);                              // temperature sol
+DS1820 ds1820(A3);                              // temperature sol
 #endif
 
 #ifdef FLOOR_HUMIDITY
@@ -53,7 +50,7 @@
 #endif
 
 // Fonctions
-float   temp_sol(void);
+void    temp_sol(void);
 int     fct_humidity_sol(void);
 void    fct_RGB(void);
 void    sendDataSigfox(void);