1

I am trying to write some code to connect and drag data across I2C using the Wiring Pi library, I'm at the stage where any data would be good but this is a link to the sensor's datasheet I'm trying to get data from MS5637-02BA03 Data Sheet.

I believe I have wired everything up correctly and my Raspberry Pi is detecting the device using i2cdetect on address 0x76 as shown below.

     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f

00:          -- -- -- -- -- -- -- -- -- -- -- -- --         
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- 76 --

My call to wiringPiI2CSetup seems to be getting called successfully, (returning a value of 3). But all subsequent write attempts are returning values of -1 with an error of 5 (IO Error).

Here is the code I am using

#include <stdio.h>
#include <wiringPiI2C.h>
#include <errno.h>

int main() {
    int returnVal;
    int fd;

    fd = wiringPiI2CSetup(0x76);
    printf("%d\n", fd);
    returnVal = wiringPiI2CWriteReg8(fd, 0xEC, 0x1E);
    if (returnVal == -1) printf("error - %d\n", errno);
    printf("%d\n", returnVal);
    returnVal = wiringPiI2CWriteReg8(fd, 0xEC, 0xA0);
    printf("%d\n", returnVal);
    return 0;
}

The values I get in return are:

3 
error - 5
-1
-1

Page 9 of that data sheet seems to suggest that I need to write to the 0xEC register to issue commands, which is what I am trying to do. It says:

Each I2C communication message starts with the start condition and it is ended with the stop condition. The MS5637 address is 1110110x (write : x=0, read : x=1).

Am I reading this wrong or completely missing something? I've used this baro sensor on an Arduino so I can confirm the sensor is in working order.

Any help would be greatly appreciated.

0

I have a different interpretation of the datasheet.

The device has no registers, you just send commands.

For example

  • to reset the device: send the single byte 0x1E
  • to read PROM location 0: send the single byte 0xA0 and then read two bytes back

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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