main.cpp 853 Bytes
#include "mbed.h"
#include "HumidityDevice.h"

#define ADDRESS 0x80

I2C i2c(D14, D15);
DigitalOut led1(LED1);
Serial pc(SERIAL_TX, SERIAL_RX);

int main()
{
    pc.printf("starting..."); 
    HumidityDevice humidityDevice(&pc, &i2c, true);
            
    if(humidityDevice.find()){
        humidityDevice.setup();
        
        while(1) 
        {
            led1 = 1;
            
            char *data;
            humidityDevice.read(data);
            
            if(humidityDevice.hasReadTemperature()){
                pc.printf("Temperature : %f\n", humidityDevice.getTemperature()); 
                pc.printf("Humidite : %f\n", humidityDevice.getHumidity()); 
            } else {
                pc.printf("Humidite : %f\n", humidityDevice.getHumidity()); 
            }
            led1 = 0;
            wait(0.5);
        }
    }
}