0

MPL115A2 Pressure and Temp Breakout - bad readings below 22*C
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

MPL115A2 Pressure and Temp Breakout - bad readings below 22*C

by kellyf on Sat Oct 06, 2012 12:46 pm

I just received the MPL115A2-IC2 breakout from you and the sample "getpressure" sketch works above ~22.6*C, but below this I'm getting strange readings like -12041.0*C. Is there a narrow usable range for this sensor or do you think something else if going on?

Here is a sample from the serial monitor as it cools off a bit:

Temp (*C): 23.7 *C
Pressure (kPa): 102.2354 kPa
Temp (*C): 23.5 *C
Pressure (kPa): 102.1922 kPa
Temp (*C): 23.3 *C
Pressure (kPa): 102.1922 kPa
Temp (*C): 23.3 *C
Pressure (kPa): 102.2985 kPa
Temp (*C): 23.3 *C
Pressure (kPa): 102.1489 kPa
Temp (*C): 23.1 *C
Pressure (kPa): 102.2985 kPa
Temp (*C): 22.9 *C
Pressure (kPa): 102.2747 kPa
Temp (*C): 23.1 *C
Pressure (kPa): 102.2747 kPa
Temp (*C): 22.9 *C
Pressure (kPa): 102.2313 kPa
Temp (*C): 22.9 *C
Pressure (kPa): 102.2313 kPa
Temp (*C): 22.6 *C
Pressure (kPa): -2694.5083 kPa
Temp (*C): 22.6 *C
Pressure (kPa): -2694.5083 kPa
Temp (*C): -12035.9 *C
Pressure (kPa): -2697.3217 kPa
Temp (*C): -12036.1 *C
Pressure (kPa): -2697.3217 kPa
Temp (*C): -12036.1 *C
Pressure (kPa): -2700.0920 kPa
Temp (*C): -12036.1 *C
Pressure (kPa): -2697.4084 kPa
Temp (*C): -12036.5 *C
Pressure (kPa): -2700.1787 kPa
Temp (*C): -12036.7 *C
Pressure (kPa): -2697.4084 kPa
Temp (*C): -12036.5 *C

I ordered 2 of these and get the same results with each.

Thanks for your help

kellyf
 
Posts: 2
Joined: Sat Sep 29, 2012 10:59 am

Re: MPL115A2 Pressure and Temp Breakout - bad readings below 22*C

by adafruit_support_bill on Sun Oct 07, 2012 7:37 am

Hmmm. :? In the library, near the end of Adafruit_MPL115A2.cpp, there is the following section of code:

Code: Select all | TOGGLE FULL SIZE
  pressure = ((i2cread() << 8) | i2cread()) >> 6;
  temp = ((i2cread() << 8) | i2cread()) >> 6;
  //Serial.print("t = "); Serial.println(temp, HEX);
  float centigrade = temp;
  centigrade -= 498;
  centigrade /= -5.35;
  centigrade += 25;


Un-comment the "Serial.print" line. Run your test again and post the output.

adafruit_support_bill
 
Posts: 61701
Joined: Sat Feb 07, 2009 10:11 am

Re: MPL115A2 Pressure and Temp Breakout - bad readings below 22*C

by adafruit_support_rick on Sun Oct 07, 2012 7:07 pm

There's something about the library I don't quite understand, but I don't have one these sensors here to test with.

If you would, go into the library, and in function readCoefficients, comment out the following lines
Code: Select all | TOGGLE FULL SIZE
  _mpl115a2_c12 = (float)c12coeff;
  _mpl115a2_c12 /= 4194304.0;

and replace them with an assignment of 0 to _mpl115a2_c12:
Code: Select all | TOGGLE FULL SIZE
//  _mpl115a2_c12 = (float)c12coeff;
//  _mpl115a2_c12 /= 4194304.0;
  _mpl115a2_c12 = 0.0;


Run that and see if your anomalous behavior goes away.

adafruit_support_rick
 
Posts: 34604
Joined: Tue Mar 15, 2011 11:42 am
Location: Buffalo, NY

Re: MPL115A2 Pressure and Temp Breakout - bad readings below 22*C

by rberni on Tue Oct 23, 2012 10:06 pm

Having the exact same problem, did as suggested with no change. Any other ideas?

rberni
 
Posts: 1
Joined: Tue Oct 23, 2012 10:05 pm

Re: MPL115A2 Pressure and Temp Breakout - bad readings below 22*C

by adafruit_support_rick on Wed Oct 24, 2012 10:14 pm

Can you try uncommenting the debug output as adafruit_support suggested above?

adafruit_support_rick
 
Posts: 34604
Joined: Tue Mar 15, 2011 11:42 am
Location: Buffalo, NY

Re: MPL115A2 Pressure and Temp Breakout - bad readings below 22*C

by sellensr on Tue Nov 06, 2012 10:30 pm

I have the same problem and uncommented the line. It looks like temp is wrapping to a negative value (FE00). The bit shifting seems to be failing as a translation. Casting the result to a longer data type (e.g. long or unsigned or uint16_t) before the left shift makes room for things to work out. You need to change these two lines in both the pressure and temperature functions in the library from

pressure = ((i2cread() << 8) | i2cread()) >> 6;
temp = ((i2cread() << 8) | i2cread()) >> 6;

to

pressure = (((uint16_t)i2cread() << 8) | i2cread()) >> 6;
temp = (((uint16_t)i2cread() << 8) | i2cread()) >> 6;

I trust somebody from adafruit is watching and the mod will find its way into the posted library.

I may have just learned how to fork a github repository and make an update at https://github.com/sellensr/Adafruit_MPL115A2. At least I hope I didn't break anything ;-)

Old Output:

t = 1FF
Temp (*C): 22.6 *C
Pressure (kPa): 101.4271 kPa
t = 1FE
Temp (*C): 22.8 *C
Pressure (kPa): 101.4271 kPa
t = 1FE
Temp (*C): 22.8 *C
Pressure (kPa): 101.2062 kPa
t = 1FF
Temp (*C): 22.6 *C
Pressure (kPa): 101.3800 kPa
t = FE00
Temp (*C): -12035.9 *C
Pressure (kPa): 101.3166 kPa
t = 1FF
Temp (*C): 22.6 *C
Pressure (kPa): -2930.0664 kPa
t = 1FE
Temp (*C): 22.8 *C
Pressure (kPa): 101.2062 kPa
t = 1FE
Temp (*C): 22.8 *C
Pressure (kPa): 101.1592 kPa
t = FE00
Temp (*C): -12035.9 *C
Pressure (kPa): 101.4271 kPa
t = 1FF
Temp (*C): 22.6 *C
Pressure (kPa): 101.3166 kPa
t = 1FE
Temp (*C): 22.8 *C
Pressure (kPa): 101.2062 kPa
t = 1FF
Temp (*C): 22.6 *C
Pressure (kPa): 101.2696 kPa
t = 1FF
Temp (*C): 22.6 *C
Pressure (kPa): 101.1592 kPa
t = 1FE
Temp (*C): 22.8 *C
Pressure (kPa): -2927.3835 kPa
t = 1FF
Temp (*C): 22.6 *C
Pressure (kPa): 101.2062 kPa
t = 1FF
Temp (*C): 22.6 *C
Pressure (kPa): 101.3800 kPa
t = 1FE
Temp (*C): 22.8 *C
Pressure (kPa): -2930.0664 kPa
t = FE00
Temp (*C): -12035.9 *C
Pressure (kPa): -2930.0664 kPa

sellensr
 
Posts: 38
Joined: Tue Nov 06, 2012 9:41 pm

Re: MPL115A2 Pressure and Temp Breakout - bad readings below 22*C

by adafruit_support_bill on Wed Nov 07, 2012 7:19 am

If you post your fix as an issue to Github it will get onto our To-Do list. :D

adafruit_support_bill
 
Posts: 61701
Joined: Sat Feb 07, 2009 10:11 am

Re: MPL115A2 Pressure and Temp Breakout - bad readings below 22*C

by sellensr on Wed Nov 07, 2012 6:16 pm

I posted it to Github, along with another fix to retrieve both T and P on the same call. It shows up on the repository as an issue and a pull request. Let me know if I got the process right, as this is my first try uploading to Github.

sellensr
 
Posts: 38
Joined: Tue Nov 06, 2012 9:41 pm

Re: MPL115A2 Pressure and Temp Breakout - bad readings below 22*C

by adafruit_support_bill on Thu Nov 08, 2012 6:55 am

Thanks. It's in the system now, so it won't fall off our radar. :)

adafruit_support_bill
 
Posts: 61701
Joined: Sat Feb 07, 2009 10:11 am

Please be positive and constructive with your questions and comments.