I recently bought the MPL115A2 sensor (https://www.adafruit.com/products/992) and am having several problems.
First of all the product page states "simply connect the VIN pin to the 5V voltage pin, GND to ground, SCL to I2C Clock (Analog 5 on an UNO) and SDA to I2C Data (Analog 4 on an UNO)". If I connect the VIN to the 5V pin I am connecting the arduino to itself and the sensor will receive no power. I am guessing that this is typo and that VIN must refer to either SDWN, RST, or VDD on the sensor but I do not know which.
The second problem is that none of the example code will run with the arduino software. Both example codes get_pt and get_pressure generate the error 'Adafruit_MPL115A2' does not name a type.
I am not trying to do anything complicated with this sensor, i would just like it to display pressure and temperature readings in the serial viewer, and maybe eventually once a certain pressure or temperature is reached to trigger a separate piece of code.
MPL115A2 pressure temperature sensor
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- adafruit_support_bill
- Posts: 88093
- Joined: Sat Feb 07, 2009 10:11 am
Re: MPL115A2 pressure temperature sensor
Yes, that is a typo I'll make sure it is fixed. What it should say is: connect the VDD pin on the module to the +5v pin on the Arduino.
And that it is installed in the correct location: http://www.ladyada.net/library/arduino/libraries.html
Finally, you must close all instances of the Arduino IDE, then re-open it before it will recognize the newly installed library.
This is usually because the library was not found. Make sure you have the latest version of the library: https://github.com/adafruit/Adafruit_MPL115A2'Adafruit_MPL115A2' does not name a type.
And that it is installed in the correct location: http://www.ladyada.net/library/arduino/libraries.html
Finally, you must close all instances of the Arduino IDE, then re-open it before it will recognize the newly installed library.
-
- Posts: 13
- Joined: Tue Nov 20, 2012 10:08 am
Re: MPL115A2 pressure temperature sensor
Thank you for your quick response, I got it working immediately after I read you answer.
I have a second question though. I am trying to modifiy the "IfStatementConditional" example code to work with this sensor, but I am having trouble finding the place in the "Adafruit_MPL115A2" or "GetPressure" codes in which the analog reading is converted into pressure and temperature.
I have a second question though. I am trying to modifiy the "IfStatementConditional" example code to work with this sensor, but I am having trouble finding the place in the "Adafruit_MPL115A2" or "GetPressure" codes in which the analog reading is converted into pressure and temperature.
- adafruit_support_bill
- Posts: 88093
- Joined: Sat Feb 07, 2009 10:11 am
Re: MPL115A2 pressure temperature sensor
It is here in Adafruit_MPL115A2.cpp. The pressure compensation calculation is described in the data sheet.
Code: Select all
void Adafruit_MPL115A2::getPT(float *P, float *T) {
uint16_t pressure, temp;
float pressureComp;
// Get raw pressure and temperature settings
Wire.beginTransmission(MPL115A2_ADDRESS);
i2cwrite((uint8_t)MPL115A2_REGISTER_STARTCONVERSION);
i2cwrite((uint8_t)0x00);
Wire.endTransmission();
// Wait a bit for the conversion to complete (3ms max)
delay(5);
Wire.beginTransmission(MPL115A2_ADDRESS);
i2cwrite((uint8_t)MPL115A2_REGISTER_PRESSURE_MSB); // Register
Wire.endTransmission();
Wire.requestFrom(MPL115A2_ADDRESS, 4);
pressure = (( (uint16_t) i2cread() << 8) | i2cread()) >> 6;
temp = (( (uint16_t) i2cread() << 8) | i2cread()) >> 6;
// See datasheet p.6 for evaluation sequence
pressureComp = _mpl115a2_a0 + (_mpl115a2_b1 + _mpl115a2_c12 * temp ) * pressure + _mpl115a2_b2 * temp;
// Return pressure and temperature as floating point values
*P = ((65.0F / 1023.0F) * pressureComp) + 50.0F; // kPa
*T = ((float) temp - 498.0F) / -5.35F +25.0F; // C
}
-
- Posts: 13
- Joined: Tue Nov 20, 2012 10:08 am
Re: MPL115A2 pressure temperature sensor
Thank you!
-
- Posts: 1
- Joined: Fri Jan 25, 2013 5:48 pm
Re: MPL115A2 pressure temperature sensor
Where did the equation for the temperature come from? The documentation only discusses the pressure calculation.
- adafruit_support_rick
- Posts: 35092
- Joined: Tue Mar 15, 2011 11:42 am
Re: MPL115A2 pressure temperature sensor
I don't know. Doesn't quite look right, assuming that 0..1023 represents the operational temperature range of 105C..-40C. The datasheet doesn't seem to say anything definite about it. Perhaps it was empirically derived.
Again, if 0..1023 linearly represents 105C..-40C, then I'd expect the calculation to be
(((float)Tadc - 512.0) / -7.062) + 32.5
I don't have one here, so I can't do a reality check on that.
Again, if 0..1023 linearly represents 105C..-40C, then I'd expect the calculation to be
(((float)Tadc - 512.0) / -7.062) + 32.5
I don't have one here, so I can't do a reality check on that.
- park
- Posts: 13
- Joined: Wed Dec 28, 2011 4:12 pm
Re: MPL115A2 pressure temperature sensor
I know this thread is a little old, but I ran across it because, for our sensor, the MPL115A2 is reporting temperatures that are about 3C too low. I assumed this might be due to the argument in the previous poster's equation. I used the stored data set my son took, reversed the calculation to get the equivalent of tadc, and then tried the suggested equation. As you can see in the graph below, neither the direct reading (labeled MPL) nor the converted reading (MPL2) are correct.
Any chance the Adafruit author of the MPL code is around to consult for temperature?
My R code, which converts the reading from what the Adafruit library produces back to the measurement, and then to proposed measurement is:
Any chance the Adafruit author of the MPL code is around to consult for temperature?
My R code, which converts the reading from what the Adafruit library produces back to the measurement, and then to proposed measurement is:
Code: Select all
tadc = (d$tempmpl_C - 25)*(-5.35) + 498
d$tempmpl_C2 = ((tadc - 512.0) / -7.062) + 32.5
-
- Posts: 12151
- Joined: Thu Apr 06, 2006 4:21 pm
Re: MPL115A2 pressure temperature sensor
Hi, the temperature code was grabbed from a few app notes and a little experimentation - its not actually something that is documented officially, that's why we have the following note in the product page
"There's a basic temperature sensor inside but there's no specifications in the datasheet so we're not sure how accurate it is. "
We don't think its calibrated from one sensor to another, so each sensor must have its own slightly different equasion (?)
"There's a basic temperature sensor inside but there's no specifications in the datasheet so we're not sure how accurate it is. "
We don't think its calibrated from one sensor to another, so each sensor must have its own slightly different equasion (?)
- park
- Posts: 13
- Joined: Wed Dec 28, 2011 4:12 pm
Re: MPL115A2 pressure temperature sensor
Well, here's what I can offer for our particular sensor. Maybe a few other people can gather similar data. Our data is not over a very large range, but it looks like the conversion is linear.
I fitted the thermistor temperature to the back-calculated "tadc" value, and produced a linear model for temperature (Fahrenheit) as a function of the tadc value. You all probably have a better way to handle these numbers without precision loss; I just did this floating point.
T_F = -0.307 * tadc + 234.1
or, in Celsius,
T_C = -0.1706 + 112.27
The results are consistent over our data range, as shown below.
Nice little sensor, by the way. Very cute.
I fitted the thermistor temperature to the back-calculated "tadc" value, and produced a linear model for temperature (Fahrenheit) as a function of the tadc value. You all probably have a better way to handle these numbers without precision loss; I just did this floating point.
T_F = -0.307 * tadc + 234.1
or, in Celsius,
T_C = -0.1706 + 112.27
The results are consistent over our data range, as shown below.
Nice little sensor, by the way. Very cute.
- park
- Posts: 13
- Joined: Wed Dec 28, 2011 4:12 pm
Re: MPL115A2 pressure temperature sensor
Woops, I meant to mention that the adjusted R-squared is 0.974, and I suspect would be better without the wide thermistor excursions at the beginning of the data series. Here's my R transcript, for any statisticians who also happen to be Arduino fans looking to squeeze more juice out of an MPL115A2...
Call:
lm(formula = thrmist_F ~ tadc, data = d)
Residuals:
Min 1Q Median 3Q Max
-1.3587 -0.3028 -0.0789 0.1966 9.2625
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 2.341e+02 2.981e-01 785.3 <2e-16 ***
tadc -3.070e-01 5.398e-04 -568.8 <2e-16 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 0.5024 on 8616 degrees of freedom
Multiple R-squared: 0.9741, Adjusted R-squared: 0.9741
F-statistic: 3.235e+05 on 1 and 8616 DF, p-value: < 2.2e-16
Cheers!
Call:
lm(formula = thrmist_F ~ tadc, data = d)
Residuals:
Min 1Q Median 3Q Max
-1.3587 -0.3028 -0.0789 0.1966 9.2625
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 2.341e+02 2.981e-01 785.3 <2e-16 ***
tadc -3.070e-01 5.398e-04 -568.8 <2e-16 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Residual standard error: 0.5024 on 8616 degrees of freedom
Multiple R-squared: 0.9741, Adjusted R-squared: 0.9741
F-statistic: 3.235e+05 on 1 and 8616 DF, p-value: < 2.2e-16
Cheers!
- rohanaby79
- Posts: 22
- Joined: Wed Jun 29, 2016 4:17 pm
Re: MPL115A2 pressure temperature sensor
I have a question on the same sensor. I am trying to use multiple sensors of the same MPL115A2. I want to use the I2C protocol to communicate with these sensors. However, I am confused if the slave addresses of these sensors can be changed.
- adafruit_support_bill
- Posts: 88093
- Joined: Sat Feb 07, 2009 10:11 am
Re: MPL115A2 pressure temperature sensor
The address is fixed at 0x60, but you can use a multiplexer like this one to control multiple sensors: https://www.adafruit.com/products/2717
- rohanaby79
- Posts: 22
- Joined: Wed Jun 29, 2016 4:17 pm
Re: MPL115A2 pressure temperature sensor
Is there multiplexer that can do upto 20 sensors?
- adafruit_support_mike
- Posts: 67446
- Joined: Thu Feb 11, 2010 2:51 pm
Re: MPL115A2 pressure temperature sensor
Not that we know about. If it does exist, it will be a pretty big chip.. probably at least a 48-pin package.
Please be positive and constructive with your questions and comments.