MansOS Humidity

From DiLab
Revision as of 10:02, 21 September 2011 by Girts (talk | contribs) (New page: To use humidity sensor, make the following changes to you application: * enable humidity sensor by adding the following line to config file: USE_HUMIDITY = y * If using generic MSP430 pla...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

To use humidity sensor, make the following changes to you application:

  • enable humidity sensor by adding the following line to config file:
USE_HUMIDITY = y
  • If using generic MSP430 platforms, which use the same humidity sensor as TelosB, additional definition in config file required:
USE_TELOSB_HUMIDITY = y
  • in your code, call humidityOn() to turn the sensor on
  • in your code, call readHumidity() to get 16-bit raw humidity value


All platform-independent humidity sensor functions are described in mos/hil/humidity.h . Implementation can be found under mos/hal/platforms/...

void humidityInit();      // init humidity sensor, do not turn it on - called by kernel automatically, not needed in application cod
void humidityOn();        // turn on humidity sensor
void humidityOff();       // turn off humidity sensor
uint16_t readHumidity();  // read humidity value

Example application:

//----------------------------------------------------
//      Read humidity sensor, print raw value to UART
//----------------------------------------------------

#include "stdmansos.h"
#include "dprint.h"
#include "humidity.h"


//-------------------------------------------
//      Entry point for the application
//-------------------------------------------
void appMain(void)
{
    PRINT_INIT(129);
    PRINTF("Humidity test app\n");

    humidityOn();

    while (1) {
        sleep(1);
        uint16_t hum_raw = readHumidity();
        uint16_t temp_raw = readHTemperature();
        PRINTF("hum = %i\t temp = %i\n", hum_raw, temp_raw);
    }
}