Tuesday, 6 November 2012

Pressure and Temperature over I2C

I picked up the Adafruit MPL115A2 - I2C Barometric Pressure/Temperature Sensor and connected it up using I2C and ran their sample program. First thing I learned is that I really should read the data sheets. The resolution is 0.15 kPa (=1.5 hPa a unit I seldom encounter) and the absolute accuracy is 1 kPa. Thus, values that vary a lot and differ from Environment Canada shouldn't be a surprise. Here's some sample output:

Pressure (kPa): -2929.0664 kPa
Temp (*C): -12035.9 *C
Pressure (kPa): 102.2696 kPa
Temp (*C): 22.6 *C

Note that the large negative numbers are ridiculous, and I don't know where they're coming from. The reasonable numbers seem to be within spec.

So I went to the adafruit forum and looked up the product. Others were having the same problem. That made me think it was software. Following some suggestions, I started messing with the library and found the bug. I fixed it, then posted about the fix, then posted new source code (that actually got accepted) to the code repository, which may make me a geek.

Bottom line: Spend a little more and get the BMP085 Breakout that provides accuracy high enough to detect raising and lowering the board by a metre. Unfortunately it also seem to be fragile enough that I busted one soldering it into a protoboard, so be careful with heat and static.

No comments:

Post a Comment