Using an Output in I2c::new

cmumford
Posts: 5
Joined: Fri Dec 11, 2020 4:29 pm

Using an Output in I2c::new

Postby cmumford » Sun Dec 21, 2025 7:07 pm

I'm writing a no_std esp-hal (v1.0.0) Rust application for the ESP32. Here is some existing code that initializes the I2C controller to talk to another device. This is working just fine and I can talk to my existing I2C device just fine.

Code: Select all

info!("[main] Initializing I2C");
let i2c = I2c::new(
    peripherals.I2C0,
    esp_hal::i2c::master::Config::default().with_frequency(Rate::from_khz(100)),
)
.unwrap()
.with_scl(peripherals.GPIO20)
.with_sda(peripherals.GPIO19)
.into_async();
What I'm trying to do is to add a second I2C device to the bus. This chip (Si7403 radio) needs a few pins to be raised/lowered to initialize it and configure its mode of operation. So, I'm trying to use esp-hal::gpio to bit-bang the pins in order to init this chip before continuing to initialize the I2C controller. So I switch from giving peripherals.GPIO19 to I2c, to instead creating an Output instance. Here is the new code that doesn't work.

Code: Select all

let mut sda_pin = Output::new(
    peripherals.GPIO19,
    Level::High,
    OutputConfig::default().with_drive_mode(DriveMode::OpenDrain),
);

// GPIO initialization will go here:

info!("[main] Initializing I2C");
let i2c = I2c::new(
    peripherals.I2C0,
    esp_hal::i2c::master::Config::default().with_frequency(Rate::from_khz(100)),
)
.unwrap()
.with_scl(peripherals.GPIO20)
.with_sda(sda_pin)
.into_async();
When I do this, my existing device fails to respond. I've also tried OpenDrain on the Output, but that has no effect. Anybody know what I'm doing wrong here?

Prestorey
Posts: 1
Joined: Mon Jan 05, 2026 12:39 pm

Re: Using an Output in I2c::new

Postby Prestorey » Thu May 21, 2026 3:02 pm

I will try connecting 2 I2C Devices and I will let you know my findings !

Who is online

Users browsing this forum: No registered users and 0 guests