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

Error in establishing communication between ADT7410 and nRF52840.

Hey hi,

I am trying to establish communication between ADT7410 and nRF52840 using I2C that is the TWI module.

I have successfully checked the address of the ADT7410 with nRF52840.

The output of so is as follow:

00> <info> app: Application Started
00>
00> <info> app: Entered the twi_init loop
00>
00> <info> app: twi is been initalized
00>
00> <info> app: error_code is : 0x0
00>
00> <info> app: Successfully detected a device at address : 0x48
00>

But unable to get the temperature value from the sensor.

Tried debugging through NRF_LOG_INFO

the program doesn't print "The Error code 2 is %x" from the ADT7410_set_mode.

ADT7410_set_mode function is as follow:

void ADT7410_set_mode(void)
{
NRF_LOG_INFO("We have entered ADT7410 set mode");
NRF_LOG_FLUSH();
ret_code_t err_code;

/* Writing to LM75B_REG_CONF "0" set temperature sensor in NORMAL mode. */
uint8_t reg[2] = {ADT7410_REG_CONF, NORMAL_MODE};
err_code = nrf_drv_twi_tx(&m_twi, ADT7410_ADDR, reg, sizeof(reg), false);
APP_ERROR_CHECK(err_code);
NRF_LOG_INFO("The Error code 1 is %x",err_code);
NRF_LOG_FLUSH();
while (m_xfer_done == false);

/* Writing to pointer byte. */
reg[0] = ADT7410_REG_TEMP;
m_xfer_done = false;
err_code = nrf_drv_twi_tx(&m_twi, ADT7410_ADDR, reg,1, false);
APP_ERROR_CHECK(err_code);
NRF_LOG_INFO("The Error code 2 is %x",err_code);
NRF_LOG_FLUSH();
while (m_xfer_done == false);
}

Please do guide me to solve this issue.

  • Hi awneil, I don't have any such facility for the logic analyser.

    I am a student working at my home with some basic facilities.

    I have worked on other controllers also and established SPI and I2C without using any such thing.

    New to the Nordic environment and that why need help.

  • But these really are basic facilities - you can get a logic analyser from ebay for ~ $10

    This is not purely a software exercise; it also depends on the hardware - so there's no point just looking at the software without checking that the hardware is actually behaving correctly.

  • Maybe the temperature data you are reading is correct, assuming it is cool in your location, but there is a problem in that you are reading 2 bytes of temperature into a single byte location:

        /* Read 1 byte from the specified address - skip 3 bits dedicated for fractional part of temperature. */
        ret_code_t err_code = nrf_drv_twi_rx(&m_twi, ADT7410_ADDR, &m_sample, 2);

    m_sample is only 1 byte; perhaps change to 2 bytes (m_sample[2]) and then the 16-bit temperature is in big-endian format, m_temp[0] is high byte, m_temp[1] is low byte. m_temp[0] will be 0x00 until it gets warmer :-)

  • It is entering ADT7410_set_mode but unable to do anything in it.

    void ADT7410_set_mode(void)
    {
    NRF_LOG_INFO("We have entered ADT7410 set mode");
    NRF_LOG_FLUSH();
    ret_code_t err_code;

    /* Writing to ADT7410_REG_CONF "0" set temperature sensor in NORMAL mode. */
    uint8_t reg1[2] = {ADT7410_REG_CONF, NORMAL_MODE};
    err_code = nrf_drv_twi_tx(&m_twi, ADT7410_ADDR, reg1, sizeof(reg1), false);
    APP_ERROR_CHECK(err_code);
    NRF_LOG_INFO("The Error code 1 is %x",err_code);
    NRF_LOG_FLUSH();
    while (m_xfer_done == false);

    /* Writing to pointer byte. */
    uint8_t reg2[2] = {ADT7410_REG_TEMP,0x00};
    m_xfer_done = false;
    err_code = nrf_drv_twi_tx(&m_twi, ADT7410_ADDR, reg2,1, false);
    APP_ERROR_CHECK(err_code);
    NRF_LOG_INFO("The Error code 2 is %x",err_code);
    NRF_LOG_FLUSH();
    while (m_xfer_done == false);
    }

  • It is entering ADT7410_set_mode but unable to do anything in it

    What, exactly, do you mean by that?

Related