Difference between revisions of "I2C Address Converter Module SKU: CQRADDR001"

From CQRobot-Wiki
Jump to: navigation, search
(Specification)
(Raspberry Pi Example and Test Code)
 
(33 intermediate revisions by the same user not shown)
Line 12: Line 12:
 
*'''Standard Interface Compatibility:''' Equipped with dual interfaces—HY2.0mm 4P connectors and 2.54mm pin headers—for easy connection to various development boards and sensor modules.
 
*'''Standard Interface Compatibility:''' Equipped with dual interfaces—HY2.0mm 4P connectors and 2.54mm pin headers—for easy connection to various development boards and sensor modules.
 
----
 
----
 +
 +
=='''Certification Documents'''==
 +
 +
[[Media:CQRADDR001-CE-Certification.rar]]
 +
 +
[[Media:CQRADDR001-FCC-SDOC-Certification.rar]]
  
 
=='''Pin Description and Size'''==
 
=='''Pin Description and Size'''==
Line 26: Line 32:
  
 
=='''Working Principle'''==
 
=='''Working Principle'''==
[[image:CQRADC001-4.jpg|thumb|1000px| center]]
+
[[image:CQRADDR001-5-1.jpg|thumb|1000px| center]]
 
----
 
----
  
=='''Power Supply and Sensor Compatibility'''==
+
=='''Address Configuration'''==
This module supports dual-voltage operation at 3.3V/5V. When powered at 3.3V, all I/Os are at 3.3V level; when powered at 5V, the I2C signals are automatically converted to 3.3V for communication with the host, while also allowing measurement of 5V sensor signals. The module includes built-in protection circuits to prevent damage from overvoltage and provides a 3.3V LDO output to power external sensors.
+
 
 +
 
 +
*'''The module sets the address conversion value through voltage divider resistors at the XORH and XORL pins.'''
 +
 
 +
 
 +
[[image:CQRADDR001-711.jpg|thumb|1000px| center]]
 +
 
 +
 
 +
[[image:CQRADDR001-721.jpg|thumb|1000px| center]]
 +
 
 +
 
 +
*'''How to determine the resistance of welding resistor:'''
 +
 
 +
 
 +
First, based on the data sheet, the module determines whether a specific bit in the I2C address is inverted by the voltage of the XORH or XORL pins (i.e., VXORH or VORL relative to VCC). In Table 2 and 3, a bit value of 1 indicates inversion, while 0 indicates no inversion.
 +
 
 +
 
 +
[[image:CQRADDR001-73.jpg|thumb|1000px| center]]
 +
 
 +
[[image:CQRADDR001-75.jpg|thumb|1000px| center]]
 +
 
 +
 
 +
Assuming the VCC is now 5V, set A3-A0 to the 1 0 0 0 mode (A3 inverting while A2-A0 not). This requires VOXRL/VCC to be 0.53125±0.015, general formula: [VCC/(R1+R2)]R1=VXORL.
 +
 
 +
 
 +
Given the VCC of 5V and RLB of 100kΩ, the target VXORL should be 0.53125×5V=2.65625V. Substituting all parameters into the formula yields R2 ≈ 88.23529kΩ.
 +
 
 +
 
 +
Since this calculated R2 is not the exact common resistance, it should be matched with the closest common resistance value and verified through formula validation.
 +
 
 +
 
 +
Under this circumstance, the closest common resistance value to 88.23529kΩ is 86.6kΩ, so VXORL≈2.67953V, or VXORL/VCC≈0.53906. This ratio falls within 0.53125±0.015, making 86.6kΩ a suitable resistance value for RLT.
 +
 
 +
 
 +
[[image:CQRADDR001-76.jpg|thumb|1000px| center]]
  
Important: When measuring 5V sensors, the module must be powered at 5V. In this case, the I2C signals remain at 3.3V level and can be directly connected to 3.3V host GPIO. Note that the SDA and SCL pins on this module are limited to 3.3V.
 
 
----
 
----
  
 
=='''Connections and Examples'''==
 
=='''Connections and Examples'''==
{|
 
| style="text-align: center;" | [[File:CQRADC001-5.jpg|1150px|left]]
 
| style="text-align: center;" | [[File:CQRADC001-6.jpg|1100px|right]]
 
|}
 
'''Configuration Method:'''
 
Use a jumper cap to connect the ADDR pin to the corresponding voltage level point. After configuration, restart the power for the changes to take effect.
 
  
'''Using an I2C Address Conversion Module for Configuration:'''
+
[[image:CQRADDR001-7.jpg|thumb|1000px| center]]
When using an I2C address conversion module, all ADS1115 modules can be set to the same hardware address. Address differentiation is achieved by selecting channels on the conversion module, eliminating the need to modify hardware jumper configurations.
+
 
 +
----
 +
=='''Arduino Example and Test Code'''==
 +
 
 +
[[File:CQRADDR001-77.jpg|700px]]
 +
 
 +
*'''Sample Code:'''
 +
 
 +
 
 +
<pre>
 +
#include <Wire.h>
 +
 
 +
void setup() {
 +
  Serial.begin(9600);
 +
  Wire.begin();
 +
  Serial.println("Scan available I2C devices:");
 +
}
 +
 
 +
void loop() {
 +
  for(int addr = 1; addr < 127; addr++) {
 +
    Wire.beginTransmission(addr);
 +
    if(Wire.endTransmission() == 0) {
 +
      if(Wire.requestFrom(addr, (byte)1) > 0) {
 +
        Serial.print("✅ Available devices: 0x");
 +
        if(addr < 16) Serial.print("0");
 +
        Serial.println(addr, HEX);
 +
        while(Wire.available()) Wire.read();
 +
      }
 +
    }
 +
  }
 +
  delay(3000);
 +
}
 +
</pre>
 +
 
 +
 
 +
*'''Test Results:'''
 +
 
 +
 
 +
[[File:CQRADDR001-78.jpg|700px]]
 +
 
 +
 
 +
Set the serial port to 9600. Open the serial port debugger to view the bidirectional I2C address. After toggling the DIP switch to change the address, power on again. The new address will appear in the serial port debugger.
 +
 
 
----
 
----
 +
=='''Raspberry Pi Example and Test Code'''==
 +
 +
'''First, visit the Raspberry Pi official website to download the system. You must select the download option in the frame below; otherwise, the sensor will not function properly.'''
 +
 +
*Download link: https://www.raspberrypi.com/software/operating-systems/#raspberry-pi-os-legacy-64-bit
 +
 +
[[File:CQRADDR001-791.jpg|700px]]
 +
 +
*Schematic Diagram of Raspberry Pi 4B pins:
 +
 +
[[File:CQRADDR001-80.jpg|700px]]
 +
 +
[[File:CQRADDR001-81.jpg|700px]]
 +
 +
[[File:CQRADDR001-82.jpg|700px]]
 +
 +
Create a folder and a “.c” file, then write the code.
 +
 +
[[Media: I2C.rar]]
  
=='''Used in Conjunction with the TDS Meter Sensor (ASIN: B08KXRHK7H)'''==
+
You can directly add to the compressed file.
[[image:CQRADC001-7.jpg|thumb|1000px| center]]
+
 
'''Example Program'''
+
[[File:CQRADDR001-83.jpg|700px]]
 +
 
 +
gcc -Wall -g -o I2C I2C.c -lm
 +
 
 +
./I2C
 +
 
 +
Go to the folder created in the terminal, use GCC cross-compilation and run the file.
 +
 
 +
*'''Sample Code:'''
 +
 
 +
<pre>
 +
include <stdio.h>
 +
#include <stdlib.h>
 +
#include <unistd.h>
 +
#include <fcntl.h>
 +
#include <sys/ioctl.h>
 +
#include <linux/i2c-dev.h>
 +
int main() {
 +
    int file;
 +
    char filename[20];
 +
   
 +
    printf("Scan available I2C devices...\n\n");
 +
   
 +
    snprintf(filename, 19, "/dev/i2c-1");
 +
    file = open(filename, O_RDWR);
 +
    if (file < 0) {
 +
        printf("Error: Unable to open I2C bus\n");
 +
        return 1;
 +
    }
 +
   
 +
    printf("The discovered I2C device address:\n");
 +
   
 +
    for (int addr = 0x03; addr <= 0x77; addr++) {
 +
        if (ioctl(file, I2C_SLAVE, addr) >= 0) {
 +
            unsigned char buffer[1];
 +
            if (read(file, buffer, 1) == 1) {
 +
                printf("0x%02X\n", addr);
 +
            }
 +
        }
 +
    }
 +
   
 +
    close(file);
 +
    printf("\nScan completed\n");
 +
return 0;}
 +
</pre>
 +
 
 +
 
 +
*'''Test Results:'''
 +
 
 +
 
 +
[[File:CQRADDR001-85.jpg|700px]]
 +
 
 +
 
 +
After toggling the DIP switch to change the address, power on again.
 
----
 
----
 +
=='''Sensor Does Not Work Properly'''==
 +
 +
'''Answer:'''
 +
 +
*Ensure the sensor wiring is correctly connected to the development board;
 +
 +
*Verify that the board program is properly burned.
  
=='''Sample Code'''==
+
----

Latest revision as of 04:23, 29 January 2026

I2C Address Converter Module

Description

LTC4316 I2C Address Translation Module is a practical I2C bus expansion tool designed to resolve I2C device address conflicts. This module can translate the fixed hardware address of an I2C device into a different communication address, enabling multiple devices with identical addresses to operate simultaneously on the same I2C bus.


Features

  • Efficient Address Conflict Solution: Based on the LTC4316IMS chip, it can translate the fixed hardware address of an I2C device into 127 distinct communication addresses, effectively resolving address conflicts on the I2C bus.
  • Wide Voltage Operating Range: Supports power supply voltages from 2.25V to 5.5V, ensuring compatibility with various logic level systems.
  • Hardware-Level Transparent Translation: Configures address offsets through a resistive voltage divider network and performs real-time address translation, remaining entirely transparent to both master and slave devices.
  • Flexible Address Configuration: Enables independent configuration of the high 3-bit and low 4-bit address offsets via the XORH/XORL pins using resistor voltage division, with support for quick switching via DIP switches.
  • Industrial-Grade Protection Design: Features separate interfaces for the master side (SCLIN/SDAIN) and slave side (SCLOUT/SDAOUT), providing clear signal flow isolation.
  • Standard Interface Compatibility: Equipped with dual interfaces—HY2.0mm 4P connectors and 2.54mm pin headers—for easy connection to various development boards and sensor modules.

Certification Documents

Media:CQRADDR001-CE-Certification.rar

Media:CQRADDR001-FCC-SDOC-Certification.rar

Pin Description and Size

CQRobot.jpg
CQRADDR001-1.jpg
CQRADDR001-2.jpg

Specification

CQRADDR001-3.jpg
CQRADDR001-4.jpg

Working Principle

CQRADDR001-5-1.jpg

Address Configuration

  • The module sets the address conversion value through voltage divider resistors at the XORH and XORL pins.


CQRADDR001-711.jpg


CQRADDR001-721.jpg


  • How to determine the resistance of welding resistor:


First, based on the data sheet, the module determines whether a specific bit in the I2C address is inverted by the voltage of the XORH or XORL pins (i.e., VXORH or VORL relative to VCC). In Table 2 and 3, a bit value of 1 indicates inversion, while 0 indicates no inversion.


CQRADDR001-73.jpg
CQRADDR001-75.jpg


Assuming the VCC is now 5V, set A3-A0 to the 1 0 0 0 mode (A3 inverting while A2-A0 not). This requires VOXRL/VCC to be 0.53125±0.015, general formula: [VCC/(R1+R2)]R1=VXORL.


Given the VCC of 5V and RLB of 100kΩ, the target VXORL should be 0.53125×5V=2.65625V. Substituting all parameters into the formula yields R2 ≈ 88.23529kΩ.


Since this calculated R2 is not the exact common resistance, it should be matched with the closest common resistance value and verified through formula validation.


Under this circumstance, the closest common resistance value to 88.23529kΩ is 86.6kΩ, so VXORL≈2.67953V, or VXORL/VCC≈0.53906. This ratio falls within 0.53125±0.015, making 86.6kΩ a suitable resistance value for RLT.


CQRADDR001-76.jpg

Connections and Examples

CQRADDR001-7.jpg

Arduino Example and Test Code

CQRADDR001-77.jpg

  • Sample Code:


#include <Wire.h>

void setup() {
  Serial.begin(9600);
  Wire.begin();
  Serial.println("Scan available I2C devices:");
}

void loop() {
  for(int addr = 1; addr < 127; addr++) {
    Wire.beginTransmission(addr);
    if(Wire.endTransmission() == 0) {
      if(Wire.requestFrom(addr, (byte)1) > 0) {
        Serial.print("✅ Available devices: 0x");
        if(addr < 16) Serial.print("0");
        Serial.println(addr, HEX);
        while(Wire.available()) Wire.read();
      }
    }
  }
  delay(3000);
}


  • Test Results:


CQRADDR001-78.jpg


Set the serial port to 9600. Open the serial port debugger to view the bidirectional I2C address. After toggling the DIP switch to change the address, power on again. The new address will appear in the serial port debugger.


Raspberry Pi Example and Test Code

First, visit the Raspberry Pi official website to download the system. You must select the download option in the frame below; otherwise, the sensor will not function properly.

CQRADDR001-791.jpg

  • Schematic Diagram of Raspberry Pi 4B pins:

CQRADDR001-80.jpg

CQRADDR001-81.jpg

CQRADDR001-82.jpg

Create a folder and a “.c” file, then write the code.

Media: I2C.rar

You can directly add to the compressed file.

CQRADDR001-83.jpg

gcc -Wall -g -o I2C I2C.c -lm

./I2C

Go to the folder created in the terminal, use GCC cross-compilation and run the file.

  • Sample Code:
include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <linux/i2c-dev.h>
int main() {
    int file;
    char filename[20];
    
    printf("Scan available I2C devices...\n\n");
    
    snprintf(filename, 19, "/dev/i2c-1");
    file = open(filename, O_RDWR);
    if (file < 0) {
        printf("Error: Unable to open I2C bus\n");
        return 1;
    }
    
    printf("The discovered I2C device address:\n");
    
    for (int addr = 0x03; addr <= 0x77; addr++) {
        if (ioctl(file, I2C_SLAVE, addr) >= 0) {
            unsigned char buffer[1];
            if (read(file, buffer, 1) == 1) {
                printf("0x%02X\n", addr);
            }
        }
    }
    
    close(file);
    printf("\nScan completed\n");
return 0;}


  • Test Results:


CQRADDR001-85.jpg


After toggling the DIP switch to change the address, power on again.


Sensor Does Not Work Properly

Answer:

  • Ensure the sensor wiring is correctly connected to the development board;
  • Verify that the board program is properly burned.