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 08 10:04:41 2018 +0000
Parent:
49:b1ac7ebb715f
Child:
53:a0752606d02c
Commit message:
add magnetic and altitude sensors

Changed in this revision

Adafruit_GFX.lib Show annotated file Show diff for this revision Revisions of this file
HMC5883L.lib 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
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Adafruit_GFX.lib	Mon Oct 08 10:04:41 2018 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/nkhorman/code/Adafruit_GFX/#7fb1d4d3525d
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/HMC5883L.lib	Mon Oct 08 10:04:41 2018 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/tylerjw/code/HMC5883L/#bc4e1201e092
--- a/config.h	Mon Oct 08 08:44:16 2018 +0000
+++ b/config.h	Mon Oct 08 10:04:41 2018 +0000
@@ -2,21 +2,25 @@
 #define __CONFIG__
 
 // communication
-#define SERIAL_PORT D1, D0
-#define WAIT_TIME 60*15 // 15 minutes
+#define SERIAL_PORT                 D1, D0
+#define WAIT_TIME                   60*15 // 15 minutes
 
 // T_H_air
-#define PIN_NAME D6
-#define DHTtype DHT22
+#define PIN_NAME                    D6
+#define DHTtype                     DHT22
 
 // H_sol
-#define LOW_H 160
-#define HIGH_H 520
+#define LOW_H                       160
+#define HIGH_H                      520
 
 // Altitude
-#define HP20X_I2C_DEV_ID 0xEC
+#define HP20X_I2C_DEV_ID            0xEC
+#define HP20X_I2C_PORT              D12, A6
+
+// Magnetometer
+#define HMC5883_I2C_PORT            D4, D5
 
 // Warnings
-#define W_AIR LED3
+#define W_AIR                       LED3
 
 #endif
\ No newline at end of file
--- a/main.cpp	Mon Oct 08 08:44:16 2018 +0000
+++ b/main.cpp	Mon Oct 08 10:04:41 2018 +0000
@@ -3,17 +3,21 @@
 #include "communication.h"
 #include "T_H_air.h"
 #include "altitude.h"
+#include "HMC5883L.h"
 
 
 Serial wisol(SERIAL_PORT);
 Serial pc(USBTX, USBRX);
 DHT sensor(PIN_NAME, DHTtype);
-I2C hp206c(D12, A6);
+I2C hp206c(HP20X_I2C_PORT);
+HMC5883L hmc5883(HMC5883_I2C_PORT);
 
 int main() {
     while(1) {
         float airH, airT;
         char *message;
+        int16_t magXYZ[3];
+        unsigned long alt;
         /*
         read T&H air
         read T sol
@@ -28,10 +32,13 @@
         airT = airTemperature(sensor);
         //message = genMessage(airT, airH);
         //wisol.printf("AT$SF=%s\r\n", message);
-        unsigned long alt = readAltitude(&hp206c);
+        alt = readAltitude(&hp206c);
+        hmc5883.getXYZ(magXYZ);
+        pc.printf("\n=====| Data |=====\n");
         pc.printf("H air : %f\n", airH);
         pc.printf("T air : %f\n", airT);
         pc.printf("altitude : %lu\n", alt);
+        pc.printf("Mag : X:%d ; Y:%d ; Z:%d\n", magXYZ[0], magXYZ[1], magXYZ[2]);
         wait(1);
     }
 }