projet capteur connecté ST/SE

Dependencies:   HP206C mbed HMC5883L DHT DS1820

Committer:
SBACCARI
Date:
Tue Oct 09 12:27:17 2018 +0000
Revision:
62:d902b1e77094
Parent:
53:a0752606d02c
Child:
64:7adaa9dfcb8c
function get_T_H_air in T_H_air.cpp

Who changed what in which revision?

UserRevisionLine numberNew contents of line
SBACCARI 29:e050039204ab 1 #include "T_H_air.h"
MathieuM 45:60f602ecd59b 2 #include "config.h"
SBACCARI 29:e050039204ab 3
MathieuM 53:a0752606d02c 4 float airHumidity(DHT sensor)
MathieuM 53:a0752606d02c 5 {
MathieuM 46:40b6bbf6167e 6 DigitalOut warningAir(W_AIR);
SBACCARI 29:e050039204ab 7 int err = 0;
MathieuM 53:a0752606d02c 8
SBACCARI 29:e050039204ab 9 err = sensor.readData();
MathieuM 53:a0752606d02c 10 while( !err ) {
MathieuM 53:a0752606d02c 11 err = sensor.readData();
SBACCARI 29:e050039204ab 12 return sensor.ReadHumidity() ;
SBACCARI 41:d3434f5816ad 13 }
MathieuM 53:a0752606d02c 14 return 0;
MathieuM 53:a0752606d02c 15 }
MathieuM 53:a0752606d02c 16
MathieuM 53:a0752606d02c 17 float airTemperature(DHT sensor)
MathieuM 53:a0752606d02c 18 {
MathieuM 46:40b6bbf6167e 19 DigitalOut warningAir(W_AIR);
SBACCARI 41:d3434f5816ad 20 int err = 0;
MathieuM 53:a0752606d02c 21
SBACCARI 41:d3434f5816ad 22 err = sensor.readData();
MathieuM 53:a0752606d02c 23 while( !err ) {
MathieuM 53:a0752606d02c 24 err = sensor.readData();
SBACCARI 41:d3434f5816ad 25 return sensor.ReadTemperature(CELCIUS) ;
MathieuM 53:a0752606d02c 26 }
MathieuM 53:a0752606d02c 27 return 0;
SBACCARI 62:d902b1e77094 28 }
SBACCARI 62:d902b1e77094 29
SBACCARI 62:d902b1e77094 30 void get_T_H_air(int* T, int* H, DHT sensor)
SBACCARI 62:d902b1e77094 31 {
SBACCARI 62:d902b1e77094 32 int tmpH, tmpT ;
SBACCARI 62:d902b1e77094 33
SBACCARI 62:d902b1e77094 34 tmpT = airTemperature(sensor);
SBACCARI 62:d902b1e77094 35 if( tmpT!=0 ) {
SBACCARI 62:d902b1e77094 36 *T=tmpT;
SBACCARI 62:d902b1e77094 37 }
SBACCARI 62:d902b1e77094 38 wait(2);
SBACCARI 62:d902b1e77094 39
SBACCARI 62:d902b1e77094 40 tmpH = airHumidity(sensor);
SBACCARI 62:d902b1e77094 41 if( tmpH!=0) {
SBACCARI 62:d902b1e77094 42 *H = tmpH;
SBACCARI 62:d902b1e77094 43 }
MathieuM 53:a0752606d02c 44 }