This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

SETTING UP A NEW PROJECT USING SDK 15

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

Parents
  • Hi Arshdeep.

    Looks like you are missing the micro-ecc library. Please see this page for how to install it.

    -----------------------------------------------------------------------------------------------------------------------

    How to add files:

    Right click on either a folder in your project or the project name (in my case "Project 'ble_app_template' ")

    There are two options you can use:

    Add New File... : Creates a blank file in your project

    Add Existing File... : Imports a file in your project

    -----------------------------------------------------------------------------------------------------------------------

    Add New File... option:

    Here you select the file type and give it your desired name.

    -----------------------------------------------------------------------------------------------------------------------

    Add Existing File... option:

    Here you have to navigate to the file you wish to include, in my case for examle ble_cus.c, when I have found it in its location i select it and open it.

    -----------------------------------------------------------------------------------------------------------------------

    Here is my result, I have created a new file called ble_nus.h with the Add New File... option and imported a file called ble_cus.c with the Add Existing File... option.

    -----------------------------------------------------------------------------------------------------------------------

    How to include header files:

    Right click on the project ("Project 'ble_app_template' " in my case), and click on Edit Options...

    In the Project Options window that opens, select the option Common under Private Configurations:

    Click on the Preprocessor option:

    Add the path to the folder that contains the header file you wish to include in the window that opens and click OK:

    Note that  ../../../../../../ is needed because the path is relative to the .emProject file in the ses folder which opened the project.

    -----------------------------------------------------------------------------------------------------------------------

    There exists a tutorial that explores the ble_app_template project by adding advertising, services and characteristics to the project. It is made by an employee at Nordic, you can find it here.

    - Andreas

  • Hi Andreas,

    Thanks for the reply. I am using SES environment , do i still need to install Micro-ecc library ? I believe SES already has the toolchain setup for quick development. Do you think it's some other problem? May be i don't have path for it defined somewhere or something like that? 

    Thanks,

  • Hi Andreas,

    So, i had a copy of template folder in my custom folder. This has been a problem for me before as well. So, i cut everything from that folder and copied into my custom folder. Now that I build my program, I see these following errors: (Attcahed image ).

    Again i am missing few files. How do i solve this?

    Thanks,

  • Hi Arshdeep.

    Your first problem was missing the micro-ecc library. Your latest problem no seems to be that you haven't included some files, as the error code states. Have you included these files to your project? bsp.c, nrf_hw_backend_rng.c, nrf_hw_backend_init.c, and nrf_hw_backend_rng_mbedtis.c? You also need to include any paths to header files these files include in their code.

    - Andreas

Reply
  • Hi Arshdeep.

    Your first problem was missing the micro-ecc library. Your latest problem no seems to be that you haven't included some files, as the error code states. Have you included these files to your project? bsp.c, nrf_hw_backend_rng.c, nrf_hw_backend_init.c, and nrf_hw_backend_rng_mbedtis.c? You also need to include any paths to header files these files include in their code.

    - Andreas

Children
Related