Other Parts Discussed in Thread: CC2650
I'm trying to read the temperature and humidity value from dht11 sensor with cc2650 launchxl using this contiki code
contiki-ng/examples/dev/dht11/dht11.c
contiki-ng/dht11.c at develop · contiki-ng/contiki-ng (github.com)
I figure i have to change the pin to fit my cc2650 IOID, but still my board can't read the sensor (output timed out). I'm wondering if i'm using the wrong IOID pin, or i'm doing something wrong with my code format, please, be kindly take a look of the code i have change below, it'd mean the world to me if you can help me solve this problem
#include "contiki.h"
#include <stdio.h>
#include "dht11-sensor.h"
/*------------I add this line----------*/
#include "board.h"
/*---------------------------------------------------------------------------*/
PROCESS(dht11_process, "DHT 11 process");
AUTOSTART_PROCESSES(&dht11_process);
/*---------------------------------------------------------------------------*/
#define DHT11_GPIO_PORT (1)
#define DHT11_GPIO_PIN (12)
/*------------I add this line----------*/
#define BOARD_IOID_DIO23 IOID_23
PROCESS_THREAD(dht11_process, ev, data)
{
static struct etimer timer;
PROCESS_BEGIN();
dht11_sensor.configure(DHT11_CONFIGURE_GPIO_PORT, DHT11_GPIO_PORT);
/*dht11_sensor.configure(DHT11_CONFIGURE_GPIO_PIN, DHT11_GPIO_PIN);*/
/*code i change*/
dht11_sensor.configure(DHT11_CONFIGURE_GPIO_PIN, IOID_23);
dht11_sensor.configure(SENSORS_HW_INIT, 0);
/* Wait one second for the DHT11 sensor to be ready */
etimer_set(&timer, CLOCK_SECOND * 1);
/* Wait for the periodic timer to expire */
PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&timer));
/* Setup a periodic timer that expires after 5 seconds. */
etimer_set(&timer, CLOCK_SECOND * 5);
while(1) {
/*
* Request a fresh read
*/
SENSORS_ACTIVATE(dht11_sensor);
printf("%ld ", clock_time());
switch(dht11_sensor.status(0)) {
case DHT11_STATUS_OKAY:
printf("Humidity %d.%d %% ",
dht11_sensor.value(DHT11_VALUE_HUMIDITY_INTEGER),
dht11_sensor.value(DHT11_VALUE_HUMIDITY_DECIMAL));
printf("Temperature = %d.%d *C\n",
dht11_sensor.value(DHT11_VALUE_TEMPERATURE_INTEGER),
dht11_sensor.value(DHT11_VALUE_TEMPERATURE_DECIMAL));
break;
case DHT11_STATUS_CHECKSUM_FAILED:
printf("Check sum failed\n");
break;
case DHT11_STATUS_TIMEOUT:
printf("Reading timed out\n");
break;
default:
break;
}
/* Wait for the periodic timer to expire and then restart the timer. */
PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&timer));
etimer_reset(&timer);
}
PROCESS_END();
}