Mathieu Moneyron / Mbed 2 deprecated projetS1

Dependencies:   HP206C mbed HMC5883L DHT DS1820

Committer:
SBACCARI
Date:
Tue Oct 09 15:58:00 2018 +0000
Revision:
72:f678052af558
Parent:
71:b31e3ee29dd0
Child:
73:bc3b0ee46dfc
v0.3 : T_H_air, T_H_soil, pression, genMsg, champ.Mag en bon fonctionnement

Who changed what in which revision?

UserRevisionLine numberNew contents of line
MathieuM 0:fa6e7dd26ef2 1 #include "mbed.h"
MathieuM 45:60f602ecd59b 2 #include "config.h"
MathieuM 45:60f602ecd59b 3 #include "communication.h"
MathieuM 46:40b6bbf6167e 4 #include "T_H_air.h"
SBACCARI 67:3ccbc6a532eb 5 #include "T_H_soil.h"
MathieuM 49:b1ac7ebb715f 6 #include "altitude.h"
MathieuM 52:d49b6f468b97 7 #include "HMC5883L.h"
MathieuM 49:b1ac7ebb715f 8
SBACCARI 72:f678052af558 9 DS1820 probe(PA_5);
SBACCARI 72:f678052af558 10 AnalogIn humidSensor(PA_6);
MathieuM 45:60f602ecd59b 11 Serial wisol(SERIAL_PORT);
MathieuM 49:b1ac7ebb715f 12 Serial pc(USBTX, USBRX);
MathieuM 46:40b6bbf6167e 13 DHT sensor(PIN_NAME, DHTtype);
SBACCARI 66:cbfcea17a3c5 14 HP20x_dev barometre(HP20X_I2C_PORT);
MathieuM 52:d49b6f468b97 15 HMC5883L hmc5883(HMC5883_I2C_PORT);
MathieuM 0:fa6e7dd26ef2 16
SBACCARI 72:f678052af558 17 int main()
SBACCARI 72:f678052af558 18 {
SBACCARI 72:f678052af558 19 float airH = 0,airT = 0, solT = 0, solH = 0;;
SBACCARI 72:f678052af558 20 long P = 0;
SBACCARI 72:f678052af558 21 float airValue(AIR_SOIL_HUMIDITY);
SBACCARI 72:f678052af558 22 float waterValue(WATER_SOIL_HUMIDITY);
SBACCARI 72:f678052af558 23
SBACCARI 72:f678052af558 24
SBACCARI 72:f678052af558 25 if(initSoilTemp(probe,PA_5)) {
SBACCARI 72:f678052af558 26 pc.printf("unassigned Probe\r\n");
SBACCARI 72:f678052af558 27 }
SBACCARI 70:1e2e21c377ed 28 barometre.reset();
MathieuM 0:fa6e7dd26ef2 29 while(1) {
SBACCARI 72:f678052af558 30 float temp = 0;
MathieuM 52:d49b6f468b97 31 int16_t magXYZ[3];
SBACCARI 72:f678052af558 32
SBACCARI 54:61d003e0754d 33 //collect data
MathieuM 52:d49b6f468b97 34 hmc5883.getXYZ(magXYZ);
SBACCARI 65:3f898ad77cb5 35 get_T_H_air(&airT, &airH, sensor); // takes 2s to execute
SBACCARI 72:f678052af558 36 P = pression(&barometre); // takes 5s to execute
SBACCARI 72:f678052af558 37 temp = getSoilTemperature(probe);
SBACCARI 72:f678052af558 38 if(temp == DS1820::invalid_conversion) {
SBACCARI 72:f678052af558 39 pc.printf("Error with soil temperature probe : not connected\n\r");
SBACCARI 72:f678052af558 40 }
SBACCARI 72:f678052af558 41 else{
SBACCARI 72:f678052af558 42 solT = temp;
SBACCARI 72:f678052af558 43 }
SBACCARI 72:f678052af558 44 solH = getSoilHumidity( humidSensor, airValue,waterValue, true);
MathieuM 55:887edb961698 45 // Display
MathieuM 55:887edb961698 46 pc.printf("\n=====| Data |=====\n");
SBACCARI 72:f678052af558 47 pc.printf("T air : %.2f C\r\n", airT);
SBACCARI 67:3ccbc6a532eb 48 pc.printf("H air : %.2f %%\r\n", airH);
SBACCARI 72:f678052af558 49 pc.printf("T sol : %.2f C\r\n", solT);
SBACCARI 72:f678052af558 50 pc.printf("H sol : %.2f %%\r\n", solH);
SBACCARI 70:1e2e21c377ed 51 pc.printf("Pression : %ul Pa\r\n", P);
MathieuM 52:d49b6f468b97 52 pc.printf("Mag : X:%d ; Y:%d ; Z:%d\n", magXYZ[0], magXYZ[1], magXYZ[2]);
MathieuM 53:a0752606d02c 53 wait(5);
MathieuM 0:fa6e7dd26ef2 54 }
MathieuM 0:fa6e7dd26ef2 55 }