Failure Message using the MPL3115A2

Hello, I’m using the MPL3115A2 on the ESP32S3. All examples show me the following message

In file included from C:\Users\klaus\AppData\Local\Temp.arduinoIDE-unsaved2026221-8604-hesvvb.vxpck\SparkFunAltimeter\SparkFunAltimeter.ino:36:
g:\ESP-IDE-Workspace\libraries\SparkFun_MPL3115A2_Altitude_and_Pressure_Sensor_Breakout\src/SparkFunMPL3115A2.h:24:22: error: ‘STATUS’ redeclared as different kind of entity
24 | STATUS = 0x00,
| ^~~~
In file included from C:\Users\klaus\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.3.4\cores\esp32/esp32-hal-log.h:23,
from C:\Users\klaus\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.3.4\cores\esp32/esp32-hal.h:85,
from C:\Users\klaus\AppData\Local\Arduino15\packages\esp32\hardware\esp32\3.3.4\cores\esp32/Arduino.h:44,
from C:\Users\klaus\AppData\Local\arduino\sketches\D70E09AC7D31140C4981A2DBCAA457DE\sketch\SparkFunAltimeter.ino.cpp:1:
C:\Users\klaus\AppData\Local\Arduino15\packages\esp32\tools\esp32-arduino-libs\idf-release_v5.5-8410210c-v2\esp32s3/include/esp_rom/esp32s3/include/esp32s3/rom/ets_sys.h:557:3: note: previous declaration ‘typedef enum STATUS STATUS’
557 | } STATUS attribute((deprecated(“Use ETS_STATUS instead”)));
| ^~~~~~
exit status 1

I do not now how to handle this problem. Means, I’m a little bit lost. My feeling is the ESP32 is not working with the library.

If someone has a solution or hint, everything is welcome

It’s nothing you did; it looks like the new version of the ESP IDF core doesn’t like some of the names used in our library…sometimes updates break things that previously worked fine! The good news is you can fix it pretty quick!

Edit the Library

You need to rename the STATUS constant in the library files to something unique like MPL3115A2_STATUS:

Step 1: Navigate to your library folder:

G:\ESP-IDE-Workspace\libraries\SparkFun_MPL3115A2_Altitude_and_Pressure_Sensor_Breakout\src\

Step 2: Open SparkFunMPL3115A2.h (line 25) and change:

// OLD (line 24):
STATUS = 0x00,

// NEW:
MPL3115A2_STATUS = 0x00,

Step 3: Open SparkFunMPL3115A2.cpp and search for all instances of STATUS (likely in read commands) and replace with MPL3115A2_STATUS.

The first one is line 60; change

	while( (IIC_Read(STATUS) & (1<<1)) == 0)

to

	while( (IIC_Read(MPL3115A2_STATUS) & (1<<1)) == 0)

and similarly for lines 102, 106, 142, 146 and bingo :slight_smile: