Difference between revisions of "MansOS Humidity"
(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...) |
(→Function reference) |
||
(8 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
__TOC__ |
|||
mos/hil/humidity.h |
|||
== Usage and configuration == |
|||
To use humidity sensor, make the following changes to you application: |
To use humidity sensor, make the following changes to you application: |
||
* enable humidity sensor by adding the following line to config file: |
* enable humidity sensor by adding the following line to config file: |
||
Line 7: | Line 13: | ||
* in your code, call readHumidity() to get 16-bit raw humidity value |
* in your code, call readHumidity() to get 16-bit raw humidity value |
||
== Dependencies == |
|||
There are no dependencies for humidity sensor usage imposed by the MansOS operating system. However, some platforms may have specific requirements, for example, I2C or SPI usage. Such cases should be handled automatically by the platforms and error or warning should be issued if some platform-specific humidity sensor requirements are not met. |
|||
== Function reference == |
|||
All platform-independent humidity sensor functions are described in mos/hil/humidity.h . Implementation can be found under mos/hal/platforms/ |
All platform-independent humidity sensor functions are described in mos/hil/humidity.h . Implementation can be found under mos/hal/platforms/<platform-name>/ |
||
<pre> |
<pre> |
||
void humidityInit(); // init humidity sensor, do not turn it on - called by kernel automatically, not needed in |
void humidityInit(); // init humidity sensor, do not turn it on - called by kernel automatically, not needed in user level |
||
void humidityOn(); // turn on humidity sensor |
void humidityOn(); // turn on humidity sensor |
||
void humidityOff(); // turn off humidity sensor |
void humidityOff(); // turn off humidity sensor |
||
uint16_t readHumidity(); // read humidity value |
uint16_t readHumidity(); // read humidity value |
||
// Optional - some humidity sensors (SHT11) also provide temperature reading |
|||
uint16_t readHTemperature(); // read temperature value from humidity sensor |
|||
</pre> |
</pre> |
||
Example |
== Example == |
||
⚫ | |||
⚫ | |||
//---------------------------------------------------- |
|||
⚫ | |||
//---------------------------------------------------- |
|||
⚫ | |||
#include "stdmansos.h" |
#include "stdmansos.h" |
||
#include "dprint.h" |
#include "dprint.h" |
||
Line 46: | Line 57: | ||
} |
} |
||
} |
} |
||
</pre> |
</pre> |
Latest revision as of 18:50, 14 November 2011
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
There are no dependencies for humidity sensor usage imposed by the MansOS operating system. However, some platforms may have specific requirements, for example, I2C or SPI usage. Such cases should be handled automatically by the platforms and error or warning should be issued if some platform-specific humidity sensor requirements are not met.
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 user level 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); } }