Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: HP206C mbed HMC5883L DHT DS1820
main.cpp@55:887edb961698, 2018-10-09 (annotated)
- Committer:
- MathieuM
- Date:
- Tue Oct 09 11:37:37 2018 +0000
- Revision:
- 55:887edb961698
- Parent:
- 53:a0752606d02c
- Child:
- 56:d9557c842d5d
HP206C changes
Who changed what in which revision?
| User | Revision | Line number | New 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" |
| MathieuM | 49:b1ac7ebb715f | 5 | #include "altitude.h" |
| MathieuM | 52:d49b6f468b97 | 6 | #include "HMC5883L.h" |
| MathieuM | 49:b1ac7ebb715f | 7 | |
| MathieuM | 0:fa6e7dd26ef2 | 8 | |
| MathieuM | 45:60f602ecd59b | 9 | Serial wisol(SERIAL_PORT); |
| MathieuM | 49:b1ac7ebb715f | 10 | Serial pc(USBTX, USBRX); |
| MathieuM | 46:40b6bbf6167e | 11 | DHT sensor(PIN_NAME, DHTtype); |
| MathieuM | 55:887edb961698 | 12 | HP20x_dev hp206c(HP20X_I2C_PORT); |
| MathieuM | 52:d49b6f468b97 | 13 | HMC5883L hmc5883(HMC5883_I2C_PORT); |
| MathieuM | 0:fa6e7dd26ef2 | 14 | |
| MathieuM | 0:fa6e7dd26ef2 | 15 | int main() { |
| MathieuM | 0:fa6e7dd26ef2 | 16 | while(1) { |
| MathieuM | 55:887edb961698 | 17 | float airH = 0, tmpH, tmpT, airT = 0; |
| MathieuM | 46:40b6bbf6167e | 18 | char *message; |
| MathieuM | 52:d49b6f468b97 | 19 | int16_t magXYZ[3]; |
| MathieuM | 52:d49b6f468b97 | 20 | unsigned long alt; |
| MathieuM | 33:2a6476c33e74 | 21 | /* |
| MathieuM | 33:2a6476c33e74 | 22 | read T&H air |
| MathieuM | 33:2a6476c33e74 | 23 | read T sol |
| MathieuM | 33:2a6476c33e74 | 24 | read H sol |
| MathieuM | 33:2a6476c33e74 | 25 | read Pressure |
| MathieuM | 33:2a6476c33e74 | 26 | read Magnetic |
| MathieuM | 33:2a6476c33e74 | 27 | |
| MathieuM | 33:2a6476c33e74 | 28 | m = genMessage(T_air, H_air, T_sol, H_sol, Pressure, Mag) |
| MathieuM | 33:2a6476c33e74 | 29 | sendMessage(m) |
| MathieuM | 33:2a6476c33e74 | 30 | */ |
| MathieuM | 53:a0752606d02c | 31 | //airH = airHumidity(sensor); |
| MathieuM | 53:a0752606d02c | 32 | //airT = airTemperature(sensor); |
| MathieuM | 48:824fda6804f1 | 33 | //message = genMessage(airT, airH); |
| MathieuM | 48:824fda6804f1 | 34 | //wisol.printf("AT$SF=%s\r\n", message); |
| MathieuM | 52:d49b6f468b97 | 35 | alt = readAltitude(&hp206c); |
| MathieuM | 52:d49b6f468b97 | 36 | hmc5883.getXYZ(magXYZ); |
| MathieuM | 53:a0752606d02c | 37 | tmpH = airHumidity(sensor); |
| MathieuM | 53:a0752606d02c | 38 | if( tmpH!=0){ |
| MathieuM | 53:a0752606d02c | 39 | airH = tmpH; |
| MathieuM | 53:a0752606d02c | 40 | } |
| MathieuM | 53:a0752606d02c | 41 | wait(2); |
| MathieuM | 53:a0752606d02c | 42 | tmpT = airTemperature(sensor); |
| MathieuM | 53:a0752606d02c | 43 | if( tmpT!=0 ){ |
| MathieuM | 53:a0752606d02c | 44 | airT=tmpT; |
| MathieuM | 53:a0752606d02c | 45 | } |
| MathieuM | 55:887edb961698 | 46 | |
| MathieuM | 55:887edb961698 | 47 | // Display |
| MathieuM | 55:887edb961698 | 48 | pc.printf("\n=====| Data |=====\n"); |
| MathieuM | 53:a0752606d02c | 49 | pc.printf("H air : %.2f \%\n", airH); |
| MathieuM | 53:a0752606d02c | 50 | pc.printf("T air : %.2f °C\n", airT); |
| MathieuM | 53:a0752606d02c | 51 | pc.printf("altitude : %lu m\n", alt); |
| 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 | } |
