Multiplexer not finding I2C to UART module address

Hi guys! I'm a mechanical engineering student so I'm not very familiar with this stuff, so sorry if I'm using the wrong terminology.

I’m trying to read data from multiple sensors using an ATMEGA328P. To manage multiple I2C devices, I’m using a Gravity: Digital 1-to-8 I2C Multiplexer (DFROBOT).

Port 3: Connected to a pressure sensor that communicates via I2C.

Port 1: Connected to a secondary sensor that supports UART. Since the sensor does not natively support I2C, it is connected through a Gravity: I2C to Dual UART Module (DFROBOT) before interfacing with the I2C multiplexer.

When I scan the I2C addresses using the following code, I find seven addresses listed under Port 1 (113 to 119). However, I am unable to read data from the UART sensor connected through the I2C-to-UART module.

#include <DFRobot_I2C_Multiplexer.h>

/*Create an I2C Multiplexer object, the address of I2C Multiplexer is 0x70*/
DFRobot_I2C_Multiplexer I2CMultiplexer(&Wire, 0x70);

void setup(){
  Serial.begin(9600);
  I2CMultiplexer.begin();
  delay(1000);
  Serial.println("Scan ready!");

  /*Print I2C device of each port*/
  for(uint8_t port = 0; port < 8; port++)
  {
    Serial.print("Port:");
    Serial.print(port);
    uint8_t *dev = I2CMultiplexer.scan(port);
    while (*dev)
    {
      Serial.print("  i2c addr ");
      Serial.print(*dev);
      dev++;
    }
    Serial.println();
  }
}

void loop(){
  
}

And I get the following output

Scan ready!
Port:0
Port:1 i2c addr 113 i2c addr 114 i2c addr 115 i2c addr 116 i2c addr 117 i2c addr 118 i2c addr 119
Port:2
Port:3 i2c addr 118
Port:4
Port:5
Port:6
Port:7

1.Why am I seeing seven I2C addresses (113–119) on Port 1?
Is this expected behavior for the Gravity I2C to Dual UART Module?

  1. Why can’t I read data from the UART sensor?
    Do I need additional steps to initialize or communicate with the I2C-to-UART module?
    Is there a specific register or command sequence required to access the connected UART device?

The pressure sensor on Port 3 appears to be correctly detected at address 118.
I suspect the I2C-to-UART module is exposing multiple registers (113-119), but I am unsure how to properly communicate with it.
If additional information is needed, please let me know.

There are many possibilities but sorry I cannot help as I cannot see what you have. Post an annotated schematic showing exactly how you have wired it. Show all components, power, ground, power sources, etc.

Here are the schematics of the relevant components (not done by me, I only have access to them). The PCB was manufactured by PCBWay, so the issue is either due to the schematics used or because I don’t fully understand how the system works. As stated before the pressure sensor connected to port 3 works, as I can read data from it. The sensor I'm having trouble detecting thorugh port one is OBD_S1.

(There is an error on port 2, the SDA and SCL are inverted, but that is not relevant right now)

Have you tried the DFrobot example code?

For the multiplexer yes and it works, but for the I2C to Uart module no, as I can't access the module istelf, since it is "hidden" behind the multiplexer.

First you need to select the multiplexer port it is on, then you will be able to communicate with it.

This is the code I'm trying to use. As you can see I select the multiplexer port 1, but the initialization of the module fails, as iicSerial1.begin(115200) != 0 never returns 0

#include <Wire.h>
#include <DFRobot_I2C_Multiplexer.h>
#include <DFRobot_IICSerial.h>

// Create an I2C Multiplexer object at address 0x70
DFRobot_I2C_Multiplexer I2CMultiplexer(&Wire, 0x70);

// Create an IICSerial object for UART1
DFRobot_IICSerial iicSerial1(Wire, SUBUART_CHANNEL_1, 1, 1);

void setup() {
  Serial.begin(9600);
  Wire.begin();
  I2CMultiplexer.begin();
  delay(1000);

  // Select port 1 on the I2C multiplexer
  I2CMultiplexer.selectPort(1);

  // Initialize UART1 at 115200 baud rate
  while (iicSerial1.begin(115200) != 0) {
    Serial.println("UART init failed");
    delay(100);
  }
  Serial.println("UART initialized successfully.");
}

void loop() {

  }
  delay(1000);
}

I assume you have the two DIP switches for the UART set to 1. Try setting them both to 0 and change them in the code

DFRobot_IICSerial iicSerial1(Wire, SUBUART_CHANNEL_1, 0, 0);

If it still does not work it is probably because the pull-up resistors on the I2C lines are too low.
You are also missing pull-up on the SDA_MCU, SCL_MCU lines.

Have you read the documents for the module?

In case you can't find them...

DIP vs IIC Address
The IIC to dual UART module is a non-standard IIC device with various addresses. IIC address has 7 bits. When running the IIC scanning program, as long as the upper 4 bits are the same as that of the module, and there will be reponse. So you can scan multiple IIC addresses with same upper 4 bits on one module.

Gravity: IIC to dual UART module Wiki - DFRobot

Yes but I don't understand them. Does this mean that reading 7 addresses on port 1 is correct? Then once port 1 is selected, which address do I choose and how do I initialize the UART module? Sorry but all of this is very new to me

See post #8
DIP switches select addr.

Thank you! I put the DIP switches to 0 and now iicSerial1.begin(115200) returns 0, meaning it was succesfully initialzed. The remaining problem is that I can't read any data, and iicSerial1.available() returns 0, meaning that 0 bytes ar available to be read. Could this be due to the missing pullup resistor on the SDA_MCU, SCL_MCU lines you mentioned before?

Maybe there aren't any bytes to read.
What is connected to iicSerial1?

Am ultrasonic sensor, which I managed to read data from when it's directly connected to my arduino 1

I know nothing about your ultrasonic sensor.
Does the DFrobot loopback test work?

Yes! But I managed to find the error, I inverted the TX and RX cables of the sonar... Thanks for your help, I learned a lot!

A very common mistake
Now back to work!