Having to create two identical instances when using I2C hub

The M5Stack Fire uses a ESP32 : https://shop.m5stack.com/products/m5stack-fire-iot-development-kit-psram-v2-6.

ClosedCube TCA9548A I2C multiplexer library is very simple : https://github.com/closedcube/ClosedCube_TCA9548A_Arduino

The RC522 is a 3.3V chip. The module could be this one at Amazon or this one at Reichelt or similar.

The M5Stack library are additions for the device : https://github.com/m5stack/M5Stack

The MFRC522_I2C library could be this one : https://github.com/kkloesener/MFRC522_I2C


The TCA9548 is a I2C multiplexer, not a "hub". Could you do me a favor and call it a "mux" or "multiplexer" or "i2c multiplexer" ?

The constructor of the MFRC522_I2C only initializes the variables, not the hardware. That is how it is supposed to be. In the examples is also a reset pin in the second parameter. You don't need the reset ?

Creating the 'tca9548a' and 'mfrc22' object before setup() is good.

You should do a Wire.begin() in setup() before the I2C bus is used.
The tca9548a.address() (initialize variable) and tca9548a.selectChannel() (set hardware channel) don't do that for you.
The MFRC522 library has a PCD_Init() function to start the hardware. I suggest you do that after the I2C mux is set.

Could you use the Serial Monitor and remove the M5Stack, I don't know if the M5Stack library has influence on the I2C bus. Try to put everything in the right order.

[ADDED] By the way, the Wire.beginTransmission() does not start something on the I2C bus and the Wire.endTransmission() may not be used to stop or end something on the I2C bus.