delay 10s

Dependencies:   HX711 DHT DS1820

Revision:
5:df7af32714c0
Parent:
4:809b9c3a1739
Child:
6:5edb45f97ffe
diff -r 809b9c3a1739 -r df7af32714c0 main.cpp
--- a/main.cpp	Sun Nov 22 17:43:42 2020 +0000
+++ b/main.cpp	Sun Nov 22 18:04:18 2020 +0000
@@ -1,9 +1,10 @@
 #include "mbed.h"
 #include "DHT.h"
 #include "DS1820.h"
+#include "HX711.h"
 
-#define   DHT_DATA_PIN  D4
-#define   DHT_DATA_PIN  D5
+#define   DHT1_DATA_PIN  D4
+#define   DHT2_DATA_PIN  D5
 
 
 DS1820      ds1820_1(D3);  // substitute D8 with the actual pin name connected to the DS1820 sensor
@@ -12,8 +13,8 @@
 float       temp2 = 0;
 int         result = 0;
 
-DHT sensor1(DHT_DATA_PIN, DHT22);                    //DHT(PinName pin, eType DHTtype)
-DHT sensor2(DHT_DATA_PIN, DHT22);                    //DHT(PinName pin, eType DHTtype)
+DHT sensor1(DHT1_DATA_PIN, DHT22);                    //DHT(PinName pin, eType DHTtype)
+DHT sensor2(DHT2_DATA_PIN, DHT22);                    //DHT(PinName pin, eType DHTtype)
 HX711 loadcell(D12, D11);
 
 Serial pc(USBTX, USBRX); // tx, rx
@@ -21,8 +22,10 @@
 
 int main()
 {
-    int error = 0;
-    float h = 0.0f, c = 0.0f;
+    int error1 = 0;
+    int error2 = 0;
+    float h_int = 0.0f, c_int = 0.0f,c_moyenne_int = 0.0f,h_ext = 0.0f,c_ext =0.0f;
+    float valeur = 0.3f,balance=0.2f;
     pc.baud(9600);
     device.baud(9600);
     
@@ -38,7 +41,7 @@
     while(1) {
         float valeur = loadcell.getValue();
         float balance = ((double)valeur - (double)valeurTare)/21500;
-        //pc.printf("Weight = %.2f\r\n", balance);
+        pc.printf("Weight = %.2f\r\n", balance);
         
         ds1820_1.startConversion();   // start temperature conversion from analog to digital
         ds1820_2.startConversion();   // start temperature conversion from analog to digital
@@ -58,11 +61,14 @@
         
         c_moyenne_int =(c_int + temp1 + temp2)/3;
         
-        // pc.printf("temperature = %4.2f\r\n", c);  // on affiche les valeurs sur teraTerm pour debug
-        //pc.printf("Humidite = %4.2f\r\n", h);
+        pc.printf("temperature_int = %4.2f\r\n", c_moyenne_int);  // on affiche les valeurs sur teraTerm pour debug
+        pc.printf("Humidite_int = %4.2f\r\n", h_int);
+        pc.printf("temperature_ext = %4.2f\r\n", c_ext);  // on affiche les valeurs sur teraTerm pour debug
+        pc.printf("Humidite_ext = %4.2f\r\n", h_ext);
+        
         
         
         device.printf("AT$SF=%02X%02X%02X%02X\r\n", (char) c_moyenne_int,(char) h_int, (char) c_ext, (char) h_ext,(char) balance);  // on envoie les données sur l'antenne
-        wait(10.0f);
+        wait(20.0f);
     }
 }