cancel
Showing results for 
Search instead for 
Did you mean: 

LPS28DFW arduino

ljm
Associate III

Hello,

Actually i'm trying to mesure the pressure using LPS28DFW and arduino uno, but i have some problems, the i2c communication does not working.

Can help me please and thank you.

arduino code : 

#include <Wire.h>
#include "SparkFun_LPS28DFW_Arduino_Library.h"

// Create a new sensor object
LPS28DFW pressureSensor;

// I2C address selection
uint8_t i2cAddress = LPS28DFW_I2C_ADDRESS_DEFAULT; // 0x5C
//uint8_t i2cAddress = LPS28DFW_I2C_ADDRESS_SECONDARY; // 0x5D

void setup()
{
    // Start serial
    Serial.begin(115200);
    Serial.println("LPS28DFW Example 1 - Basic Readings!");

    // Initialize the I2C library
    Wire.begin();

    // Check if sensor is connected and initialize
    // Address is optional (defaults to 0x5C)
    while(pressureSensor.begin(i2cAddress) != LPS28DFW_OK)
    {
        // Not connected, inform user
        Serial.println("Error: LPS28DFW not connected, check wiring and I2C address!");

        // Wait a bit to see if connection is established
        delay(1000);
    }

    Serial.println("LPS28DFW connected!");
}

void loop()
{
    // Get measurements from the sensor. This must be called before accessing
    // the pressure data, otherwise it will never update
    pressureSensor.getSensorData();

    // Print temperature and pressure
    Serial.print("Temperature (C): ");
    Serial.print(pressureSensor.data.heat.deg_c);
    Serial.print("\t\t");
    Serial.print("Pressure (hPa): ");
    Serial.println(pressureSensor.data.pressure.hpa);

    // Only print every second
    delay(1000);
}
2 REPLIES 2
Federica Bossi
ST Employee

Hi @ljm ,

Two suggestions: the CS must be high when you are in I2C, in addition you can check if the SDO pin matches the address set.

Hope this helps

In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.

 

Hello,
I have a question.
For the LPS22DF, in fact I do shock tests, and I compare the measurement of the sensor with a reference, in a certain number of shocks I saw that the difference was 20 mbar but when I continue the test with more shocks I saw that the difference was decreased to 13 mbar, is it the membrane that has moved? or another mechanical phenomenon that has passed?

I'm applying tests of 10,000 and 20,000 shocks (between 200 and 300 g each).
Yes, I'm measuring the temperature (between 19°C and 24°C).

i'm using 10 simples, 

only the sample number 8 has this deviation from 13 mbar of difference to 20 mbar and by continuing to test, it was back to 13mbar of difference.

the rest of samples are all the sample difference of measurements