Skip to main content
July 4, 2023
Question

lps22hb i2c interface(erorrs)

  • July 4, 2023
  • 9 replies
  • 2690 views

Hello, 

We want to operate the LPS22HB pressure sensor with the i2c protocol. The pin legs of the sensor are connected to the SCL - SDA 4.7k ohm pull-up resistors. Sa0/GND   Csi / 3.3  RES / GND. This is how connections are made. This way we can't get data from the sensor. What is the reason of this?

 

    This topic has been closed for replies.

    9 replies

    July 4, 2023
    July 4, 2023
    ST Employee
    July 4, 2023

    Hello @Legacy member , 

    First please make sur that your are using the correct address. You can use an oscilloscope to check SDA and SCL behavior.
    Could you share the code ? 

    Foued

    July 4, 2023

    @Foued_KH  Thankk youu <3

    All settings are used by default. The code is the library ready code written in arduino. Address 5C and all of its derivatives have been tested by changing the test from within the library. The interrupt pin is not connected anywhere, any problem occurs?


    #include <Arduino_LPS22HB.h>

    void setup() {
      Serial.begin(9600);
      while (!Serial);

      if (!BARO.begin()) {
        Serial.println("Failed to initialize pressure sensor!");
        while (1);
      }
    }

    void loop() {
      // read the sensor value
      float pressure = BARO.readPressure();

      // print the sensor value
      Serial.print("Pressure = ");
      Serial.print(pressure);
      Serial.println(" kPa");

      float temperature = BARO.readTemperature();

      // print the sensor value
      Serial.print("Temperature = ");
      Serial.print(temperature);
      Serial.println(" C");

      // print an empty line
      Serial.println();

      // wait 1 second to print again
      delay(1000);
    }
    July 5, 2023
    ST Employee
    July 5, 2023

    For I2C communication, 2 pins are required to interface, as this :
    VDD to 3.3V DC
    SCL to A5
    SDA to A4
    GND to common groud

    Foued

    Visitor II
    July 5, 2023

    @KHALSI_Foued 

    I've already done what you said, I can't get it to work.
     
    Technical Moderator
    July 5, 2023

    Hi,

    The I2C address for LPS22HB is 0xBA or 0xB8 according with SA0  (datasheet page 26).

    Visitor II
    July 5, 2023

    We tried the solutions you suggested but we can't get a solution. Do you have any other suggestions?

    Technical Moderator
    July 6, 2023

    Hi @Sinoplu57 ,

    In alternative you can try to reduce the pull up resistances, for example you can use 2.2kOhm.

    Let me know if this solves.