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 WakeUp QMC5883L DHT22 DS1820
main.cpp
- Committer:
- raminou
- Date:
- 2018-10-02
- Revision:
- 1:6b6f96cbd12c
- Parent:
- 0:1c266599e07b
- Child:
- 5:d805b1c2dc1e
File content as of revision 1:6b6f96cbd12c:
#include "mbed.h"
#include "WakeUp.h"
#include "DHT22.h"
#include "HP20x_dev.h"
#define DEBUG 1
#ifdef DEBUG
Serial pc(USBTX, USBRX);
#endif
// HP20x_dev capt_barometer(D4, D5);
// I2C capt_magnetometer(D4, D5);
// AnalogIn capt_ground_humidity(A0); // SEN0
DHT22 capt_thermo_air_humidity(D3); // DHT22
Serial sigfox(D1, D0);
char message[50] = {};
long pressure = 1000;
float air_temperature = 20;
float air_humidity = 50;
int ground_temperature = 20;
int ground_humidity = 50;
void mycallback()
{
}
int main()
{
sigfox.printf("\r\n");
#ifdef DEBUG
pc.printf("\r\n\r\n\r\nInit...\r\n");
#endif
while(1) {
/*
// Temperature Sol
// Humidite Sol
ground_humidity = capt_ground_humidity.read();
*/
// Temperature et Humidite Air
if(capt_thermo_air_humidity.sample())
{
air_temperature = capt_thermo_air_humidity.getTemperature() / 10.0;
air_humidity = capt_thermo_air_humidity.getHumidity() / 10.0;
}
// Pression
/*
if(barometer.isAvailible())
pressure = capt_barometer.ReadPressure()
// Magnetometre
*/
// Affichage pour debug
#ifdef DEBUG
// pc.printf("Pressure: %d\r\n", pressure);
// pc.printf("Ground Temperature: %.1f\r|\t Ground Humidity: %f\r\n", ground_temperature, ground_humidity);
pc.printf("Air Temperature: %.1f\t|\tAir Humidity: %.1f\r\n", air_temperature, air_humidity);
#endif
// Envoie sigfox
sprintf(message, "AT$SF=%04x%02x\r\n", (int)(air_temperature*10), (int)(air_humidity));
#ifdef DEBUG
pc.printf("%s", message);
#endif
sigfox.printf("%s", message);
// DEEPSLEEP
/*
WakeUp::set_ms(10000);
WakeUp::attach(&mycallback);
deepsleep();
*/
wait(120);
}
}
