Hi Team Nordic,
I started developing a project using SDK 15 using DK nrf52840 .
I went through several threads and started by creating a test folder inside example directory . Now i copied the template folder in my test folder i.e.. example/ testFolder/ templateProject ..
And i wrote a simple program to read data from DHT11 sensor. But i am having the following error. I think I did not set up my project correctly.
Can you please have a look at error and suggest possible solutions. Also can you please refer me to a relevant tutorial that shows how to set up my project and how to add my different .c and .h files in the project.
#include <stdbool.h>
#include <stdint.h>
#include "nrf.h"
#include "nordic_common.h"
#include "boards.h"
#include "nrf_delay.h"
#include "nrf_gpio.h "
#define MAXTIMINGS 85
#define DHTPIN 9
int dht11_dat[5] = { 0, 0, 0, 0, 0 };
void read_dht11_dat()
{
uint8_t laststate = 1;
uint8_t counter = 0;
uint8_t j = 0, i;
float f; /* fahrenheit */
dht11_dat[0] = dht11_dat[1] = dht11_dat[2] = dht11_dat[3] = dht11_dat[4] = 0;
nrf_gpio_cfg_output(DHTPIN);
nrf_gpio_pin_write(DHTPIN, 0);
nrf_delay_ms(18);
nrf_gpio_pin_write(DHTPIN, 1);
nrf_delay_us(40);
nrf_gpio_cfg_input(DHTPIN, NRF_GPIO_PIN_NOPULL);
for ( i = 0; i < MAXTIMINGS; i++ )
{
counter = 0;
while ( nrf_gpio_pin_read(DHTPIN) == laststate)
{
counter++;
nrf_delay_us(1);
if ( counter == 255 )
{
break;
}
}
laststate = nrf_gpio_pin_read( DHTPIN );
if ( counter == 255 )
break;
/* ignore first 3 transitions */
if ( (i >= 4) && (i % 2 == 0) )
{
/* shove each bit into the storage bytes */
dht11_dat[j / 8] <<= 1;
if ( counter > 16 )
dht11_dat[j / 8] |= 1;
j++;
}
}
}
int main(void)
{
printf( "DHT22 Temperature test program\n" );
while (true)
{
read_dht11_dat();
nrf_delay_ms(1000);
}
}Thanks and Regards,
Arshdeep







