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

how to handle the I2C clock stretching between nRF52840 and SENSIRION sensor SCD 30

Hi,

In the I2C communication,the nRF52840 SoC is master, the sensor SCD 30 is slave. The sensor SCD 30 needs the clock stretching period, the period time is 12ms or 150ms. 

The first step is to get data ready status, the I2C command is 0x0202. I used the following code to test, however, I didn't get the right response. 

uint8_t cmd_code[] 	= {0x02,0x02};		
uint8_t rx_buffer[] = {0xff,0xff,0xff};

ret_code_t 	err_code;
err_code = nrf_drv_twi_tx(&m_twi_0, 0x61, cmd_code, sizeof(cmd_code) , false);  		
APP_ERROR_CHECK(err_code);	
nrf_delay_ms(1000);

err_code = nrf_drv_twi_rx(&m_twi_0,0x61, rx_buffer,sizeof(rx_buffer)); 
APP_ERROR_CHECK(err_code);	

For the question, please help me to solve it, thanks a lot !

Sensirion_CO2_Sensors_SCD30_Interface_Description.pdfSensirion_CO2_Sensors_SCD30_Datasheet.pdf

  • Hello,

    The first step is to get data ready status, the I2C command is 0x0202. I used the following code to test, however, I didn't get the right response. 

    Could you elaborate on what you mean when you say "didnt get the right response"? - what response are you getting?

    Furthermore, could you use a logical analyzer to scope you pins, and see what is being sent and received?
    Please attach pictures from the logical analyzer here, so I may take a look.

    Best regards,
    Karl

Related