Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 2 of 2

Thread: Multiple i2c devices

  1. #1
    Junior Member
    Join Date
    Aug 2019
    Posts
    6

    Multiple i2c devices

    Hi, can i use more than one i2c device on SDA0 SCL0 pins at the same time? like using oled ssd1306 and the max30100 pulse oximeter? i am using teensy 3.2. i am aware that teensy 3.2 has another i2c port but i cant understand the "i2c_t3.h" lib. so maybe i can still use the "wire.h" .
    Thanks

  2. #2
    Senior Member+ MichaelMeissner's Avatar
    Join Date
    Nov 2012
    Location
    Ayer Massachussetts
    Posts
    3,375
    Quote Originally Posted by Gill View Post
    Hi, can i use more than one i2c device on SDA0 SCL0 pins at the same time? like using oled ssd1306 and the max30100 pulse oximeter? i am using teensy 3.2. i am aware that teensy 3.2 has another i2c port but i cant understand the "i2c_t3.h" lib. so maybe i can still use the "wire.h" .
    Thanks
    You can use Wire.h.

    An i2c bus is a shared bus. Each device has an address, sort of like a phone number. When the i2c master is talking to an i2c slave, it uses the address of the slave to send commands to. All other devices on the bus ignore the commands, since it isn't addressed to them. When a slave responds to the master, it includes its address in the reply and the master can look to see which device responded. Many i2c devices can select different addresses, which is helpful if you have 2 devices of the same type on the i2c bus (such as 2 displays).

    Depending on your setup, you can either wire i2c connections in a star fashion (i.e. using a breadboard/perfboard that has multiple connections per pin, you connect a SDA wire to the display and a second SDA wire to the omimeter. Ditto for SCL, Ground, and 3.3v). Alternatively some i2c devices have more than one connection, and you can wire device serially to the next with a daisy chain.

    In general, you want to keep the wires as short as possible.

    If none of the devices on the i2c bus have pull-up resistors, you need to add 2 pull-up resistors, one between SCL and 3.3v, and the other between SDA and 3.3v in parallel to the other connections. The way to determine if you need pull-up resistors is to run the Wire -> scanner example, and if it hangs or does not identify the i2c devices, you need the pull-up resistors.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •