RDK: IIC Communication
Introduction
This repository provides Python example code for communication between the RDK X5 (Raspberry Pi) platform and the AI voice interaction module, supporting two communication methods: I2C and UART.
Speech recognition module: supports offline speech recognition and outputs the command ID after recognition
Playback functions: supports passive playback, function word playback and command word playback
Communication protocol: I2C address 0x2A, UART baud rate 115200
Programming language: Python 3
Hardware Connection
General Connection
Important: make sure all devices share a common ground!
I2C Version Connection
Note: I2C bus 5 (BCM numbering) is used by default

Environment Setup
System Requirements
RDK X5
Ubuntu / Debian system
Python 3.7+
Install Dependency Packages
# Update packages
sudo apt update
sudo apt upgrade -y
# Install Python libraries
sudo apt install -y python3-pip python3-smbus i2c-toolsEnable the I2C Interface
# Open the configuration tool
sudo raspi-config
# Select Interface Options → I2C → Enable
# Reboot to take effect
sudo rebootTest the Hardware Interfaces
# Test the I2C device
sudo i2cdetect -y 5Using the IIC Version
Check the Code Files
cd IIC_Voice
ls -la
# You should see iic_voice.pyConfigure the I2C Bus
Edit the iic_voice.py file and modify the required parameters:
# I2C device address
DEVICE_ADDRESS = 0x2A
# Register address
REG_RESULT = 0xDA
# I2C bus number (modify according to the actual connection)
bus = smbus.SMBus(5) # I2C bus 5Run the Program
# Grant execute permission
chmod +x iic_voice.py
# Run (sudo privileges required to access I2C)
sudo python3 iic_voice.pyRunning Test
After a normal startup it will display:
Speech Serial Opened! Baudrate=115200Say a command word to the voice module and the corresponding ID will be displayed:
Speech Serial Opened! Baudrate=115200
ID:1
ID:4
ID:10Stop the Program
Press Ctrl + C to stop the program:
Program terminatedTroubleshooting
Q1: Insufficient permission for I2C operations
A: Add the user to the I2C user group:
sudo usermod -aG i2c $USER
# Takes effect after logging in againOr run the program with sudo
Q2: The I2C device cannot be scanned
A: Check:
Confirm that I2C is enabled (raspi-config)
Check whether SDA/SCL are reversed
Check whether the grounds are common
Check whether the device is powered
# Scan I2C devices
sudo i2cdetect -y 5
# If you see 0x2A, the device is connected properlyQ3: The command ID only shows 0 or does not appear
A: Normal behavior:
0 = no valid command recognized
the ID is output only when a valid command word is spoken
wake the module first, then say the command
Q4: Recognition accuracy is not high
A: Optimization suggestions:
Keep the environment quiet and the background noise low
Keep a moderate distance from the microphone (10-50cm)
Speak at a moderate rate and articulate clearly
Technical Support
If there are problems, please check:
Whether the hardware wiring is correct (a common ground is very important!)
Whether the serial port baud rate is 115200
Whether the I2C address is correct (0x2A)
Whether there is sufficient permission to access the hardware interface
Common Debugging Commands
ls -l /dev/i2c* # View I2C devices
groups # Check user group permissions
