Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs

Not able to find I2C address of sensirion SGP40 sensor with nrfSDK

Hii,

i used nrf5sdk and i am trying to scanning i2c address of Sensirion sgp40 Sensor but unable to sacn i2c address.

I try SGP40 sensor with arduino code its work correctly and give me i2c address and VOC value.

when i use latest nrfSDK its give me i2c address but i can not use latest version of SDK in my project.  

Parents
  • Hi

    Are you using the nRF5 SDK for Mesh or Zigbee/Thread here? Have you done any kind of debugging and get an error code that might explain what is happening/going wrong here? Is there a specific reason you can't use the nRF Connect SDK by the way?

    Based on the info you provide it's really hard to tell what the issue might be, so please share some more information on what your end goal here is, what pins you're using for I2C, and what libraries/drivers you're using in your project.

    Best regards,

    Simon

Reply
  • Hi

    Are you using the nRF5 SDK for Mesh or Zigbee/Thread here? Have you done any kind of debugging and get an error code that might explain what is happening/going wrong here? Is there a specific reason you can't use the nRF Connect SDK by the way?

    Based on the info you provide it's really hard to tell what the issue might be, so please share some more information on what your end goal here is, what pins you're using for I2C, and what libraries/drivers you're using in your project.

    Best regards,

    Simon

Children
  • Yes I am using nRF5 SDK for ZIgbee/Thread with SGP40.

    This is my I2c address scan code.

    void BSP_I2C_Scanner(nrf_drv_twi_t const *handler)
    {
    ret_code_t err_code;
    uint8_t address;
    uint8_t sample_data;
    bool detected_device = false;

    for (address = 1; address <= 127; address++)
    {
    err_code = nrf_drv_twi_rx(handler, address, &sample_data, sizeof(sample_data));
    if (err_code == NRF_SUCCESS)
    {
    detected_device = true;
    NRF_LOG_INFO("I2C device detected at address 0x%x.", address);
    printf("I2C device detected at address 0x%x.", address);
    }
    }

    if (!detected_device)
    {
    NRF_LOG_ERROR("I2C Error: No device was found.");
    }
    }

    This is my I2c init code 

    /* I2C Peripheral */
    #define SNODE_I2C1_SCL_PIN NRF_GPIO_PIN_MAP(0,14)
    #define SNODE_I2C1_SDA_PIN NRF_GPIO_PIN_MAP(0,13)


    /**
    * Initialize all hard- and software components that are needed for the I2C
    * communication.
    */
    void sensirion_i2c_hal_init(void) {

    int8_t err;
    const nrf_drv_twi_config_t i2c_instance_config = {.scl = SNODE_I2C1_SCL_PIN,
    .sda = SNODE_I2C1_SDA_PIN,
    .frequency =NRF_TWI_FREQ_100K,
    .interrupt_priority = 0};
    /* initiate TWI instance */
    err = nrf_drv_twi_init(&i2c_instance, &i2c_instance_config, NULL, NULL);
    if (err) {
    /* Could be omitted if the prototyp is changed to non-void or an error
    * flag is introduced */
    printf("Error %d: Initialization of I2C connection failed!\n", err);
    }
    /* enable TWI instance */
    nrf_drv_twi_enable(&i2c_instance);
    return;
    }

    and this is my configure file 

    /*######################################################################
    Configuration for enabling NRFX TWI/TWIM peripheral
    #######################################################################*/

    #define TWI_ENABLED 1 // enable TWI peripherl driver (legacy layer)
    #define NRFX_TWI_ENABLED 1 // enable NRFX TWI peripherl driver
    #define NRFX_TWIM_ENABLED 1 // enable TWIM peripheral driver
    #define TWI0_ENABLED 1 // Enable TWI0 Instance
    #define TWI1_ENABLED 1 // Enable TWI1 Instance

    /* Use EasyDMA (if present). Determines if you use the
    TWI peripheral (without DMA) or the TWIM peripheral (with DMA).*/
    #define TWI0_USE_EASY_DMA 1
    #define TWI1_USE_EASY_DMA 1

    /* (TWI/NRFX_TWI/NRFX_TWIM)_DEFAULT_CONFIG_FREQUENCY - Frequency
    <26738688=> 100k ,67108864=> 250k, <104857600=> 400k */
    #define TWI_DEFAULT_CONFIG_FREQUENCY 26738688
    #define NRFX_TWI_DEFAULT_CONFIG_FREQUENCY 26738688
    #define NRFX_TWIM_DEFAULT_CONFIG_FREQUENCY 26738688

    /* <o> (TWI/NRFX_TWI/NRFX_TWIM)_DEFAULT_CONFIG_IRQ_PRIORITY - Interrupt priority
    Priorities 0,2 (nRF51) and 0,1,4,5 (nRF52) are reserved for SoftDevice
    <0=> 0 (highest)
    <1=> 1
    <2=> 2
    <3=> 3
    <4=> 4
    <5=> 5
    <6=> 6
    <7=> 7
    */
    #define TWI_DEFAULT_CONFIG_IRQ_PRIORITY 6
    #define NRFX_TWI_DEFAULT_CONFIG_IRQ_PRIORITY 6
    #define NRFX_TWIM_DEFAULT_CONFIG_IRQ_PRIORITY 6

Related