MansOS Humidity

From DiLab
Revision as of 18:47, 14 November 2011 by Girts (talk | contribs) (Usage and configuration)
Jump to: navigation, search
mos/hil/humidity.h

Usage and configuration

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

Dependencies

Function reference

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

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

// Optional - some humidity sensors (SHT11) also provide temperature reading
uint16_t readHTemperature();  // read temperature value from humidity sensor

Example

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);
    }
}