MPL3115A2 low pressure reading problem

Hello everyone,
I am using a MPL3115A2 and I am using a slightly changed code of the Adafruit library for measurements. While I am getting sensible temperature readings (±1*C), relatively acceptable altitude measurements (±10m) I am getting 400 pascals instead of around 100k. I do not think there is a problem with the wiring or the pressure readings because altitude is derived from the pressure readings. However, somehow it shows 400ish values all the time. In order to fix this, I created a while loop. The loop forces to retake pressure values if the result is below 1k. Then, I’ve seen that there is only one correct measurement and that is exactly the first reading, which hits 100000kish values for only once and then goes back to 400s. How can I fix this? Is it a hardware error? Should I put more resistors? Does anyone have a picture of wiring which actually works? Did anyone else encounter such issue? If so, how did you solve your problem?
Any and all help is appreciated.
Friends from far away lands in this community hear my calls for help :slight_smile:

Would be great if we could guess what these alterations are but the community crystal ball :crystal_ball: is for repair :wink:

Also when refering to a 3rd party library posting a link might be a good idea.


Thank you for your support but I am only calling functions from the Adafruit library, other changes are concerning printing information and for LED’s. The library that I am talking about is: Adafruit Library .
I am using more or less the example in this library. I changed delays into counts so that photon could do its work rather than just waiting and I added functions for LEDs which should not be a problem. My code has some Turkish in it but I can still share it if it won’t create any further confusions. I hope your crystal ball gets better soon :slight_smile:

Are you using a breakout board for the sensor, or have you built your own circtuit?
You could try to add some debug print statements to the library implementation of float Adafruit_MPL3115A2::getPressure() to see where the wrong readongs may come from.

I have no such sensor, so I can’t help direct, but maybe @wgbartley who ported the librarry may be able to help.

1 Like

Hello, I changed everything Turkish into English, and here is my full code:

#include <Adafruit_MPL3115A2.h>
#include <adafruit-sht31.h>
#include "math.h"
#include <Ubidots.h>
#ifndef TOKEN
#define TOKEN "A1E-HOcQOOSZS1EEb4uFNYoiJ7sQRrAm2g"  // Put here your Ubidots TOKEN
Ubidots ubidots(TOKEN);
Adafruit_MPL3115A2 baro = Adafruit_MPL3115A2();
Adafruit_SHT31 sht31 = Adafruit_SHT31();
int count=0;

void setup() {
  Particle.publish("Adafruit_MPL3115A2 test!");
  while(! baro.begin()) {
    Serial.println("Couldnt find sensor");
  Serial.println("SHT31 test");
    if (! sht31.begin(0x44)) {   // Set to 0x45 for alternate i2c addr
        Particle.publish("Couldn't find SHT31");

void loop() {
  float pascals = baro.getPressure();
  float altm = baro.getAltitude();
  float tempC = baro.getTemperature();
  float t = sht31.readTemperature();
  float h = sht31.readHumidity();
  float tF = (t* 9) /5 + 32;
      //alter this number to change the amount of time between each reading
      if(count == 5)//prints roughly every 10 seconds for every 5 counts
         ubidots.add("Pressure (Inches)",pascals);  // Change for your variable name
         ubidots.add("Altitude(m)", altm);
         ubidots.add("Temperature(*C)", tempC);
         ubidots.add("Humidity (%)",h);
         bool bufferSent = false;
         if(ubidots.isDirty()){  // There are stored values in buffer
            bufferSent = ubidots.sendAll();
        count = 0;

I am also trying to add 4 LED’s to this code which could be controlled from Ubidots. Do you have any idea how I can do that?

The SCL goes to D1 and SDA goes to D0. I have two resistors of 220 Ohms on INT1 and INT2.

For the LED’s I found this link: Ubidots Switch POST format
However, I could not make it work :confused:

@aguspg do you have any idea on how to tackle this? Anything would help…