Skip to content

Proposal: Adding an LP I2C Example (using SHT30) #4657

@MabezDev

Description

@MabezDev

Discussed in https://github.com/esp-rs/esp-hal/discussions/4625

Originally posted by puyogo-suzuki December 8, 2025
Hello everyone!

Thank you to the maintainers for merging my recent PR #4612 regarding the LP Core.

I'd like to propose adding an LP I2C example (utilizing the LP Core) to demonstrate continuous sensor reading. This example addresses the bugs that were fixed in my previous work.

I'd appreciate discussion on two specific points:

  • Name: How should we name the new LP I2C example(s)?
  • Sensor Choice: I don't have a BMP180 sensor. Would using the SHT30 be an acceptable alternative for this example?

Example Overview

The goal is to add an example that reads temperature and humidity continuously using the SHT30 sensor.

This example will be a derivation of the present lp_core example (see LP Code and HP Code).

The proposed logic uses fixed addresses between the LP and HP cores like the lp_core example:

LP Core Code (Reading)

fn read_temp_and_humid(&mut i2c: LpI2c) -> (i32, i32) {
 // ... sensor reading logic
}

#[entry]
fn main(mut i2c: LpI2c) -> ! {
    let temp_ptr = TEMP_ADDRESS as *mut i32;
    let humid_ptr = HUMID_ADDRESS as *mut i32;
    loop {
        let (temp, humid) = read_temp_and_humid(&i2c);
        unsafe {
            temp_ptr.write_volatile(temp);
            humid_ptr.write_volatile(humid);
        }
        Delay.delay_ms(1000);
    }
}

HP Core Code (Printing)

let temp = TEMP_ADDRESS as *mut i32;
let humid = HUMID_ADDRESS as *mut i32;
loop {
    print!("Current {}C  {}%          \u{000d}", unsafe {
        temp.read_volatile(), humid.read_volatile()
    });
}

Naming Suggestion

Currently, the LP core example is named lp_core.

I propose the following naming scheme:

  1. Rename the existing example from lp_core to lp_core_blinky (since it demonstrates basic functionality).
  2. Add the new I2C example as lp_core_i2c_sht30.

The esp-lp-hal/example directory already contains i2c.rs for the BMP180.
Should I add the new example as i2c_sht30.rs to this directory?

Sensor Choice (SHT30 vs. BMP180)

The BMP180 pressure sensor seems somewhat outdated and has limited availability now.

The SHT30 is a modern and very common temperature/humidity sensor (used, for example, in M5 ENV units).
It's also suitable for an example as it requires no complex initialization; reading values only requires sending 0x2C 0x06.
I believe SHT30 is a better fit for a contemporary example.

I'd like to get the maintainer's perspective on both the naming and the sensor choice before proceeding with the implementation.

Thank you!

Metadata

Metadata

Assignees

No one assigned

    Labels

    examplesThere is a problem with one or more of the examples

    Type

    No type

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions