Altitude Sensor has crazy readings

I’m using an MPL3115A2 Altitude Sensor with a Sparkfun Pro Micro 5v and a basic sketch from the library. I’m getting some crazy readings: Altitude(ft): -3277.56 and Temp(F): -1766.20. Ideas for troubleshooting? What am I missing?

include <Wire.h>
#include "SparkFunMPL3115A2.h"

//Create an instance of the object
MPL3115A2 myPressure;

void setup()
{
  Wire.begin();        // Join i2c bus
  Serial.begin(9600);  // Start serial for output

  myPressure.begin(); // Get sensor online

  //Configure the sensor
  myPressure.setModeAltimeter(); // Measure altitude above sea level in meters
  //myPressure.setModeBarometer(); // Measure pressure in Pascals from 20 to 110 kPa

  myPressure.setOversampleRate(7); // Set Oversample to the recommended 128
  //myPressure.enableEventFlags(); // Enable all three pressure and temp event flags 
}

void loop()
{
  //float altitude = myPressure.readAltitude();
  //Serial.print("Altitude(m):");
  //Serial.print(altitude, 2);

  float altitude = myPressure.readAltitudeFt();
  Serial.print("Altitude(ft): ");
  Serial.print(altitude,2);

  //float pressure = myPressure.readPressure();
  //Serial.print("Pressure(Pa):");
  //Serial.print(pressure, 2);

  //float temperature = myPressure.readTemp();
  //Serial.print(" Temp(c):");
  //Serial.print(temperature, 2);

  float tempRead = myPressure.readTempF();
  Serial.print("     Temp(F): ");
  Serial.print(tempRead,2);

  Serial.println();
  delay(5000);

}

Hi eshulz,

Usually, when you see readings like that there is a connection or power issue. Can you take a few photos of the top and bottom of your MPL3115A2 Breakout and the circuit you have it in with your Pro Micro?

I’m not exactly sure what I did, but it appears to be working now. Thanks for the response!

Ah, that old magic trick with electronics. My guess is it was a loose connection somewhere that got nudged into place. If you run into this issue again, double check your connections for the power and data lines and that should fix the issue.

Let us know if you have any other issues with or questions about the MPL3115A2 and we would be happy to help.