2014-01-10 6 views
2

콘티 키 프로그램으로 온도, 빛 및 습도를 측정하는 방법을 알고 싶습니다.contiki-OS로 온도, 습도 및 광도를 읽는 방법은 무엇입니까?

저는 TelosB mote (sky mote)를 사용하고 있으므로이 세 센서는 mote 자체에 통합되어 있습니다.

PS :

#include "dev/sht11-sensor.h" 
#include "dev/light-sensor.h" 

그런 다음 당신이 다음 기능을 사용할 수 있습니다 : 당신이 다음에 추가해야합니다 빛과 온도 센서를 사용하기 위해서는 컨티키-OS 2.7

답변

3

에서 일하고 있어요 :

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(); 
} 
+0

'10 * light_sensor.value (LIGHT_SENSOR_PHOTOSYNTHETIC)/7'과'((sht11_sensor.value (SHT11_SENSOR_TEMP)/10) - 396)/10'을 설명 할 수 있습니까? – watou

+0

TelosB mote에서 사용할 수있는 센서의 데이터 시트에서이 수식을 얻을 수 있습니다. 온도 센서는 [SHT11 센서] (http://www.sensirion.com/fileadmin/user_upload/customers/sensirion/Dokumente/Humidity/Sensirion_Humidity_SHT1x_Datasheet_V5.pdf)입니다. 체크 아웃하면 온도 센서가 센서로 온도를 계산하는 방법을 설명하는 수식 : 'T = d1 + d2 * sensorReading' 데이터 시트에있는 표에서 d1 및 d2의 값을 얻을 수 있습니다. 광 센서의 공식은 해당 센서 사양에서 얻을 수 있습니다. – PabloCorbalan