0

MPL3115A2 Altimeter Not Stable
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

MPL3115A2 Altimeter Not Stable

by cavu on Sat Dec 16, 2017 2:46 pm

For a day or two, the module works perfectly--accurate and stable. Then it starts to return altitude of 214975.18 feet (adjusted from meters). The temperature and BARO continue to be correct. The program I wrote is relatively simple and returns to an LCD but i get the same readings from the serial monitor. When I load Adafruit example sketch (output to serial only) it also reads correct temp, baro but meters is 65523.94 (same as ft. adjusted above). Disconnected for a few days and reboot, all is good again....for a few days.
Suggestions?

cavu
 
Posts: 23
Joined: Mon Jan 02, 2012 10:24 pm

Re: MPL3115A2 Altimeter Not Stable

by adafruit_support_bill on Sat Dec 16, 2017 3:20 pm

... but meters is 65523.94 (same as ft. adjusted above). ...

Sounds like an integer overflow condition. Probably a signed integer that should be unsigned. Please post the code you are using.

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

Re: MPL3115A2 Altimeter Not Stable

by cavu on Sat Dec 16, 2017 4:01 pm

Since the exact same thing happens with the example code supplied by Adafruit, do you still that is the case.
below is the sample code from Ada.

Code: Select all | TOGGLE FULL SIZE
/**************************************************************************/
/*!
    @file     Adafruit_MPL3115A2.cpp
    @author   K.Townsend (Adafruit Industries)
    @license  BSD (see license.txt)

    Example for the MPL3115A2 barometric pressure sensor

    This is a library for the Adafruit MPL3115A2 breakout
    ----> https://www.adafruit.com/products/1893

    Adafruit invests time and resources providing this open source code,
    please support Adafruit and open-source hardware by purchasing
    products from Adafruit!

    @section  HISTORY

    v1.0 - First release
*/
/**************************************************************************/

#include <Wire.h>
#include <Adafruit_MPL3115A2.h>

// Power by connecting Vin to 3-5V, GND to GND
// Uses I2C - connect SCL to the SCL pin, SDA to SDA pin
// See the Wire tutorial for pinouts for each Arduino
// http://arduino.cc/en/reference/wire
Adafruit_MPL3115A2 baro = Adafruit_MPL3115A2();

void setup() {
  Serial.begin(9600);
  Serial.println("Adafruit_MPL3115A2 test!");
}

void loop() {
  if (! baro.begin()) {
    Serial.println("Couldnt find sensor");
    return;
  }
 
  float pascals = baro.getPressure();
  // Our weather page presents pressure in Inches (Hg)
  // Use http://www.onlineconversion.com/pressure.htm for other units
  Serial.print(pascals/3377); Serial.println(" Inches (Hg)");

  float altm = baro.getAltitude();
  Serial.print(altm); Serial.println(" meters");

  float tempC = baro.getTemperature();
  Serial.print(tempC); Serial.println("*C");

  delay(250);
}
Last edited by adafruit_support_carter on Fri Jan 12, 2018 1:00 pm, edited 1 time in total.
Reason: added [code] tags

cavu
 
Posts: 23
Joined: Mon Jan 02, 2012 10:24 pm

Re: MPL3115A2 Altimeter Not Stable

by adafruit_support_bill on Sat Dec 16, 2017 4:12 pm

Quite possibly. It looks like the device returns a signed integer and the library is handling it as unsigned. What is your actual altitude? Are you close to sea-level?

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

Re: MPL3115A2 Altimeter Not Stable

by cavu on Sat Dec 16, 2017 5:14 pm

about 400 feet is the ASL.
the module temperature corrects for altitude so it will vary between 50 and 500 ft ASL when operating properly.
this will ultimately be used for much higher altitudes.
appreciates your suggestions.

cavu
 
Posts: 23
Joined: Mon Jan 02, 2012 10:24 pm

Re: MPL3115A2 Altimeter Not Stable

by adafruit_support_bill on Sun Dec 17, 2017 6:39 am

In the getAltitude function of the library, the 'alt' variable is declared as an "int32_t". Try changing that to "uint32_t".

Code: Select all | TOGGLE FULL SIZE
float Adafruit_MPL3115A2::getAltitude() {
  int32_t alt;

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

Re: MPL3115A2 Altimeter Not Stable

by cavu on Sun Dec 17, 2017 11:03 am

Unfortunately, didn't help. Any other thoughts.

cavu
 
Posts: 23
Joined: Mon Jan 02, 2012 10:24 pm

Re: MPL3115A2 Altimeter Not Stable

by adafruit_support_bill on Mon Dec 18, 2017 7:21 am

At 400' you shouldn't be getting negative readings anyway. Let's try replacing the sensor. Please contact support@adafruit.com with a link to this thread and we can ship one out to you.

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

Re: MPL3115A2 Altimeter Not Stable

by cavu on Mon Dec 18, 2017 7:38 am

Will do. Thank you for your help.

cavu
 
Posts: 23
Joined: Mon Jan 02, 2012 10:24 pm

Re: MPL3115A2 Altimeter Not Stable

by cavu on Thu Dec 28, 2017 3:32 pm

I tried the second MPL3115A2 with the same issue. After about 9 hours of running perfectly, the altitude goes to 22,400+ and freezes but temperature and pressure readings continue normally. I'm thinking it's related to some type of buffering in the unit. I've tried it on two different Arduino Unos. Might be worth Adafruit trying the same test to see if you have the same results. I can't see from the data sheet how I can reset the MPL3115A2. One work around might be to ignore the altitude readout and do the calculation in the program. I believe the negative of that is not having the advantage of the factory set calibration for accuracy. Suggestions.

cavu
 
Posts: 23
Joined: Mon Jan 02, 2012 10:24 pm

Re: MPL3115A2 Altimeter Not Stable

by adafruit_support_bill on Fri Dec 29, 2017 7:47 am

I'll check with the author of the library.

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

Re: MPL3115A2 Altimeter Not Stable

by adafruit2 on Tue Jan 02, 2018 12:08 am

It definitely sounds like either a software, timing or loose wiring issue.
Can you try some other libraries? could help narrow down the issue

Here's one from kriswiner
https://github.com/kriswiner/MPL3115A2

Example from controleverything:
https://github.com/ControlEverythingCom ... 3115A2.ino

?

adafruit2
Site Admin
 
Posts: 16433
Joined: Fri Mar 11, 2005 7:36 pm

Re: MPL3115A2 Altimeter Not Stable

by cavu on Tue Jan 02, 2018 7:15 pm

Thank you for the suggestions. I had tried using the SparkFunMPL3115A2 library and examples and they work properly. I didn't try seeing what would happen after five hours of running. I was hoping the above library would clear everything out and allow me then to upload the MPL3115A2 program and examples for it to start working properly, unfortunately without success. It does appear to be a library problem. I've tried two different Unos, two different breakouts and get the same result. After five hours the altitude read is incorrect. I think if it was as simple as a loose wire it would not be properly providing baro, temp, etc. Did you have a chance to duplicate the above and let it run for five hours (exactly) and see if you get the same result. thank you.

cavu
 
Posts: 23
Joined: Mon Jan 02, 2012 10:24 pm

Re: MPL3115A2 Altimeter Not Stable

by adafruit2 on Tue Jan 02, 2018 7:18 pm

hiya no we haven't had a chance to set up a rig yet, we recommend trying the other libraries for 5 hours - we dont know what the issue is either - we'll try to get to making a test jig later this week :)

adafruit2
Site Admin
 
Posts: 16433
Joined: Fri Mar 11, 2005 7:36 pm

Re: MPL3115A2 Altimeter Not Stable

by cavu on Tue Jan 02, 2018 8:28 pm

Will do

cavu
 
Posts: 23
Joined: Mon Jan 02, 2012 10:24 pm

Please be positive and constructive with your questions and comments.


cron