Skip to content

Examples do not work with esp_hal 1.0.0.rc1 #5

@justrandomgenerateduser

Description

@justrandomgenerateduser

Due to GPIO changes mentioned in the changelog:

The OutputOpenDrain driver has been removed. You can use Output instead with
DriveMode::OpenDrain. The input-related methods of OutputOpenDrain (level,
is_high, is_low) are available through the (unstable) Flex driver.

- OutputOpenDrain::new(peripherals.GPIO0, Level::Low);
+ Output::new(
     peripherals.GPIO0,
     Level::Low,
     OutputConfig::default()
         .with_drive_mode(DriveMode::OpenDrain),
 );

Due to that the examples no longer works.

My workaround was:

        let delay = Delay::new();
        let mut pin = Output::new(
            peripherals.GPIO5,
            Level::High,
            OutputConfig::default().with_drive_mode(DriveMode::OpenDrain),
        )
        .into_flex();
        pin.set_input_enable(true);
        pin.set_output_enable(true);
        let mut dht22 = Dht22::new(pin, delay);
        loop {
            match dht22.read() {
                Ok(sensor_reading) => log::info!(
                    "DHT 22 Sensor - Temperature: {} °C, humidity: {} %",
                    sensor_reading.temperature,
                    sensor_reading.humidity
                ),
                Err(error) => {
                    log::error!("An error occurred while trying to read sensor: {:?}", error)
                }
            }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions