Contiki-OS로 온도, 습도 및 가벼운 조치를 읽는 방법은 무엇입니까?
문제
Contiki 프로그램으로 온도, 빛 및 습도를 측정하는 방법을 알고 싶습니다.
TheLOSB Mote (Sky Mote)를 사용하고 있으므로이 세 센서는 Mote 자체에 통합됩니다.
추신 : Contiki-OS 2.7 / P>에서 일하고 있습니다.
해결책
빛과 온도 센서를 사용하려면 다음을 추가해야합니다 :
#include "dev/sht11-sensor.h"
#include "dev/light-sensor.h"
.
다음 다음 함수를 사용할 수 있습니다.
static int
get_light(void)
{
return 10 * light_sensor.value(LIGHT_SENSOR_PHOTOSYNTHETIC) / 7;
}
static int
get_temp(void)
{
return ((sht11_sensor.value(SHT11_SENSOR_TEMP) / 10) - 396) / 10;
}
.
예를 들어, 이러한 센서의 값을 표시하는 최소 응용 프로그램은 다음과 같습니다.
#include "contiki.h"
#include "dev/sht11-sensor.h"
#include "dev/light-sensor.h"
#include "dev/leds.h"
#include <stdio.h>
//Declare the process
PROCESS(send_sensor_info_process, "Print the Sensors Information");
//Make the process start when the module is loaded
AUTOSTART_PROCESSES(&send_sensor_info_process);
/*---------------------------------------------------------------------------*/
static int
get_light(void)
{
return 10 * light_sensor.value(LIGHT_SENSOR_PHOTOSYNTHETIC) / 7;
}
/*---------------------------------------------------------------------------*/
static int
get_temp(void)
{
return ((sht11_sensor.value(SHT11_SENSOR_TEMP) / 10) - 396) / 10;
}
/*---------------------------------------------------------------------------*/
//Define the process code
PROCESS_THREAD(send_sensor_info_process, ev, data)
{
PROCESS_BEGIN();
SENSORS_ACTIVATE(light_sensor);
SENSORS_ACTIVATE(sht11_sensor);
printf("Light: %d \n", get_light());
printf("Temperature: %d \n", get_temp());
PROCESS_END();
}
. 제휴하지 않습니다 StackOverflow