Компьютер ланд баруун хойно 26 р байр Electronic Parts
Хүргэлтийн үйлчилгээ таны цагийг хэмнэнэ
×
Cityepress Cargo
Таны хайж буй бүтээгдэхүүнүүд манай сайтад байхгүй бол доорх хайлтыг ашиглан taobao-с шууд хайлт хийнэ үү.

TCA9548A Low-Voltage 8-Channel I 2C Switch with Reset

8000₮
Барааны код: 206
Агуулахад:
Сагсанд хийх
Тайлбар

Overview

Have you ever wanted to use 2 sensors with the same I2C address at the same time, not knowing what to do? Faced some serious challenges in doing that?

In a lot of projects, we have used different modules and sensors that support I2C communication protocol. Sometimes, we have interfaced some I2C modules with a microcontroller in our projects. If they all have different I2C addresses, we could easily interface them, facing no serious trouble. But, if 2 or more of the modules had the same I2C address, we would face some apparently unsolvable problems in using them all. This problem is a serious one which we all have definitely come across with at least once. If you’re having the same problem, this tutorial can be helpful for you.

Generally speaking, this problem can be solved in both software and hardware. In this tutorial, we are going to present a hardware solution for this problem. In a nutshell, we are going to add the TCA9548A I2C Multiplexer to the project and expand the I2C addresses of the modules with the same I2C address.

Multiple I2C Modules

What You Will Learn

As mentioned above, a real challenge while working with I2C communication protocol is interfacing different I2C devices with the same address to Arduino or any other microcontroller.

In this article, we first interface the two temperature & humidity sensors GY-21 and LM75 which have different I2C addresses with Arduino and use an OLED to display the temperature each of them measures. We do that by combining their libraries and then display the temperature on the OLED.

Then we will add the I2C expansion module TCA9548A to the circuit. But in this stage, we use the sensors GY-21, SHT20 and HTU21D, which all have the same I2C address. We will make some changes in the code and display the temperature measured by each sensor on the OLED.

The image below is a preview of the final circuit. At the end of this tutorial, you will be able to display the temperature measured by these 3 sensors having the same I2C address on an OLED.

What Is I2C Communication Protocol, and How Does It Work?

I2C, short for Inter-Integrated Circuit, is a communication protocol which can also be referred to with the short term IIC. This communication protocol is widely used in microcontrollers. In this communication, masters and slaves (Masters are usually the main components like microcontrollers and Slaves are sensors, modules and other components used in the circuit.) communicate through 2 lines:

  • SDA (Serial Data): The line to transmit and receive data between the Master and Slave
  • SCL (Serial Clock): The line to send the clock
Note

In the Arduino Uno, the pins A4 and A5 are the SDA and SCL, respectively.

In other boards and microcontrollers, these pins might differ. In that case, you can easily figure out the I2C pins by checking the datasheet of that specific microcontroller.

The most important features of the I2C communication protocol are the following:

  • It’s not so fast (But fast enough for most applications)
  • Suitable for short distances (e.g. maximum distance in 100KHz is 1 meter)
  • Synchronous communication
  • Data is transmitted serially
  • Logic level can be both 3.3V and 5V

In the I2C communication protocol, there are two types of devices that connect to the I2C bus: The master and the slave. In this protocol, multiple slaves can be connected to a single master, like a microcontroller. And also, a single slave can be controlled and monitored by multiple masters, but only one of the masters can be active at a time. Each master can select which slave to communicate with. This selection is done through the slave’s 7-bit addresses (10-bit in some cases). So, there can be approximately 128 slave devices connected to the I2C bus. So, in other words, each slave has its own specific I2C address and there is no address for the masters.

The data transmitted on the I2C bus, synchronized by clock line, SCL. The master is responsible for the synchronization.

Cart

Сагсанд амжилттай орлоо