0

I'm trying to read data from a pressure sensor from BB Sensors over i2c. They haven't made it especially easy. It uses a reserved address by default (0x78) and it also uses some sort of cut-down version of i2c reading AFAICT. In normal operation the device exposes no registers (you have to put it into "Command mode" by sending a special command byte immediately after power-on to allow writing to its control registers), you simply address it for reading and it sends back 2 bytes of data. I can use i2cget to read from it but the value doesn't make much sense and I believe that I'm only getting the first byte of a 2 byte word like this. Reading the man page, i2cget allows me to specify a mode ('w') for reading a word instead of a byte, but only if I also send a register/data-address. From what I understand, this is like going to generate an i2c write from the master with the register address, followed by a read - and this doesn't appear to work with this sensor which is expecting me just to read values.

Is there a way to do what I need to with i2cget? Looking at the python smbus module it seems like I'm going to have the same problem. Is the sensor's I2C implementation just irredeemably wrong? What options do I have here?

Data sheet excerpt (sadly not hosted anywhere publicly that i can find): Data sheet excerpt

1 Answer 1

2

I think you just read two or four bytes from the sensor depending on which type of sensor you have.

Your pressure sensor provides 2 byte readings.

To test use pigpio as follows.

sudo pigpiod # start the pigpio daemon

pigs i2co 1 0x78 0 # get handle to I2C bus 1 device 0x78

The i2co should return 0 as the handle (0 being the first handle).

Then to get a reading do

pigs i2crd 0 2 -x # read two bytes from handle 0, display as hex

The i2crd should return 2 followed by the data bytes (most significant byte first).

1
  • Fantastic. For some reason reading more than 1 byte from the default register doesn't seem to be a feature of i2cget or the python smbus library - they only let you read multiple bytes if you're reading from a specific register which seems to work very differently. The next problem is that the sensor provides very unstable readings, not sure if that's interference on the i2c level or just the intrinsic instability of the sensor itself.
    – hollandlef
    Feb 7, 2021 at 18:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.