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:
- 67:3ccbc6a532eb
- Parent:
- 66:cbfcea17a3c5
- Child:
- 69:9ad4bce37c63
- Child:
- 70:1e2e21c377ed
File content as of revision 67:3ccbc6a532eb:
#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"
Serial wisol(SERIAL_PORT);
Serial pc(USBTX, USBRX);
DHT sensor(PIN_NAME, DHTtype);
HP20x_dev barometre(HP20X_I2C_PORT);
HMC5883L hmc5883(HMC5883_I2C_PORT);
DS1820 probe(SOIL_T_PIN);
AnalogIn humidSensor(SOIL_H_PIN);
int main() {
if(initSoilTemp(probe,PA_5))
pc.printf("unassigned Probe\r\n");
float airValue(AIR_SOIL_HUMIDITY);
float waterValue(WATER_SOIL_HUMIDITY);
while(1) {
float airH = 0,airT = 0;
int16_t magXYZ[3];
long P = 0;
/*
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
hmc5883.getXYZ(magXYZ);
get_T_H_air(&airT, &airH, sensor); // takes 2s to execute
P = pression(&barometre);
float soilH = getSoilHumidity( humidSensor, airValue,waterValue, true);
float soilT = getSoilTemperature(probe);
if(soilT == DS1820::invalid_conversion)
pc.printf("Error with soil temperature probe : not connected\n\r");
// Display
pc.printf("\n=====| Data |=====\n");
pc.printf("H air : %.2f %%\r\n", airH);
pc.printf("T air : %.2f oC\r\n", airT);
pc.printf("H soil : %.2f %%\r\n", soilH);
pc.printf("T soil : %.2f oC\r\n", soilT);
pc.printf("Pression : %lu m\n", P);
pc.printf("Mag : X:%d ; Y:%d ; Z:%d\n", magXYZ[0], magXYZ[1], magXYZ[2]);
wait(5);
}
}
