@tkurtz, there is no “step-by-step” tutorial. I believe either @ScruffR or I can help you here but he’s a lot smarter than me :
Says the one who's about ten times the experience of me (just count the library ports - I've only got three still)
But since @peekay123 is already juggling way more balls than I even got, I can have a look
Meanwhile, have you seen this thread
Library List + Porting How To - Libraries - Particle
but most importantly the related GitHub repo
GitHub - harrisonhjones/Spark-Ported-Libraries: A small repo of ported libraries for the SparkCore along with a "how to" of porting libraries
This should at least give you some head start.
@ScruffR @peekay123, Thanks guys! I gave it a good try but I’m resulting in some ugly errors during compile. Here’s a look at my files. Errors point to various issues in the library. Would love to hear your thoughts!
The INO:
// This #include statement was automatically added by the Particle IDE.
#include "Adafruit_MPL115A2/Adafruit_MPL115A2.h"
Adafruit_MPL115A2 mpl115a2 = Adafruit_MPL115A2();
void setup(void)
{
Serial.begin(9600);
Serial.println("Hello!");
Serial.println("Getting barometric pressure ...");
mpl115a2.begin();
}
void loop(void)
{
float pressureKPA = 0, temperatureC = 0;
mpl115a2.getPT(&pressureKPA,&temperatureC);
Serial.print("Pressure (kPa): "); Serial.print(pressureKPA, 4); Serial.print(" kPa ");
Serial.print("Temp (*C): "); Serial.print(temperatureC, 1); Serial.println(" *C both measured together");
pressureKPA = mpl115a2.getPressure();
Serial.print("Pressure (kPa): "); Serial.print(pressureKPA, 4); Serial.println(" kPa");
temperatureC = mpl115a2.getTemperature();
Serial.print("Temp (*C): "); Serial.print(temperatureC, 1); Serial.println(" *C");
delay(1000);
}
The .cpp:
/**************************************************************************/
/*!
@file Adafruit_MPL115A2.cpp
@author K.Townsend (Adafruit Industries)
@license BSD (see license.txt)
Driver for the MPL115A2 barometric pressure sensor
This is a library for the Adafruit MPL115A2 breakout
----> https://www.adafruit.com/products/992
Adafruit invests time and resources providing this open source code,
please support Adafruit and open-source hardware by purchasing
products from Adafruit!
@section HISTORY
v1.0 - First release
v1.1 - Rick Sellens added casts to make bit shifts work below 22.6C
- get both P and T with a single call to getPT
*/
/**************************************************************************/
#include "Adafruit_MPL115A2.h"
/**************************************************************************/
/*!
@brief Instantiates a new MPL115A2 class
*/
/**************************************************************************/
Adafruit_MPL115A2::Adafruit_MPL115A2() {
}
/**************************************************************************/
/*!
@brief Gets the factory-set coefficients for this particular sensor
*/
/**************************************************************************/
void Adafruit_MPL115A2::readCoefficients() {
int16_t a0coeff;
int16_t b1coeff;
int16_t b2coeff;
int16_t c12coeff;
Wire.beginTransmission(MPL115A2_ADDRESS);
i2cwrite((uint8_t)MPL115A2_REGISTER_A0_COEFF_MSB);
Wire.endTransmission();
Wire.requestFrom(MPL115A2_ADDRESS, 8);
a0coeff = (( (uint16_t) i2cread() << 8) | i2cread());
b1coeff = (( (uint16_t) i2cread() << 8) | i2cread());
b2coeff = (( (uint16_t) i2cread() << 8) | i2cread());
c12coeff = (( (uint16_t) (i2cread() << 8) | i2cread())) >> 2;
/*
Serial.print("A0 = "); Serial.println(a0coeff, HEX);
Serial.print("B1 = "); Serial.println(b1coeff, HEX);
Serial.print("B2 = "); Serial.println(b2coeff, HEX);
Serial.print("C12 = "); Serial.println(c12coeff, HEX);
*/
_mpl115a2_a0 = (float)a0coeff / 8;
_mpl115a2_b1 = (float)b1coeff / 8192;
_mpl115a2_b2 = (float)b2coeff / 16384;
_mpl115a2_c12 = (float)c12coeff;
_mpl115a2_c12 /= 4194304.0;
/*
Serial.print("a0 = "); Serial.println(_mpl115a2_a0);
Serial.print("b1 = "); Serial.println(_mpl115a2_b1);
Serial.print("b2 = "); Serial.println(_mpl115a2_b2);
Serial.print("c12 = "); Serial.println(_mpl115a2_c12);
*/
}
/**************************************************************************/
/*!
@brief Instantiates a new MPL115A2 class
*/
/**************************************************************************/
Adafruit_MPL115A2::Adafruit_MPL115A2() {
_mpl115a2_a0 = 0.0F;
_mpl115a2_b1 = 0.0F;
_mpl115a2_b2 = 0.0F;
_mpl115a2_c12 = 0.0F;
}
/**************************************************************************/
/*!
@brief Setups the HW (reads coefficients values, etc.)
*/
/**************************************************************************/
void Adafruit_MPL115A2::begin() {
Wire.begin();
// Read factory coefficient values (this only needs to be done once)
readCoefficients();
}
/**************************************************************************/
/*!
@brief Gets the floating-point pressure level in kPa
*/
/**************************************************************************/
float Adafruit_MPL115A2::getPressure() {
float pressureComp,centigrade;
getPT(&pressureComp, ¢igrade);
return pressureComp;
}
/**************************************************************************/
/*!
@brief Gets the floating-point temperature in Centigrade
*/
/**************************************************************************/
float Adafruit_MPL115A2::getTemperature() {
float pressureComp, centigrade;
getPT(&pressureComp, ¢igrade);
return centigrade;
}
/**************************************************************************/
/*!
@brief Gets both at once and saves a little time
*/
/**************************************************************************/
void Adafruit_MPL115A2::getPT(float *P, float *T) {
uint16_t pressure, temp;
float pressureComp;
// Get raw pressure and temperature settings
Wire.beginTransmission(MPL115A2_ADDRESS);
i2cwrite((uint8_t)MPL115A2_REGISTER_STARTCONVERSION);
i2cwrite((uint8_t)0x00);
Wire.endTransmission();
// Wait a bit for the conversion to complete (3ms max)
delay(5);
Wire.beginTransmission(MPL115A2_ADDRESS);
i2cwrite((uint8_t)MPL115A2_REGISTER_PRESSURE_MSB); // Register
Wire.endTransmission();
Wire.requestFrom(MPL115A2_ADDRESS, 4);
pressure = (( (uint16_t) i2cread() << 8) | i2cread()) >> 6;
temp = (( (uint16_t) i2cread() << 8) | i2cread()) >> 6;
// See datasheet p.6 for evaluation sequence
pressureComp = _mpl115a2_a0 + (_mpl115a2_b1 + _mpl115a2_c12 * temp ) * pressure + _mpl115a2_b2 * temp;
// Return pressure and temperature as floating point values
*P = ((65.0F / 1023.0F) * pressureComp) + 50.0F; // kPa
*T = ((float) temp - 498.0F) / -5.35F +25.0F; // C
}
And the .h
/**************************************************************************/
/*!
@file Adafruit_MPL115A2.h
@author K. Townsend (Adafruit Industries)
@license BSD (see license.txt)
This is a library for the Adafruit MPL115A2 breakout board
----> https://www.adafruit.com/products/???
Adafruit invests time and resources providing this open source code,
please support Adafruit and open-source hardware by purchasing
products from Adafruit!
@section HISTORY
v1.0 - First release
*/
/**************************************************************************/
#include "application.h"
/*=========================================================================
I2C ADDRESS/BITS
-----------------------------------------------------------------------*/
#define MPL115A2_ADDRESS (0x60) // 1100000
/*=========================================================================*/
/*=========================================================================
REGISTERS
-----------------------------------------------------------------------*/
#define MPL115A2_REGISTER_PRESSURE_MSB (0x00)
#define MPL115A2_REGISTER_PRESSURE_LSB (0x01)
#define MPL115A2_REGISTER_TEMP_MSB (0x02)
#define MPL115A2_REGISTER_TEMP_LSB (0x03)
#define MPL115A2_REGISTER_A0_COEFF_MSB (0x04)
#define MPL115A2_REGISTER_A0_COEFF_LSB (0x05)
#define MPL115A2_REGISTER_B1_COEFF_MSB (0x06)
#define MPL115A2_REGISTER_B1_COEFF_LSB (0x07)
#define MPL115A2_REGISTER_B2_COEFF_MSB (0x08)
#define MPL115A2_REGISTER_B2_COEFF_LSB (0x09)
#define MPL115A2_REGISTER_C12_COEFF_MSB (0x0A)
#define MPL115A2_REGISTER_C12_COEFF_LSB (0x0B)
#define MPL115A2_REGISTER_STARTCONVERSION (0x12)
/*=========================================================================*/
class Adafruit_MPL115A2{
public:
Adafruit_MPL115A2();
boolean begin(void);
float getPressure(void);
float getTemperature(void);
float getPT(float *P, float *T);
void write8(uint8_t a, uint8_t d);
private:
float _mpl115a2_a0;
float _mpl115a2_b1;
float _mpl115a2_b2;
float _mpl115a2_c12;
void readCoefficients(void);
uint8_t read8(uint8_t a);
uint8_t mode;
};
@tkurtz, you kinda deleted too much and changed some function prototypes between the .h and .cpp files, giving you the errors. Here are the corrected library files:
Adafruit_MPL115A2.cpp - note I added back the i2cread() and i2cwrite() functions
/**************************************************************************/
/*!
@file Adafruit_MPL115A2.cpp
@author K.Townsend (Adafruit Industries)
@license BSD (see license.txt)
Driver for the MPL115A2 barometric pressure sensor
This is a library for the Adafruit MPL115A2 breakout
----> https://www.adafruit.com/products/992
Adafruit invests time and resources providing this open source code,
please support Adafruit and open-source hardware by purchasing
products from Adafruit!
@section HISTORY
v1.0 - First release
v1.1 - Rick Sellens added casts to make bit shifts work below 22.6C
- get both P and T with a single call to getPT
*/
/**************************************************************************/
#include "Adafruit_MPL115A2.h"
/**************************************************************************/
/*!
@brief Instantiates a new MPL115A2 class
*/
/**************************************************************************/
static uint8_t i2cread(void) {
uint8_t x;
x = Wire.read();
//Serial.print("0x"); Serial.println(x, HEX);
return x;
}
static void i2cwrite(uint8_t x) {
Wire.write((uint8_t)x);
}
/**************************************************************************/
/*!
@brief Gets the factory-set coefficients for this particular sensor
*/
/**************************************************************************/
void Adafruit_MPL115A2::readCoefficients() {
int16_t a0coeff;
int16_t b1coeff;
int16_t b2coeff;
int16_t c12coeff;
Wire.beginTransmission(MPL115A2_ADDRESS);
i2cwrite((uint8_t)MPL115A2_REGISTER_A0_COEFF_MSB);
Wire.endTransmission();
Wire.requestFrom(MPL115A2_ADDRESS, 8);
a0coeff = (( (uint16_t) i2cread() << 8) | i2cread());
b1coeff = (( (uint16_t) i2cread() << 8) | i2cread());
b2coeff = (( (uint16_t) i2cread() << 8) | i2cread());
c12coeff = (( (uint16_t) (i2cread() << 8) | i2cread())) >> 2;
/*
Serial.print("A0 = "); Serial.println(a0coeff, HEX);
Serial.print("B1 = "); Serial.println(b1coeff, HEX);
Serial.print("B2 = "); Serial.println(b2coeff, HEX);
Serial.print("C12 = "); Serial.println(c12coeff, HEX);
*/
_mpl115a2_a0 = (float)a0coeff / 8;
_mpl115a2_b1 = (float)b1coeff / 8192;
_mpl115a2_b2 = (float)b2coeff / 16384;
_mpl115a2_c12 = (float)c12coeff;
_mpl115a2_c12 /= 4194304.0;
/*
Serial.print("a0 = "); Serial.println(_mpl115a2_a0);
Serial.print("b1 = "); Serial.println(_mpl115a2_b1);
Serial.print("b2 = "); Serial.println(_mpl115a2_b2);
Serial.print("c12 = "); Serial.println(_mpl115a2_c12);
*/
}
/**************************************************************************/
/*!
@brief Instantiates a new MPL115A2 class
*/
/**************************************************************************/
Adafruit_MPL115A2::Adafruit_MPL115A2() {
_mpl115a2_a0 = 0.0F;
_mpl115a2_b1 = 0.0F;
_mpl115a2_b2 = 0.0F;
_mpl115a2_c12 = 0.0F;
}
/**************************************************************************/
/*!
@brief Setups the HW (reads coefficients values, etc.)
*/
/**************************************************************************/
void Adafruit_MPL115A2::begin() {
Wire.begin();
// Read factory coefficient values (this only needs to be done once)
readCoefficients();
}
/**************************************************************************/
/*!
@brief Gets the floating-point pressure level in kPa
*/
/**************************************************************************/
float Adafruit_MPL115A2::getPressure() {
float pressureComp,centigrade;
getPT(&pressureComp, ¢igrade);
return pressureComp;
}
/**************************************************************************/
/*!
@brief Gets the floating-point temperature in Centigrade
*/
/**************************************************************************/
float Adafruit_MPL115A2::getTemperature() {
float pressureComp, centigrade;
getPT(&pressureComp, ¢igrade);
return centigrade;
}
/**************************************************************************/
/*!
@brief Gets both at once and saves a little time
*/
/**************************************************************************/
void Adafruit_MPL115A2::getPT(float *P, float *T) {
uint16_t pressure, temp;
float pressureComp;
// Get raw pressure and temperature settings
Wire.beginTransmission(MPL115A2_ADDRESS);
i2cwrite((uint8_t)MPL115A2_REGISTER_STARTCONVERSION);
i2cwrite((uint8_t)0x00);
Wire.endTransmission();
// Wait a bit for the conversion to complete (3ms max)
delay(5);
Wire.beginTransmission(MPL115A2_ADDRESS);
i2cwrite((uint8_t)MPL115A2_REGISTER_PRESSURE_MSB); // Register
Wire.endTransmission();
Wire.requestFrom(MPL115A2_ADDRESS, 4);
pressure = (( (uint16_t) i2cread() << 8) | i2cread()) >> 6;
temp = (( (uint16_t) i2cread() << 8) | i2cread()) >> 6;
// See datasheet p.6 for evaluation sequence
pressureComp = _mpl115a2_a0 + (_mpl115a2_b1 + _mpl115a2_c12 * temp ) * pressure + _mpl115a2_b2 * temp;
// Return pressure and temperature as floating point values
*P = ((65.0F / 1023.0F) * pressureComp) + 50.0F; // kPa
*T = ((float) temp - 498.0F) / -5.35F +25.0F; // C
}
Adafruit_MPL115A2.h - note the changes to the function prototypes to match those in the .cpp file and the original library.
/**************************************************************************/
/*!
@file Adafruit_MPL115A2.h
@author K. Townsend (Adafruit Industries)
@license BSD (see license.txt)
This is a library for the Adafruit MPL115A2 breakout board
----> https://www.adafruit.com/products/???
Adafruit invests time and resources providing this open source code,
please support Adafruit and open-source hardware by purchasing
products from Adafruit!
@section HISTORY
v1.0 - First release
*/
/**************************************************************************/
#include "application.h"
/*=========================================================================
I2C ADDRESS/BITS
-----------------------------------------------------------------------*/
#define MPL115A2_ADDRESS (0x60) // 1100000
/*=========================================================================*/
/*=========================================================================
REGISTERS
-----------------------------------------------------------------------*/
#define MPL115A2_REGISTER_PRESSURE_MSB (0x00)
#define MPL115A2_REGISTER_PRESSURE_LSB (0x01)
#define MPL115A2_REGISTER_TEMP_MSB (0x02)
#define MPL115A2_REGISTER_TEMP_LSB (0x03)
#define MPL115A2_REGISTER_A0_COEFF_MSB (0x04)
#define MPL115A2_REGISTER_A0_COEFF_LSB (0x05)
#define MPL115A2_REGISTER_B1_COEFF_MSB (0x06)
#define MPL115A2_REGISTER_B1_COEFF_LSB (0x07)
#define MPL115A2_REGISTER_B2_COEFF_MSB (0x08)
#define MPL115A2_REGISTER_B2_COEFF_LSB (0x09)
#define MPL115A2_REGISTER_C12_COEFF_MSB (0x0A)
#define MPL115A2_REGISTER_C12_COEFF_LSB (0x0B)
#define MPL115A2_REGISTER_STARTCONVERSION (0x12)
/*=========================================================================*/
class Adafruit_MPL115A2{
public:
Adafruit_MPL115A2();
void begin(void);
float getPressure(void);
float getTemperature(void);
void getPT(float *P, float *T);
void write8(uint8_t a, uint8_t d);
private:
float _mpl115a2_a0;
float _mpl115a2_b1;
float _mpl115a2_b2;
float _mpl115a2_c12;
void readCoefficients(void);
uint8_t read8(uint8_t a);
uint8_t mode;
};
@peekay123, Thank you so much for reviewing and fixing her up. This must be darn close because I’m only getting this error now. Thanks again for all your help.
mpl115a2new.cpp:4:47: error: expected primary-expression before ‘;’ token
void loop(void);
Here’s my current INO:
// This #include statement was automatically added by the Particle IDE.
#include "Adafruit_MPL115A2/Adafruit_MPL115A2.h"
Adafruit_MPL115A2 mpl115a2 = Adafruit_MPL115A2;
void setup(void)
{
Serial.begin(9600);
Serial.println("Hello!");
Serial.println("Getting barometric pressure ...");
mpl115a2.begin();
}
void loop(void)
{
float pressureKPA = 0, temperatureC = 0;
mpl115a2.getPT(&pressureKPA,&temperatureC);
Serial.print("Pressure (kPa): "); Serial.print(pressureKPA, 4); Serial.print(" kPa ");
Serial.print("Temp (*C): "); Serial.print(temperatureC, 1); Serial.println(" *C both measured together");
pressureKPA = mpl115a2.getPressure();
Serial.print("Pressure (kPa): "); Serial.print(pressureKPA, 4); Serial.println(" kPa");
temperatureC = mpl115a2.getTemperature();
Serial.print("Temp (*C): "); Serial.print(temperatureC, 1); Serial.println(" *C");
delay(1000);
}
The CPP:
/***********************************************************************/
/*!
@file Adafruit_MPL115A2.cpp
@author K.Townsend (Adafruit Industries)
@license BSD (see license.txt)
Driver for the MPL115A2 barometric pressure sensor
This is a library for the Adafruit MPL115A2 breakout
----> https://www.adafruit.com/products/992
Adafruit invests time and resources providing this open source code,
please support Adafruit and open-source hardware by purchasing
products from Adafruit!
@section HISTORY
v1.0 - First release
v1.1 - Rick Sellens added casts to make bit shifts work below 22.6C
- get both P and T with a single call to getPT
*/
/**************************************************************************/
#include "Adafruit_MPL115A2.h"
/**************************************************************************/
/*!
@brief Instantiates a new MPL115A2 class
*/
/**************************************************************************/
static uint8_t i2cread(void) {
uint8_t x;
x = Wire.read();
//Serial.print("0x"); Serial.println(x, HEX);
return x;
}
static void i2cwrite(uint8_t x) {
Wire.write((uint8_t)x);
}
/**************************************************************************/
/*!
@brief Gets the factory-set coefficients for this particular sensor
*/
/**************************************************************************/
void Adafruit_MPL115A2::readCoefficients() {
int16_t a0coeff;
int16_t b1coeff;
int16_t b2coeff;
int16_t c12coeff;
Wire.beginTransmission(MPL115A2_ADDRESS);
i2cwrite((uint8_t)MPL115A2_REGISTER_A0_COEFF_MSB);
Wire.endTransmission();
Wire.requestFrom(MPL115A2_ADDRESS, 8);
a0coeff = (( (uint16_t) i2cread() << 8) | i2cread());
b1coeff = (( (uint16_t) i2cread() << 8) | i2cread());
b2coeff = (( (uint16_t) i2cread() << 8) | i2cread());
c12coeff = (( (uint16_t) (i2cread() << 8) | i2cread())) >> 2;
/*
Serial.print("A0 = "); Serial.println(a0coeff, HEX);
Serial.print("B1 = "); Serial.println(b1coeff, HEX);
Serial.print("B2 = "); Serial.println(b2coeff, HEX);
Serial.print("C12 = "); Serial.println(c12coeff, HEX);
*/
_mpl115a2_a0 = (float)a0coeff / 8;
_mpl115a2_b1 = (float)b1coeff / 8192;
_mpl115a2_b2 = (float)b2coeff / 16384;
_mpl115a2_c12 = (float)c12coeff;
_mpl115a2_c12 /= 4194304.0;
/*
Serial.print("a0 = "); Serial.println(_mpl115a2_a0);
Serial.print("b1 = "); Serial.println(_mpl115a2_b1);
Serial.print("b2 = "); Serial.println(_mpl115a2_b2);
Serial.print("c12 = "); Serial.println(_mpl115a2_c12);
*/
}
/**************************************************************************/
/*!
@brief Instantiates a new MPL115A2 class
*/
/**************************************************************************/
Adafruit_MPL115A2::Adafruit_MPL115A2() {
_mpl115a2_a0 = 0.0F;
_mpl115a2_b1 = 0.0F;
_mpl115a2_b2 = 0.0F;
_mpl115a2_c12 = 0.0F;
}
/**************************************************************************/
/*!
@brief Setups the HW (reads coefficients values, etc.)
*/
/**************************************************************************/
void Adafruit_MPL115A2::begin() {
Wire.begin();
// Read factory coefficient values (this only needs to be done once)
readCoefficients();
}
/**************************************************************************/
/*!
@brief Gets the floating-point pressure level in kPa
*/
/**************************************************************************/
float Adafruit_MPL115A2::getPressure() {
float pressureComp,centigrade;
getPT(&pressureComp, ¢igrade);
return pressureComp;
}
/**************************************************************************/
/*!
@brief Gets the floating-point temperature in Centigrade
*/
/**************************************************************************/
float Adafruit_MPL115A2::getTemperature() {
float pressureComp, centigrade;
getPT(&pressureComp, ¢igrade);
return centigrade;
}
/**************************************************************************/
/*!
@brief Gets both at once and saves a little time
*/
/**************************************************************************/
void Adafruit_MPL115A2::getPT(float *P, float *T) {
uint16_t pressure, temp;
float pressureComp;
// Get raw pressure and temperature settings
Wire.beginTransmission(MPL115A2_ADDRESS);
i2cwrite((uint8_t)MPL115A2_REGISTER_STARTCONVERSION);
i2cwrite((uint8_t)0x00);
Wire.endTransmission();
// Wait a bit for the conversion to complete (3ms max)
delay(5);
Wire.beginTransmission(MPL115A2_ADDRESS);
i2cwrite((uint8_t)MPL115A2_REGISTER_PRESSURE_MSB); // Register
Wire.endTransmission();
Wire.requestFrom(MPL115A2_ADDRESS, 4);
pressure = (( (uint16_t) i2cread() << 8) | i2cread()) >> 6;
temp = (( (uint16_t) i2cread() << 8) | i2cread()) >> 6;
// See datasheet p.6 for evaluation sequence
pressureComp = _mpl115a2_a0 + (_mpl115a2_b1 + _mpl115a2_c12 * temp ) * pressure + _mpl115a2_b2 * temp;
// Return pressure and temperature as floating point values
*P = ((65.0F / 1023.0F) * pressureComp) + 50.0F; // kPa
*T = ((float) temp - 498.0F) / -5.35F +25.0F; // C
}
AND THE .H:
/**************************************************************************/
/*!
@file Adafruit_MPL115A2.h
@author K. Townsend (Adafruit Industries)
@license BSD (see license.txt)
This is a library for the Adafruit MPL115A2 breakout board
----> https://www.adafruit.com/products/???
Adafruit invests time and resources providing this open source code,
please support Adafruit and open-source hardware by purchasing
products from Adafruit!
@section HISTORY
v1.0 - First release
*/
/**************************************************************************/
#include "application.h"
/*=========================================================================
I2C ADDRESS/BITS
-----------------------------------------------------------------------*/
#define MPL115A2_ADDRESS (0x60) // 1100000
/*=========================================================================*/
/*=========================================================================
REGISTERS
-----------------------------------------------------------------------*/
#define MPL115A2_REGISTER_PRESSURE_MSB (0x00)
#define MPL115A2_REGISTER_PRESSURE_LSB (0x01)
#define MPL115A2_REGISTER_TEMP_MSB (0x02)
#define MPL115A2_REGISTER_TEMP_LSB (0x03)
#define MPL115A2_REGISTER_A0_COEFF_MSB (0x04)
#define MPL115A2_REGISTER_A0_COEFF_LSB (0x05)
#define MPL115A2_REGISTER_B1_COEFF_MSB (0x06)
#define MPL115A2_REGISTER_B1_COEFF_LSB (0x07)
#define MPL115A2_REGISTER_B2_COEFF_MSB (0x08)
#define MPL115A2_REGISTER_B2_COEFF_LSB (0x09)
#define MPL115A2_REGISTER_C12_COEFF_MSB (0x0A)
#define MPL115A2_REGISTER_C12_COEFF_LSB (0x0B)
#define MPL115A2_REGISTER_STARTCONVERSION (0x12)
/*=========================================================================*/
class Adafruit_MPL115A2{
public:
Adafruit_MPL115A2();
void begin(void);
float getPressure(void);
float getTemperature(void);
void getPT(float *P, float *T);
void write8(uint8_t a, uint8_t d);
private:
float _mpl115a2_a0;
float _mpl115a2_b1;
float _mpl115a2_b2;
float _mpl115a2_c12;
void readCoefficients(void);
uint8_t read8(uint8_t a);
uint8_t mode;
};
@tkurtz, try removing the “void” in the setup(void) and loop(void) statements. They should be:
void setup()
{
}
and
void loop()
{
}
@peekay123, nice catch, but still resulting in that same error. Other ideas?
@tkurtz, can you tell me what all the files names are?
@tkurtz, you are missing brackets at the end of this line!
Adafruit_MPL115A2 mpl115a2 = Adafruit_MPL115A2();
@peekay123, NEVER would have found that!!! Thank you so much, you’re the best!!!
Not sure if that pressure is close, but the Temp is.
Pressure (kPa): 99.7546 kPa Temp (*C): 20.9 *C both measured together
Pressure (kPa): 99.7546 kPa
Temp (*C): 20.9 *C
@tkurtz, blow on the sensor and see if they fluctuate. That is a good indication that things are working.
@peekay123, while I enjoyed great success due to your sage advice, I killed a photon and am risk of killing another. The one that was put to rest enjoyed quite a wonderful life, months of making and IoT joy. It was displaying a solid blue situation and had a dent in its main chip. Thinking that the indented metal cover was causing a situation, I attempted a radical surgery. Inserting fine tweeters between the cover and circuit the less then qualified technicians attempted to pry the cover away from the innards. This resulted in death. Not $19 bucks in the grave but rather, $19 bucks that delivered great learning and amateur maker fun.
But, OH! NO!!!, after getting our success at getting the temp sensor working, I plugged my backup photon into my breadboard. BTW, everyone has a backup photon at hand, right? Anyway, my backup photon also went into a solid blue state. Great sadness clouded my otherwise successful day.
Can you or another hardware expert help me recover from my solid blue state? I’d post images or my circuit that might have caused this state, but i’m too sad and must seek solace in a rum beverage.
Thanks again for your help today. You got me a little closer to porting libraries and gave me happiness in successfully getting two Ic2 boards functioning on Photon.
One thing that should always be tried before using “The Force” should be Safe Mode
Solid blue - is it the D7 LED solid blue or the RGB LED.
BTW: The Photon switches itself completely off if the housing would cause a short.
@ScruffR, Hi ScruffR, the now dead one was doing one of two things, either going through start up and ending in a solid blue RGB Mode LCD state or getting to solid blue and shutting off after about 100 ms. My other Photon is doing the same but not shutting off, just stuck in solid blue on the RGB Mode LCD.
Please advice. I read another posting on Solid Blue recovery and I’m not sure if I have the skills to get through this. Thank you!
First thing to do in such situation is to get the Photon disconnected from other circuitry and try Safe Mode.
If Safe Mode works, flash some dummy code wich definetly works and gives unmistakable feedback (e.g. blink D7).
After that gradually go forward reimplementing your project and see if the problem reappears, and check the last step you made, why it introduced the issue.
@ScruffR, I’ll give it a shot. How does one get into safe mode or is it already defaulting to safe? If this solid blue is “safe” mode then I’ve already tried to flash code but it isn’t taking a flashes. I also tried resetting it and starting fresh but it ends in the same mode and wont even accept a flash of tinker from my Andriod.
The docs are a good source for such things
https://docs.particle.io/guide/getting-started/modes/photon/#safe-mode
@ScruffR, well, actually those docs turn out to not be such a good source for this. The link for the DFU install takes you to another doc that doesn’t have the install instructions.
After searching about I stumbled on this nice tutorial.
DFU Install Tutorial
Oddly enough while I was riding into work on the bus I put the Photon in DFU mode and was getting ready to work through the DFU install but I ran out of time and arrived at my stop. At work I plugged in my Photon again and was getting ready for the DFU process when it actually started to breath again. Yay!!! I was able to flash some code and I’m back in action. Weird but I’m pleased to not have to attempt the DFU business.
Thanks again for all the help. @peekay123 @ScruffR
Hmm, how did this
not answer your question?