Thread 中讨论的其他器件:CC2650
我正在尝试使用此 contiki 代码通过 cc2650 launchxl 从 dht11传感器读取温度和湿度值
Contiki-ng/examples/dev/dht11/dht11.c
Contiki-ng/dht11.c,在开发·contiki-ng/contiki-ng (github.com)
我觉得我必须更改引脚以适应我的 cc2650 IOID、但我的电路板仍然无法读取传感器(输出超时)。 我想知道我使用的是错误的 IOID 引脚、还是我的代码格式有问题、请仔细查看我在下面更改的代码、如果您能帮助我解决这个问题、这对我来说意味着世界
#include "contiki.h"
#include
#include "dht11-sensor.h"
/*-------- 我添加这一行--- *
#include "board.h"
/*------------------ *
进程(dht11_process、"DHT 11 process");
autostart_processes (&dht11_process);
/*------------------ *
#define DHT11_GPIO_PORT (1)
#define DHT11_GPIO_PIN (12)
/*-------- 我添加这一行--- *
#define Board_IOID_DIO23 IOID_23
process_thread (dht11_process、EV、data)
{
静态结构 etimer 计时器;
process_bege();
dht11_sensor.configure (DHT11_configure_GPIO_port、DHT11_GPIO_port);
/*dht11_sensor.configure (DHT11_configure_GPIO_PIN、DHT11_GPIO_PIN);*/
/*我更改的代码*/
dht11_sensor.configure (DHT11_configure_GPIO_PIN、IOID_23);
dht11_sensor.configure (sensor_hw_init、0);
/*等待一秒钟,使 DHT11传感器准备就绪*/
etimer_set (&timer、clock_second * 1);
/*等待周期性计时器过期*/
Process_Wait_event_until (etimer_expired (&timer)));
/*设置一个在5秒后过期的周期性计时器。 *
etimer_set (&timer、clock_second * 5);
while (1){
/*
*请求重新读取
*
sensors_activate (dht11_sensor);
printf ("%ld "、clock_time());
switch (dht11_sensor.status (0)){
案例 DHT11_STATUS_OK:
printf ("湿度%d.%d %%"、
dht11_sensor.value (DHT11_value_humidation_integer)、
dht11_sensor.value (DHT11_value_humidation_decimal);
printf ("温度=%d.%d * C\n"、
dht11_sensor.value (DHT11_value_temperature 整数)、
dht11_sensor.value (DHT11_value_temperature 十进制);
中断;
案例 DHT11_STATUS_CHECKSUM_FAILED:
printf ("校验和失败\n"\n);
中断;
案例 DHT11_STATUS_TIMEOUT:
printf ("读取超时\n");
中断;
默认值:
中断;
}
/*等待周期性计时器过期,然后重新启动计时器。 *
Process_Wait_event_until (etimer_expired (&timer)));
etimer_reset (&timer);
}
process_end();
}