projet capteur connecté ST/SE

Dependencies:   HP206C mbed HMC5883L DHT DS1820

Files at this revision

API Documentation at this revision

Comitter:
MathieuM
Date:
Mon Oct 01 10:32:14 2018 +0000
Parent:
45:60f602ecd59b
Child:
47:81848525ea2a
Commit message:
updated main

Changed in this revision

T_H_air.cpp Show annotated file Show diff for this revision Revisions of this file
T_H_air.h Show annotated file Show diff for this revision Revisions of this file
config.h 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
--- a/T_H_air.cpp	Mon Oct 01 10:02:53 2018 +0000
+++ b/T_H_air.cpp	Mon Oct 01 10:32:14 2018 +0000
@@ -1,10 +1,8 @@
 #include "T_H_air.h"
 #include "config.h"
 
-DHT sensor(PinName, DHTtype);
-DigitalOut warningAir(LED3);
-
-float airHumidity(){
+float airHumidity(DHT sensor){
+    DigitalOut warningAir(W_AIR);
     int err = 0;
     
     err = sensor.readData();
@@ -15,7 +13,8 @@
         return EXIT_FAILURE ;
     }
     
-float airTemperature(){
+float airTemperature(DHT sensor){
+    DigitalOut warningAir(W_AIR);
     int err = 0;
     
     err = sensor.readData();
--- a/T_H_air.h	Mon Oct 01 10:02:53 2018 +0000
+++ b/T_H_air.h	Mon Oct 01 10:32:14 2018 +0000
@@ -2,5 +2,5 @@
 #include "DHT.h"
 #include "config.h"
 
-float airHumidity( void );
-float airTemperature();
\ No newline at end of file
+float airHumidity(DHT sensor);
+float airTemperature(DHT sensor);
\ No newline at end of file
--- a/config.h	Mon Oct 01 10:02:53 2018 +0000
+++ b/config.h	Mon Oct 01 10:32:14 2018 +0000
@@ -6,11 +6,14 @@
 #define WAIT_TIME 60*15 // 15 minutes
 
 // T_H_air
-#define PinName D2
+#define PIN_NAME D2
 #define DHTtype DHT22
 
 // H_sol
 #define LOW_H 160
 #define HIGH_H 520
 
+// Warnings
+#define W_AIR LED3
+
 #endif
\ No newline at end of file
--- a/main.cpp	Mon Oct 01 10:02:53 2018 +0000
+++ b/main.cpp	Mon Oct 01 10:32:14 2018 +0000
@@ -1,11 +1,15 @@
 #include "mbed.h"
 #include "config.h"
 #include "communication.h"
+#include "T_H_air.h"
 
 Serial wisol(SERIAL_PORT);
+DHT sensor(PIN_NAME, DHTtype);
 
 int main() {
     while(1) {
+        float airH, airT;
+        char *message;
         /*
         read T&H air
         read T sol
@@ -16,6 +20,10 @@
         m = genMessage(T_air, H_air, T_sol, H_sol, Pressure, Mag)
         sendMessage(m)
         */
+        airH = airHumidity(sensor);
+        airT = airTemperature(sensor);
+        message = genMessage(airT, airH);
+        wisol.printf("AT$SF=%s\r\n", message);
         wait(WAIT_TIME);
     }
 }