#Include <x.h> for MPL3115A2 pressure sensor?

Hi. I am very new to arduino and I have to jump into the thick of it for a project requiring the mpl3115a2 barometric sensor. I have followed the direct instructions on the tutorial in this link:


Everything is hooked up correctly, but when I go to the provided library and run the basic SparkfunMPL3115A2 file, I get this very odd result on the serial monitor.


So I tried different codes from the internet, such as this basic one that should print pressure and altitude directly.



#include <Wire.h>
#include "MPL3115A2.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, 2);

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

  float pressure = myPressure.readPressure();
  Serial.print(pressure, 2);

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

  float temperature = myPressure.readTempF();
  Serial.print(" Temp(f):");
  Serial.print(temperature, 2);


And now, like many others I have tried it says that “MPL3115A2 does not have a name type.” I have no idea what this means because as I said, I have no idea how to use arduino programming aside from some similarities between RobotC. I’m sure there is a simple and easy way to fix this, but I don’t know what it is. Could I have some help?


When you get garbage on the Serial monitor like that, the first thing to check is that the baud rate in the code matches the baud rate on the serial monitor.