STS30 temperature sensor I2C code

I am trying to read temperature value from STS30 temperature sensor using this simple code snippet: 

During debugging, my debugger stuck at line "if (STS30_read_temp(temperature)==true)". When I step into this line, I can see debugger is stuck at line "return result" of function "nrf_drv_twi_tx" in nrf_drv_twi.h file. 

Can you check the code and advise what am I doing wrong here. 

I have attached the command sequence for reading temperature from STS30 sensor. 

  

Thanks

Parents
  • Hello,

    Please make sure to check the error code returned by nrf_drv_twi_rx - if you do not check the error code you will not have any way of knowing if the function call unexpectedly failed, and so you will be stuck in the while loop forever waiting for the transfer to complete, without the transfer ever having started.

    Please also make sure to have DEBUG defined in your preprocessor defines, like shown in the included image:

    This will make your logger output a detailed error message whenever a non-NRF_SUCCESS error code is passed to an APP_ERROR_CHECK.
    Use this error message to find the function that returned the error code, and look at the function's API reference to see why it returned this particular error code.

    Best regards,
    Karl

Reply
  • Hello,

    Please make sure to check the error code returned by nrf_drv_twi_rx - if you do not check the error code you will not have any way of knowing if the function call unexpectedly failed, and so you will be stuck in the while loop forever waiting for the transfer to complete, without the transfer ever having started.

    Please also make sure to have DEBUG defined in your preprocessor defines, like shown in the included image:

    This will make your logger output a detailed error message whenever a non-NRF_SUCCESS error code is passed to an APP_ERROR_CHECK.
    Use this error message to find the function that returned the error code, and look at the function's API reference to see why it returned this particular error code.

    Best regards,
    Karl

Children
Related