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:
- Fayge
- Date:
- 2018-10-10
- Revision:
- 73:bc3b0ee46dfc
- Parent:
- 72:f678052af558
- Child:
- 76:04941d128fff
File content as of revision 73:bc3b0ee46dfc:
#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(SOIL_T_PIN);
AnalogIn humidSensor(SOIL_H_PIN);
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);
char* msg;
if(initSoilTemp(probe,SOIL_T_PIN)) {
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, false);
msg = genMessage( solH, airH, solT, airT, P,magXYZ);
// Display
pc.printf("\n\r=====| Data |=====\n\r");
pc.printf("H sol : %.2f %%\r\n", solH);
pc.printf("H air : %.2f %%\r\n", airH);
pc.printf("T sol : %.2f C\r\n", solT);
pc.printf("T air : %.2f C\r\n", airT);
pc.printf("Mag : X:%d ; Y:%d ; Z:%d\n\r", magXYZ[0], magXYZ[1], magXYZ[2]);
pc.printf("Pression : %ul Pa\r\n", P);
pc.printf("\n\r");
for(int i=0; i<12 ; ++i)
{
pc.printf("%x ",msg[i]);
}
wait(2);
}
}
