MPL115A2 Library

Has the MPL115A2 Arduino library ( ) already been ported to Particle (Core)?

Or can I use the MPL3115A2 library? I guess not because the code looks a bit different.

Well I have given it a go and tried to upgrade the library for Particle ( ). I’m not able to test this at the moment, but will this weekend. Lets hope it works :wink:

Have you had a look if the MPL3115A2 library is compatible with your sensor?

It’s also available on Particle Build

But a quick browse through your repo seemed OK.
Just out of curiosity, why have you decided to change the static functions into non-static? Did the Particle Wire class not play well with static?

One thing you might want to consider for future ports is, that you could keep the original Arduino functionality and just add the Particle specifics by use of conditional compiling (#ifdef .. #endif).


#if defined(SPARK)
 #include "application.h"
 #if ARDUINO >= 100		
  #include "Arduino.h"		
  #include "WProgram.h"		
 #include <Wire.h>
static uint8_t i2cread(void) {		
  uint8_t x;		
  #if (ARDUINO >= 100) || defined(SPARK)		
  x =;		
  x = Wire.receive();		
  //Serial.print("0x"); Serial.println(x, HEX);		
  return x;		

Hi Jacealot,

Did you have success with the Adafruit MPL115A2? I’m trying to get it running with the Photon but haven’t been successful. Would love to hear and learn from your experience.

Thank you! Todd