I2C_MPRLS

July 16, 2026 ยท View on GitHub

Arduino CI Arduino-lint JSON check GitHub issues

License: MIT GitHub release PlatformIO Registry

I2C_MPRLS

Arduino library for MPRLS pressure sensors. (Honeywell).

Description

The MPRLS sensor of Honeywell exists in many variations and ranges. In the "sensor type" section below these variations are explained a bit. Check the datasheet of your type for all the details.

The I2C_MPRLS library can read the sensor over I2C and returns the pressure in the same unit as used in the begin() function. There is no conversion. Typical units to use are Bar, mBar, KPa or PSI, depending on the sensor used, (see datasheet figure 2). although one may convert the sensors specified unit to any other of course. E.g. use a PSI sensor an configure it as a mBar sensor.

The MPRLS sensor comes with different transfer functions. The pressure is measured in 24 bit but only a part of the full range is used. This can be 20-80%, 10-90% or 2.5-22.5%, depending on the transfer function. Default transfer function is A but the library allows to set B or C.

The MPR series are relative low pressure sensors, for higher pressure ranges you might check e.g. the Honeywell ABP series.

Feedback, as always, is welcome.

Hardware connection

Always check datasheet for the exact pins. (Figure 3. I2C Circuit Diagram)

        MPRLS              ARDUINO
    +----------+        +----------+
    |          |        |          |
    |     GND o|--------|o GND     |
    |     VCC o|--------|o VCC     |
    |     SDA o|--------|o SDA     |
    |     SCL o|--------|o SCL     |
    |          |        |          |
    |     EOC o|------->|o GPIO    |
    |     RES o|<-------|o GPIO    |
    |          |        |          |
    +----------+        +----------+
    
pinnamedescriptionNotes
10GNDGround
12VCCPower
8EOCEnd Of Conversionnot supported yet.
9RESRESETnot supported yet.
2SDAI2C data
3SCLI2C clockmax 400 kHz.
otherNCnot connected

Note: SPI is not supported in this library, maybe in the future.
The connections for SPI in datasheet miss pull up resistors.

Sensor type

Detailed information see Figure 2. Product Nomenclature

The MPR sensor has a full product type string like

MPRLS0025PA00001A 
split in fields:

MPR  L  S  0025  P  A  0000   1  A
partdescription
MPRSeries, Micro Pressure (R unknown)
Lmodel: L = Long
SSilicone gel
0025max pressure = 25 units
Punit: P (Psi) or B(bar), M(mbar), K(kPa) ...
AA=Absolute, G=Gage
0000min pressure = 0 units
1IO: S=SPI, digit = I2C address => 0xN8 (e.g. 1 => 0x18)
Atransfer function: A,B or C

The last character A is the transfer function to be used to calculate the pressure from the raw pressure count. The library supports A B and C and raw pressure count.

Pressure sensors:

Other:

I2C

I2C address

Datasheet figure 2. The address is hard coded in the sensor, so order the right type.

HEXDECHEXDEC
0x0880x4872
0x18240x5888
0x28400x68104
0x38560x78120

I2C multiplexing

Sometimes you need to control more devices than possible with the default address range the device provides. This is possible with an I2C multiplexer e.g. TCA9548 which creates up to eight channels (think of it as I2C subnets) which can use the complete address range of the device.

Drawback of using a multiplexer is that it takes more administration in your code e.g. which device is on which channel. This will slow down the access, which must be taken into account when deciding which devices are on which channel. Also note that switching between channels will slow down other devices too if they are behind the multiplexer.

I2C Performance

The sensor supports up to 400 kHz for I2C-bus (datasheet).

TODO: run performance sketch with hardware.

Only test read() as that is the main function.

Clocktime (us)Notes
100 kHzdefault
200 kHz
300 kHz
400 kHzmaximum datasheet

Interface

#include "I2C_MPRLS.h"

Constructor

  • I2C_MPRLS(uint8_t address, TwoWire *wire = &Wire) Constructor, I2C address and optional the wire interface can be defined.
  • bool begin(float maxPressure) initializes range as 0..maxPressure.
  • bool begin(float minPressure, float maxPressure) initializes range. Note: all sensors have a range starting at zero, however one might set minPressure to be non zero to adjust (calibrate) the range. The pressure is in arbitrary units, can be PSI, mBar, KPa etc. The function getPressure() returns the same units. Returns true if the address can be found on the I2C bus.
  • void reset() resets internal variables, including pressure.
  • bool isConnected() tests if the address can be found on the I2C bus.
  • uint8_t getAddress() returns the I2C address configured in the constructor. Mainly for debug message.

Transfer function

The MPR sensors come with three different transfer functions, named 'A', 'B' or 'C'. This function defines how the raw counter is converted to pressure. The library defaults to 'A' but the other transfer functions to be set.

  • void setTransferFunction(char tff) idem. Parameter tff == 'A', 'B' or 'C'. Default = 'A'. The tff is case sensitive as it is the last character of the sensor type code.
  • char getTransferFunction() return set value or default 'A'.

There is no validity check on the TFF parameter, to allow to add additional (proprietary) transfer functions in the library. This can be used to have other conversion of the raw pressure count (rpc) to pressure. Or one could just pass through the rpc. If TFF is not supported, the default 'A' is used.

Read ASYNC

  • int request() request new pressure conversion. Returns I2C_MPRLS_OK or an error code.
  • bool conversionReady() returns true if state byte indicates not busy. Can set an error code.
  • int getData() reads the status and pressure data, checks for errors, calculates the pressure and set the lastRead time stamp. Returns I2C_MPRLS_OK or an error code.

Read, getPressure

Before any call to getPressure() one need to call read() unless one wants the last value read.

  • int read() actually reads the status and pressure, checks for errors, calculates the pressure and set the lastRead time stamp. The read() call blocks for at least 5 milliseconds. Returns I2C_MPRLS_OK or an error code.
  • int getPressure() returns pressure in units as defined in begin(). Multiple calls give the same value until a new call to read() is made.

Check related library: https://github.com/RobTillaart/pressure for conversions.

In the future an ASYNC API for read will be implemented. First need the working be validated with hardware.

State

  • uint32_t lastRead() time in milliseconds of last successful read of the sensor.
  • uint8_t getState() returns last known state fetched by read() or getData().
statebit maskmeaning
I2C_MPRLS_POWER0x401 = device powered
I2C_MPRLS_BUSY0x201 = device busy
I2C_MPRLS_MEMTEST0x041 = integrity fail
I2C_MPRLS_MATH0x011 = math saturation
other fields0x00always 0

Error

  • uint16_t errorCount() total counter for the number of errors occurred. Internal counter wraps after 65535.
  • int getLastError() returns last error and resets error flag.
errormeaning
I2C_MPRLS_OKno error
I2C_MPRLS_INITbegin() not called
I2C_MPRLS_READ_ERRORI2C error
I2C_MPRLS_WRITE_ERRORI2C error
I2C_MPRLS_CONNECT_ERRORI2C error

Debugging

Raw counter API, for debugging or your own conversion.

  • int rawPressureCount() idem.
  • float getMinPressure() idem.
  • float getMaxPressure() idem.

Testing

The library is not tested with hardware yet.

Your feedback is welcome.

Future

Must

  • update documentation
  • verify with hardware
  • keep in sync with I2C_ASDX if possible

Should

Could

  • improve performance of pressure math
    • first need verification they work
  • add lastRequest timeStamp for more efficient async
    • no need to poll state before e.g. 5 ms
    • implement conversionReady() based upon millis() and lastRequest
    • implement isBusy() upon state field.
    • lastRequest > lastRead fails when wrapping occurs.
    • lastRequest ==> 0 after read?
  • add examples
    • derived
  • check datasheet if SPI bus is faster?
  • support EOC pin
  • support RES (reset) pin

Wont

Support

If you appreciate my libraries, you can support the development and maintenance. Improve the quality of the libraries by providing issues and Pull Requests, or donate through PayPal or GitHub sponsors.

Thank you,