Skip to main content
Graduate
March 11, 2024
Question

Multiplexing I2C on STM32f4 Board

  • March 11, 2024
  • 4 replies
  • 3375 views

Hi all

I am using 4 sensors on my project. These are comminicated with stm32f4 board via I2C. However there ara 3 I2C channel on stm32f4 board. Is it possible to connect them to same channel via  ı2c multiplexer ? As ı researched, the multiplexer is used with the same sensors. The multiplexer i mentionoed is TCA9548A. 

    This topic has been closed for replies.

    4 replies

    Super User
    March 11, 2024

    @yasinbjk50 wrote:

    stm32f4 board  


    Which STM32F4 board - an ST board, or your own custom board?

    Fundamental to the operation of I2C is the Slave Address - that's what lets you have multiple Slaves on a single I2C bus.

    Do your sensors not allow you to select different addresses?

     


    @yasinbjk50 wrote:

    The multiplexer i mentionoed is TCA9548A. 


    So this:

    https://www.ti.com/product/TCA9548A

    Yes, as its datasheet shows, that is designed to allow a single I2C Master to connect to multiple I2C buses:

    AndrewNeil_0-1710182671908.png

    AndrewNeil_1-1710182785098.png

     

    Graduate
    March 13, 2024

    The board ı am using is 32f407vg. However the sensors are different from each other (rtc module, pulse sensor, lux sensor, lcd module). As ı understand, TCA9548A is used for connecting same sensors. Is it appropriate device for my project?

    Super User
    March 11, 2024
    Graduate II
    March 11, 2024

    What sensor are you interfacing to? Most I2C devices can be hardwired for a different address. Then in FW, you can read/write to each sensor address independently. Knowing what sensor would clarify this.

    Graduate
    March 13, 2024

    DS1307 (RTC module), BH1705(Light Sensor), MAX30100 (Pulse Sensor), LCD Sensor. So these are much more than ı have I2C on STM32f407vg

    Super User
    March 13, 2024

    @yasinbjk50 wrote:

    The board ı am using is 32f407vg. 


    That's not a board - that's just a chip.

    Is that STM32F407VG chip mounted on an ST board, or a 3rd-party board, or your own custom board?

     


    @yasinbjk50 wrote:

    However the sensors are different from each other (rtc module, pulse sensor, lux sensor, lcd module)


    Then they should all have different I2C Slave Addresses - yes?

     


    @yasinbjk50 wrote:

    As ı understand, TCA9548A is used for connecting same sensors


    Generally, yes - or, at least, devices which all have the same I2C Slave Address.

     


    @yasinbjk50 wrote:

     Is it appropriate device for my project?


    Probably not: all your sensors should have different I2C Slave Addresses - so you shouldn't need a multiplexer for that.

    Unless you have some other specific reason for it?

     


    @yasinbjk50 wrote:

    DS1307 (RTC module), BH1705(Light Sensor), MAX30100 (Pulse Sensor), LCD Sensor. So these are much more than ı have I2C on STM32f407vg


    The datasheets for all these devices will tell you what I2C Slave Address(es) each one has.
    (often devices have a choice of 2 or more addresses to minimise the risk of "collisions")

    What is an "LCD Sensor"?
    LCDs are usually output devices - so not "sensors" ...
    :thinking_face:

     


    @yasinbjk50 wrote:

     So these are much more than ı have I2C on STM32f407vg


    Pardon?

    The whole point of a bus is that it can be shared by multiple devices - I2C is a bus.

    You can connect multiple devices to an I2C bus - it is the Slave Address which distinguishes them.

    Example from Wikipedia:

    AndrewNeil_0-1710327488882.png

     

    Perhaps you need to read-up on the I2C bus:

    https://en.wikipedia.org/wiki/I%C2%B2C

    UM10204 2C-bus specification and user manual - this is the definitive specification of the  I2C bus:

    https://www.nxp.com/docs/en/user-guide/UM10204.pdf

    There are many 3rd-party tutorials; eg,

    https://learn.sparkfun.com/tutorials/i2c/all

    https://www.i2c-bus.org/

    Super User
    March 13, 2024