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

Hello all i want to interface temperature sensor with nRF52 DK. And send the temperature values to the users smart phone. I have checked with the tutorial and have used the sd_temp_get() function to get the temperature using the on board sensor.

 nd Since i am still a newbie to nordic i wanted to know how can i break the task in smaller steps. 

1)As a first step i get the values in temperature form using saadc. 

2)How can i notify the value just as it does after calling for sd_temp_get().

3)As a 3rd question I have already interfaced the battery management IC with nrF52 and extracted the required bit. I wish to send that bit and read/notify it on one of the characteristics. But the value doesnt get updated.

Any inputs would be helpful 

  • Hi Karl,

    Once again thanks for reply

    get_char_bit1() while debugging is taking me to NRF_BREAKPOINT_CMD.

    I have interfaced my sensor using TWI.

    I read from one of the registers of sensor  and get a value(that i wish to see on smart phone) which is returned by  function charging_check. 

    I have called twi_init function before calling the bluetooth required functions. I will add that codesnippet below for you to know the order in which the functions are called.

    ORDER OF SENSOR function AND BLE function 
    int main(void)
    {
       
       twi_sens(); all sensor related stuff reading from and writing to registers
       modules_init(); all BLE related functions
        for (;;)
        {   
            
            idle_state_handle();
            //nrf_pwr_mgmt_run();
            //NRF_LOG_FLUSH();  
            
        }
    }
     
     
      void modules_init(void)
    {
        log_init();
        leds_init();
        timers_init();
    
        //   buttons_init();
        power_management_init();
        ble_stack_init();
        pwm_init();
        gap_params_init();
        gatt_init();
        services_init();
        advertising_init();
        conn_params_init();
        //    Start execution
        application_timers_start();
        advertising_start();
       //  OneWireSlave_init(); 
    
    
    
    
        
        // Enter main loop.
    }

    Kind Regards,

    PaSi

  • Hello,

    PaSi said:
    get_char_bit1() while debugging is taking me to NRF_BREAKPOINT_CMD.

    This usually happens when a non-NRF_SUCCESS error code is passed to an APP_ERROR_CHECK. Please make sure that you have DEBUG defined in your preprocessor defines like previously explained. Do you see an error message in your log when this happens?
    If you do, what does this error message say?

    Best regards,
    Karl

  • Hi Karl

    I get error NRF_ERROR_SOFTDEVICE_NOT_ENABLED 

    at application_timers_start() function when called in main as per the characteristic tutorial .

      

    Best Regards,

    PaSi

  • Hello again PaSi,

    This means that you try to call a SoftDevice function before the SoftDevice is enabled.
    Please go back and answer my question in regards to the 50 µs you mentioned earlier.
    I think this might be the issue is - if this function is called every 50 µs, and called before the SoftDevice is enabled, you will get this error.

    Your timers_init comes before the ble_stack_init, so if it triggers immediately it will try to do a sd_temp_get, but fail since the SoftDevice is not yet enabled.

    Please read through my previous comments, and answer the missed questions.

    In general, when a non-NRF_SUCCESS error code is returned by a function, you should look into that functions API reference to see why it returned this particular error code.

    Best regards,
    Karl

  • Hi Karl,

    I am not calling the function get_char_bit1()  every 50 micro seconds. 

    As i said the program is working perfectly fine with sd_temp_get() i can see values changing but as soon as i call get_char_bit function in timer timeout handler nRF connect App doesnt show nordic blinky. I had a question here do we need a differen timer timeout for sd_temp_get() and get_char_bit() or it can be implemented in same timer timeout handler.

    Yes the timer_init()  is called before ble_stack_init

    https://devzone.nordicsemi.com/nordic/short-range-guides/b/bluetooth-low-energy/posts/ble-characteristics-a-beginners-tutorial here the app_tmers_start() is called after advertising_start in solution folder .

    int main()
    
    { log_init();
    
    leds_init();
    timers_init();
    
    // buttons_init();
    power_management_init();
    ble_stack_init();
    pwm_init();
    gap_params_init();
    gatt_init();
    services_init();
    advertising_init();
    conn_params_init();
    
    // Start execution.
    NRF_LOG_INFO("Blinky example started.");
    application_timers_start(); // This one i am talking about 
    advertising_start();
    
    }
    Thanks a lot!

    Best Regards,

    PaSi

Related