Sparkfun MPL3115A2 only reading -999

Hi,
I am trying to use the Sparkfun MPL3115A2 as an altimeter for a model rocket.(Arduino Uno) I have connected it, installed libraries and used code according to this: https://github.com/sparkfun/SparkFun_MPL3115A2_Breakout_Arduino_Library

#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 temperature = myPressure.readTemp();
  Serial.print(" Temp(c):");
  Serial.print(temperature, 2);

  Serial.println();
  delay(200);
}

As soon as I run the code, I end up getting only -999 readings (see picture)

Does anyone know what to do?
Thanks in advance

According to library, returning -999 caused by IIC connection error.
Could you show your schematic?

The example schematic is introduced by MPL3115A2 Pressure Sensor Hookup Guide - learn.sparkfun.com.
In this schematic, logic level converter is required.
SDA and SDL of Arduino Uno are A4 and A5 according to Wire - Arduino Reference.

I hope this helps you.

Hi, thanks for responding.
I cant take a picture but I have:
3.3V to Vcc
Gnd to Gnd
A4 to SDA
A5 to SCL
(Arduino Uno to MPL3115A2)

Please use logic level converter.
Arduino Uno operate 5V.
So 5V will be applied to MPL3115A2 from SDA and SDL in your condition.
Many electronic components are sensitive and will break down if a voltage higher than the operating voltage is applied.

Something like this?

Btw: I have tried using 5V before did this break the component? On some tutorials it said to use 5V?

Thanks

Sorry. The datasheet shows how to use A4 and A5 without a logic level convertor. But 330 ohm resiters required.
If you connect SDA and ADL to A4 and A5 directly, the sensor will be damaged.
https://learn.sparkfun.com/tutorials/mpl3115a2-pressure-sensor- (digikey.com)

Ok. Thanks.
Ill get back to you on when Im in school and try it out. Thanks

Hi, I have tried it out and it doesn't work which, I think, is either due to the sensor being damaged or as it says on the File you sent:
"-999 indicates that I2C timed out (512ms max). Check your
connections."
Could it just be a connection error or is the connection error due to the board being damaged?
Thanks for your help so far :grinning:

Hi, @nick_hoenemann .

If you were connecting 5V directly it would be damaged.
I suggest you buy the sensor again and test it.

1 Like

Thanks for the continuous help.
I've ordered it and will get back to you with any progress. Thanks!

Hi @hijiy .
Within a few minutes after using the MPL3115a2 on 3.3v successfully, it went back to -999 readings. I had tinkered around a bit and checked the connection using the I2C bus scanner. In the beginning, it said not connection found but after I soldered the pins and used 1k ohm resistors, it is not saying it is not connecting. Is this progress and what else can I do? Thanks again

In addition to this, while the new MPL3115A2 was working, I connected the old one and it worked too. This seems very weird to me.

SOLUTION:
An UNO (or any other board) does not output a (5V) signal. I2c works in tri-state connections. To send a 0-bit, it will pull the SCL or SDA line to GND, to send a 1-bit it will leave the line floating. Hence you always need pullup resistors to bring the line high. I have checked the schematics and these pull-up resistors (1k) are already on the MPL3115A2 board and connect the VCC ( 3v3).

Try to connect the board GND- GND, VCC -3V3, SCL to SCL, SDA to SDA ( NO resistors needed).

Thanks to paulvha from the Sparkfun Forum for helping!

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.