How to use mpu6050 accelerometer with i2c-4

pip install adafruit-circuitpython-mpu6050
pip install adafruit-blinka

Simple example

import time
import busio
import board
from adafruit_mpu6050 import MPU6050

Utiliza los pines específicos para el bus I2C-4

i2c_bus = busio.I2C(board.D4_B3, board.D4_B2)

Inicializa el sensor MPU6050

mpu = MPU6050(i2c_bus)

while True:
# Lee los datos del acelerómetro
accel_x, accel_y, accel_z = mpu.acceleration
# Lee los datos del giroscopio
gyro_x, gyro_y, gyro_z = mpu.gyro

# Imprime los datos del acelerómetro y giroscopio
print(f"Acelerómetro: X={accel_x:.2f}, Y={accel_y:.2f}, Z={accel_z:.2f} m/s^2")
print(f"Giroscopio: X={gyro_x:.2f}, Y={gyro_y:.2f}, Z={gyro_z:.2f} rad/s")
print("")

# Espera un segundo antes de la siguiente lectura
time.sleep(1)

Here is a demo for raspberry pi which uses python lib smbus, perhaps you can refer to it.

No, no, its on radxa zero 3w

I mean you can see how this demo is implemented, since the smbus library is generic.

This demo works fine on 3W.

@Nasca I have some previous HV, and i use bus 3, pin 3, and pin 5 on this board, however, i noticed the new revision: https://docs.radxa.com/en/zero/zero3/hardware-design/hardware-interface i2c3 is not available, is it correct?

Can you provide which HW version is the latest one and clarify this for the latest board version:

“Pin 3, Pin 5, Pin 27, and Pin 28 add extra pull-up resistors for I2C device power supply, so they work abnormally when used as GPIOs.”

I2C3 is occupied by kernel default.


Yep, i disabled it. I thought it fusb was necessary to be enabled for the wifi, but board works without it.
I haven’t tested USB3 yet. Can you clarify what the fusb302 at 3W is for?

usbc0 node is used for usb 3.0 port.

1 Like

I used the i2c = busio.i2c(board.D4_B3, board.D4_B2) with great success. However, I have two screens I want to use that can be identified ad 0x3c and 0x3d when I run i2cdetect -y 4 as a search.
Is there any way I can set the address when coding with busio?

It should not be possible to set an i2c address by encoding it. The I2C address is set by hardware. In i2c Oled, this can be set via the address selection line or via other hardware means.

For example, if the address selector line is connected to gnd , the address of the i2c oled is 0x3c, if it is connected to vcc , the address is 0x3d.

Or some people are pulling pin 16 of the row up through an external resistor to change the i2c address of the oled.
https://electronics.stackexchange.com/questions/565641/changing-the-i2c-address-of-a-different-type-of-oled-display

For details, you need to refer the i2c oled datasheet.