I2C unable to read or write in register

I want to use a Barometer 2 Click (LPS35HW) but so far enable to read or write correctly in the various register
One of the register is called WHO_AM_I (register 0x0F) and is supposed to return the value 10110001.

Every time I got the value 0x22 instead of 0xB1.
Writing a value and reading back in any of the R/W register do not work,returned values are incorrect but always the same
Could a defective chip always return the same value ?

public Barometer2Click(bool lowBusSpeed,string i2CControllerName)
var settings = new I2cConnectionSettings(0xB8, (uint) (lowBusSpeed ? 100_000 : 400_000));
var controller = I2cController.FromName(i2CControllerName);
Barometer2 = controller.GetDevice(settings);

    /// <summary>
    /// Initialisation of the PLS35HW (set bit 2)
    /// </summary>
    public bool Initialization()
        // Read Register WHO_AM_I (0x0F) : should be 10110001
        byte[] rxBuffer = new byte[1];
        Barometer2.WriteRead(new[] {WhoAmI}, rxBuffer);

Try with address = 0x5C

1 Like

:pray: :+1: Short and efficient response . Thanks Christophe

Now the complete story :wink:

First thing to think at with I2C : if address is greater than 0x7F (or better greater than 0x80), then you’re wrong and you have to right-shift it once. Hence the 0x5C here :wink:

Reminder : I2C address is 7 bits length. The 8th bit determines read or write operation.

You’re right. Something that I need to remember. I took the address from the datasheet and forget about 7 bits address. But making a mistake help you to avoid to do it again in the future (normally)
Thanks again. All readings fine

1 Like