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@66:cbfcea17a3c5, 2018-10-09 (annotated)
- Committer:
- SBACCARI
- Date:
- Tue Oct 09 14:43:03 2018 +0000
- Revision:
- 66:cbfcea17a3c5
- Parent:
- 65:3f898ad77cb5
- Child:
- 67:3ccbc6a532eb
function pression to get pressure value
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); |
| SBACCARI | 66:cbfcea17a3c5 | 12 | HP20x_dev barometre(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) { |
| SBACCARI | 62:d902b1e77094 | 17 | float airH = 0,airT = 0; |
| MathieuM | 46:40b6bbf6167e | 18 | char *message; |
| MathieuM | 52:d49b6f468b97 | 19 | int16_t magXYZ[3]; |
| MathieuM | 52:d49b6f468b97 | 20 | unsigned long alt; |
| SBACCARI | 66:cbfcea17a3c5 | 21 | long P = 0; |
| MathieuM | 33:2a6476c33e74 | 22 | /* |
| MathieuM | 33:2a6476c33e74 | 23 | read T&H air |
| MathieuM | 33:2a6476c33e74 | 24 | read T sol |
| MathieuM | 33:2a6476c33e74 | 25 | read H sol |
| MathieuM | 33:2a6476c33e74 | 26 | read Pressure |
| MathieuM | 33:2a6476c33e74 | 27 | read Magnetic |
| MathieuM | 33:2a6476c33e74 | 28 | |
| MathieuM | 33:2a6476c33e74 | 29 | m = genMessage(T_air, H_air, T_sol, H_sol, Pressure, Mag) |
| MathieuM | 33:2a6476c33e74 | 30 | sendMessage(m) |
| SBACCARI | 54:61d003e0754d | 31 | |
| SBACCARI | 54:61d003e0754d | 32 | airH = airHumidity(sensor); |
| SBACCARI | 54:61d003e0754d | 33 | airT = airTemperature(sensor); |
| SBACCARI | 54:61d003e0754d | 34 | message = genMessage(airT, airH); |
| SBACCARI | 54:61d003e0754d | 35 | wisol.printf("AT$SF=%s\r\n", message); |
| MathieuM | 33:2a6476c33e74 | 36 | */ |
| SBACCARI | 54:61d003e0754d | 37 | |
| SBACCARI | 54:61d003e0754d | 38 | //collect data |
| SBACCARI | 64:7adaa9dfcb8c | 39 | //alt = readAltitude(&hp206c); |
| MathieuM | 52:d49b6f468b97 | 40 | hmc5883.getXYZ(magXYZ); |
| SBACCARI | 65:3f898ad77cb5 | 41 | get_T_H_air(&airT, &airH, sensor); // takes 2s to execute |
| SBACCARI | 66:cbfcea17a3c5 | 42 | P = pression(barometre); |
| MathieuM | 55:887edb961698 | 43 | |
| MathieuM | 55:887edb961698 | 44 | // Display |
| MathieuM | 55:887edb961698 | 45 | pc.printf("\n=====| Data |=====\n"); |
| MathieuM | 53:a0752606d02c | 46 | pc.printf("H air : %.2f \%\n", airH); |
| MathieuM | 53:a0752606d02c | 47 | pc.printf("T air : %.2f °C\n", airT); |
| MathieuM | 53:a0752606d02c | 48 | pc.printf("altitude : %lu m\n", alt); |
| MathieuM | 52:d49b6f468b97 | 49 | pc.printf("Mag : X:%d ; Y:%d ; Z:%d\n", magXYZ[0], magXYZ[1], magXYZ[2]); |
| MathieuM | 53:a0752606d02c | 50 | wait(5); |
| MathieuM | 0:fa6e7dd26ef2 | 51 | } |
| MathieuM | 0:fa6e7dd26ef2 | 52 | } |
