I have BMP180 connected to my RPi, I can read calibration data from it, but when I try to get pressure / temperature data -- I get 80 00
for temp and 80 00 00
for pressure (mean -- 'just-after-reboot value')
the communication log (reading data part) looks like:
device <-- f4
delay for (asked 50us) 0s 0ms 57us
device <-- 2e
delay for (asked 50us) 0s 0ms 56us
delay (asked 5 ms) for 0s 5ms 139us
device [f6] -> 80 00
device <-- f4
delay for (asked 50us) 0s 0ms 56us
device <-- b4
delay for (asked 50us) 0s 0ms 393us
delay (asked 14 ms) for 0s 14ms 149us
device [f6] -> 80 00 00
bcm085: t=51.1 p=104462
chipid: 85 version: 2 Calibration data: ac1=0198 ac2=ffb8 ac3=c7d1 ac4=7fe5 ac5=7ff5 ac6=5a71 b1=182e b2=0004 mb=8000 mc=ddf9 md=0b34 Raw data: rt=8000 rp=020000
50 µs delays after each read/write operations can be dropped from sequence with same result. also, increasing wait times from 5 ms to any -- won't help.
Communication code:
#define BMP180_READ_ADDRESS 0x77
#define BMP180_WRITE_ADDRESS 0x77
#define BMP085_REG_CALIBRATION_DATA_ADDR 0xAA
#define BMP085_REG_CHIPID 0xD0
#define BMP085_REG_VERSION 0xD1
#define BMP085_CMD_CONTROL 0xf4
#define BMP085_REG_TEMPDATA 0xf6
#define BMP085_REG_PRESDATA 0xf6
#define BMP085_CMD_READTEMP 0x2e
#define BMP085_CMD_READPRES 0x34
#define BMP085_CMD_SOFTRESET 0xE0
// get raw temperature
bcm2835_i2c_setSlaveAddress(BMP180_WRITE_ADDRESS);
i2c_reg_set8(BMP085_CMD_CONTROL, BMP085_CMD_READTEMP);
rpi_delay(5);
char tempReadBuf[2];
i2c_read_reg(BMP085_REG_TEMPDATA, tempReadBuf, sizeof(tempReadBuf));
tempRawData = (int)tempReadBuf[0] << 8 | (int)tempReadBuf[1];
// get raw pressure
i2c_reg_set8(BMP085_CMD_CONTROL, BMP085_CMD_READPRES + (oversampling << 6));
rpi_delay(2 + (3 << oversampling));
char presReadBuf[3];
i2c_read_reg(BMP085_REG_PRESDATA, presReadBuf, sizeof(presReadBuf));
presRawData = (int)presReadBuf[0] << 16 | (int)presReadBuf[1] << 8 | (int)presReadBuf[2];
presRawData >>= (8-oversampling);
I use libbcm2835 library for access device, without any other libs like wiringPi or smbus. i2c_* and rpi_delay functions are wrappers over libbcm2835 and they do work with other devices.
Can somebody help me please with finding an issue?
Update: more detailed code on pastebin:
- bmp.cpp : http://pastebin.com/NGGWCByp
- i2c_rw.cpp: http://pastebin.com/Ncpg13ZK (warppers over libbcm2835 i2c read/write functions)
- tools.cpp : 9BAAVGEc (wrappers over libbcm2835 delay functions)
<linux/i2c-dev.h>
) interface. I'm gonna disagree a bit w/ joan in that I think just because you have a methodology for talking with one I2C device does not mean it will work with all I2C devices.