int bmp085ReadInt(unsigned char address)
{
unsigned char msb, lsb;
Wire.beginTransmission(BMP085_ADDRESS);
Wire.write(address);
Wire.endTransmission();
Wire.requestFrom(BMP085_ADDRESS, 2);
while(Wire.available()<2)
;
msb = Wire.read();
lsb = Wire.read();
return (int) msb<<8 | lsb;
}
I am trying to read from a BMP085 sensor and something wonky is going on. I think it is in the wire library.
When I call the above function with this command
mc = bmp085ReadInt(0xBC);
The ESP2866 appears to store a value of 54461. The variable mc is used in a compensation (from calibration info) calculation.
When I run the same code on an Uno with the same BMP085, mc stores a value of -11075.
In binary these numbers are only a digit apart:
11010100 10111100
11010100 10111101
I am still trying to work out where it is happening, but it appears that the ESP module is failing to pick up on the fact that this is a signed value being read from the calibration data on the chip...