projet capteur connecté ST/SE
Dependencies: HP206C mbed HMC5883L DHT DS1820
Revision 56:d9557c842d5d, committed 2018-10-09
- Comitter:
- MathieuM
- Date:
- Tue Oct 09 11:40:10 2018 +0000
- Parent:
- 54:61d003e0754d
- Parent:
- 55:887edb961698
- Child:
- 57:4ae308bac609
- Commit message:
- merge main
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
main.cpp.orig | Show annotated file Show diff for this revision Revisions of this file |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/HP206C.lib Tue Oct 09 11:40:10 2018 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/Dzhafarkhanov/code/HP206C/#573122fe4fd1
--- a/main.cpp Mon Oct 08 10:33:30 2018 +0000 +++ b/main.cpp Tue Oct 09 11:40:10 2018 +0000 @@ -9,12 +9,12 @@ Serial wisol(SERIAL_PORT); Serial pc(USBTX, USBRX); DHT sensor(PIN_NAME, DHTtype); -I2C hp206c(HP20X_I2C_PORT); +HP20x_dev hp206c(HP20X_I2C_PORT); HMC5883L hmc5883(HMC5883_I2C_PORT); int main() { while(1) { - float airH, tmpH, tmpT, airT; + float airH = 0, tmpH, tmpT, airT = 0; char *message; int16_t magXYZ[3]; unsigned long alt; @@ -40,7 +40,7 @@ tmpH = airHumidity(sensor); if( tmpH!=0){ airH = tmpH; - } + } wait(2); tmpT = airTemperature(sensor); if( tmpT!=0 ){
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp.orig Tue Oct 09 11:40:10 2018 +0000 @@ -0,0 +1,58 @@ +#include "mbed.h" +#include "config.h" +#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(HP20X_I2C_PORT); +HMC5883L hmc5883(HMC5883_I2C_PORT); + +int main() { + while(1) { + float airH, tmpH, tmpT, airT; + char *message; + int16_t magXYZ[3]; + unsigned long alt; + /* + read T&H air + read T sol + read H sol + read Pressure + read Magnetic + + 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); + */ + + //collect data + alt = readAltitude(&hp206c); + hmc5883.getXYZ(magXYZ); + tmpH = airHumidity(sensor); + if( tmpH!=0){ + airH = tmpH; + } + wait(2); + tmpT = airTemperature(sensor); + if( tmpT!=0 ){ + airT=tmpT; + } + + // Display + pc.printf("\n=====| Data |=====\n"); + pc.printf("H air : %.2f \%\n", airH); + pc.printf("T air : %.2f °C\n", airT); + pc.printf("altitude : %lu m\n", alt); + pc.printf("Mag : X:%d ; Y:%d ; Z:%d\n", magXYZ[0], magXYZ[1], magXYZ[2]); + wait(5); + } +}