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

Connecting Altimeter to nrf52 dk using i2c.

Hi I trying to connect Altimeter ( mpl 3115a2) to the nrf52 development kit. Can someone guide me how to do it (pin connection). I have followed the example given in the sdk but still I am a little unclear. Thank you.

  • Can you elaborate a bit? What exactly is unclear about connecting the sensor to the DK?

  • Hi

    You can find reference circuitry for your sensor here.

    The main thing to note is the external pull ups on SDA and SCL, otherwise you can connect SDA, SCL, and (optionally) INT1/INT2 directly to the nRF52 DK.

    Technically it is possible to use internal pull ups in the nRF52 to avoid the need for external pull ups, but having them externally gives you more control over the pull up resistance.

    Best regards
    Torbjørn

  • Hi, I am little new to all this, let me go step by step. According to the hardware files P 0.26 and P 0.27 are SDA and SCL respectively. So on the hardware side connection is like SDA -> SDA , SCL-> SCL, Vdd and gnd. This is pretty straight forward. I am confused on the hardware side. The example twi_master_with_twis_slave shows how the master reads the data from the eeprom. I am stuck where all changes I have to make to read the raw data from the sensor. Like where I have to define the pin no. for SDA and SCL and also for the slave address and read address. Can you help me on this issue.

    Thank you.

  • Hi, I am little new to all this, let me go step by step. According to the hardware files P 0.26 and P 0.27 are SDA and SCL respectively. So on the hardware side connection is like SDA -> SDA , SCL-> SCL, Vdd and gnd. This is pretty straight forward. I am confused on the hardware side. The example twi_master_with_twis_slave shows how the master reads the data from the eeprom. I am stuck where all changes I have to make to read the raw data from the sensor. Like where I have to define the pin no. for SDA and SCL and also for the slave address and read address. Can you help me on this issue. Thank you

  • In the twi_master_with_twis_slave example the pins and twi/s instances are defined in the file config.h:

    #define TWI_SCL_M                3   //!< Master SCL pin
    #define TWI_SDA_M                4   //!< Master SDA pin
    
    #define MASTER_TWI_INST          0    //!< TWI interface used as a master accessing EEPROM memory
    

    The macros are used in twi_master_init():

        const nrf_drv_twi_config_t config =
        {
           .scl                = TWI_SCL_M,
           .sda                = TWI_SDA_M,
    ...
    

    So in the example you can change TWI_SCL_M and TWI_SDA_M to be 27 and 26 respectively to match your circuit.

    The simulated EEPROM (slave) address is also defined in config.h:

    #define EEPROM_SIM_ADDR          0x50 //!< Simulated EEPROM TWI address
    

    and the address is used like so:

        static ret_code_t eeprom_read(size_t addr, uint8_t * pdata, size_t size)
        {
    ...
               ret = nrf_drv_twi_tx(&m_twi_master, EEPROM_SIM_ADDR, &addr8, 1, true);
    ...
               ret = nrf_drv_twi_rx(&m_twi_master, EEPROM_SIM_ADDR, pdata, size, false);
    ...
        }
    

    So EEPROM_SIM_ADDR above would in your altimeter's case be changed to 0xC0 (datasheet p.6. ; 7bit address 0x60 << 1). Otherwise the reads and writes are done similarly to how they're done in the example.

    As for the read/write (register) addresses, you need to follow e.g. the sequence in MPL3115A2 datasheet p.10. IIC_RegWrite/Read are analogous to eeprom_write/read in the example (size=1).

    I hope I managed to answer your question and didn't just blabber something... :)

Related