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

I am begineer coder. I am working on nRF52832 board. Want to develope firmware for Temperature and Humidity using HTU21D sensor. Could anyone provide me complete code with supporting files to refer. thanks.

I am working on nRF52832 controller for a small project . I am completely new to this series of controller.

I want to develope a firmware to measure Humidity and Temperature using HTU21D sensor. I am using Eclipse neon IDE. I am completely unaware of procedure to develope a code using Eclipse IDE. 

Could anyone please send me a complete code to measure Humidity and Temperature using HTU21D. Please I want code and supporting files for the same. e.g. linker file, makefile, configuration file etc.

Thanks in advance! 

Parents
  • hi,

      here i attach the code for htu21d but it works in pca10028. you want to make necessary changes to work on nrf52832 pca 10040. 2526.HTU21D.rar

    cheers,

    karthikeyan

  • Hi Karthikeyan, 

    I do have another query. I have done my coding for another project. Please help me to rectify the code. 

    I am sumitting the code here. 

    #include <stdbool.h>
    #include <stdint.h>
    #include <stdio.h>
    #include "app_uart.h"
    #include "app_error.h"
    #include "nrf_delay.h"
    #include "nrf.h"
    #include "bsp.h"
    
    
    
    #define MAX_TEST_DATA_BYTES     (15U)
    #define UART_TX_BUF_SIZE 256
    #define UART_RX_BUF_SIZE 256
    
    
    
    //  UART error handler function.
    
    
    void uart_error_handle(app_uart_evt_t * p_event)
    {
        if (p_event->evt_type == APP_UART_COMMUNICATION_ERROR)
        {
            APP_ERROR_HANDLER(p_event->data.error_communication);
        }
        else if (p_event->evt_type == APP_UART_FIFO_ERROR)
        {
            APP_ERROR_HANDLER(p_event->data.error_code);
        }
    }
    
    
    
    
    // LED glow function: When data Transmitted is equal to data Received then LED glow up else stays off.
    
    
    void led_blink()
    {
    
        bsp_board_leds_init();
    
    
        while (true)
        {
            for (int i = 0; i < 1; i++)
            {
                bsp_board_led_invert(i);
                nrf_delay_ms(500);
            }
        }
    }
    
    //   UART transmit function.
    
    
     #if ((Enable_UART_TxDecimalNumber==1) || (Enable_UART_TxFloatNumber==1))
    
    
    void UART_Tx(uint32_t dec_no, uint8_t nod)
    {
    		uint8_t i=0;
    
    		printf("\nEnter decimal no to transmit:");
    		scanf("\n%d", &dec_no);
    
    		if(dec_no==0)																			//decimal number to transmit
    		{
    			for(i=0; ((i<nod) && (i<max_dttx)); i++)											//number of digits to transmit
    			a[i] = 0x00;																		//maximum number of digits to transmit
    		}
    		else if
    		{
    			for(i=0; i<nod; i++)
    			{
    				if(dec_no!=0)
    				{
    					a[i] = util_GetMod32(dec_no,10);
    					dec_no = dec_no/10;
    				}
    
    
    		else if( (nod == dttx) || (nod > max_dttx))												//total numbers to transmit
    			{
    				break;
    			}
    		else
    			{
    				a[i]=0;
    			}
    		}
    	}
    
    	while(i)
    	{
    		UART_TxChar(util_Dec2Ascii(a[i-1]));													//Convert decimal to ASCII
    		i--;
    	}
    
    	void led_blink();
    }
    
    #endif
    
    
    
    //  main Function.
    
    
    int main(void)
    {
        uint32_t err_code;
    
        bsp_board_leds_init();
    
        const app_uart_comm_params_t comm_params =
          {
              RX_PIN_NUMBER,
              TX_PIN_NUMBER,
              RTS_PIN_NUMBER,
              CTS_PIN_NUMBER,
              APP_UART_FLOW_CONTROL_ENABLED,
              false,
              UART_BAUDRATE_BAUDRATE_Baud19200
          };
    
        APP_UART_FIFO_INIT(&comm_params,
                             UART_RX_BUF_SIZE,
                             UART_TX_BUF_SIZE,
                             uart_error_handle,
                             APP_IRQ_PRIORITY_LOWEST,
                             err_code);
    
        APP_ERROR_CHECK(err_code);
    
    
        UART_Tx();
    
    
    
    	return 0;
    }
    
    
    
    
    
    
    

    I want to transmit 0-9 numbers using UART. Above the code for same. I dont know where I am going wrong. Please help me with code.

  • hi,

      can you post the new question. because anybody can answer that. and also please describe the exact problem

  • Yes Karthikeyan, I will do the same.

    Thank you for suggestion. Appericiate!

Reply Children
No Data
Related