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
- Committer:
- SBACCARI
- Date:
- 2018-10-09
- Revision:
- 72:f678052af558
- Parent:
- 71:b31e3ee29dd0
- Child:
- 73:bc3b0ee46dfc
File content as of revision 72:f678052af558:
#include "mbed.h"
#include "config.h"
#include "communication.h"
#include "T_H_air.h"
#include "T_H_soil.h"
#include "altitude.h"
#include "HMC5883L.h"
DS1820 probe(PA_5);
AnalogIn humidSensor(PA_6);
Serial wisol(SERIAL_PORT);
Serial pc(USBTX, USBRX);
DHT sensor(PIN_NAME, DHTtype);
HP20x_dev barometre(HP20X_I2C_PORT);
HMC5883L hmc5883(HMC5883_I2C_PORT);
int main()
{
float airH = 0,airT = 0, solT = 0, solH = 0;;
long P = 0;
float airValue(AIR_SOIL_HUMIDITY);
float waterValue(WATER_SOIL_HUMIDITY);
if(initSoilTemp(probe,PA_5)) {
pc.printf("unassigned Probe\r\n");
}
barometre.reset();
while(1) {
float temp = 0;
int16_t magXYZ[3];
//collect data
hmc5883.getXYZ(magXYZ);
get_T_H_air(&airT, &airH, sensor); // takes 2s to execute
P = pression(&barometre); // takes 5s to execute
temp = getSoilTemperature(probe);
if(temp == DS1820::invalid_conversion) {
pc.printf("Error with soil temperature probe : not connected\n\r");
}
else{
solT = temp;
}
solH = getSoilHumidity( humidSensor, airValue,waterValue, true);
// Display
pc.printf("\n=====| Data |=====\n");
pc.printf("T air : %.2f C\r\n", airT);
pc.printf("H air : %.2f %%\r\n", airH);
pc.printf("T sol : %.2f C\r\n", solT);
pc.printf("H sol : %.2f %%\r\n", solH);
pc.printf("Pression : %ul Pa\r\n", P);
pc.printf("Mag : X:%d ; Y:%d ; Z:%d\n", magXYZ[0], magXYZ[1], magXYZ[2]);
wait(5);
}
}
