SparkFun Qwiic MicroPressure Hookup Guide

Pages
Contributors: Alex the Giant, Ell C
Favorited Favorite 3

Software Setup and Programming

Note: This code/library has been written and tested on Arduino IDE version 1.8.13.

If this is your first time using Arduino, please review our tutorial on installing the Arduino IDE. If you have not previously installed an Arduino library, please check out our installation guide.

SparkFun has written a library to work with the Qwiic MicroPressure Sensor. You can obtain this library through the Arduino Library Manager by searching for "MicroPressure". Find the one written by SparkFun Electronics and install the latest version. If you prefer downloading libraries manually, you can grab them from the GitHub Repository.

Functions

Below is a list of the functions that can be used with the MicroPressure sensor, along with a description of what each function does and how to use it.

  • SparkFun_MicroPressure( int8_t eoc_pin, int8_t rst_pin, uint8_t minimumPSI, uint8_t maximumPSI ) - The constructor has four optional arguments, by default the eoc_pin, and rst_pin are not used, and the MicroPressure sensor used on the board has a pressure range of 0 - 25 PSI.

    • eoc_pin - The End Of Conversion pin is set high when a measurement and calculation have been completed and the data is ready to be clocked out. When set to -1, the status register is used to check when a measurement is ready to be clocked out. Default: -1
    • rst_pin - The Reset pin is active low, and resets the sensor in the begin function. When set to -1, the board will reset after a power cycle. Default: -1
    • minimumPSI - The minimum PSI value is used in the pressure conversion calculation for the MPR series sensor. Default: 0 PSI
    • maximumPSI - The minimum PSI value is used in the pressure conversion calculation for the MPR series sensor. Default: 25 PSI
  • bool begin(uint8_t deviceAddress, TwoWire &wirePort) - Call at the beginning of the sketch to intialize the device. This function takes two optional parameters: deviceAddress and wirePort. This function will return true when the device is intialized, and false if it is unable to communicate with the device.

    • deviceAddress - The MPR series sensor has multiple I2C addresses that are fixed as shown on page 7 of the datasheet, with the most common address being 0x18. Default: 0x18
    • wirePort - Sets the I2C bus the sensor is connected to, such as Wire or Wire1. Default: Wire
  • float readPressure (Pressure_Units units) - returns the pressure sensor reading. The sensor outputs pressure in pounds per square inch, or PSI. If you would prefer a different unit of measurement, this function can convert the reading to one of the following for you by passing the argument:

    • PSI - Pounds per Square Inch (default)
    • PA - Pascals
    • KPA - kilopascals
    • BAR - bar (1 bar is equal to 100,000 Pa)
    • TORR - torr (1 torr is roughly equal to 133.32 Pa)
    • INMG - Inches of Mercury (Mg)
    • ATM - Atmospheres
  • uint8_t readStatus( void ) - Reads and returns the status byte of the sensor. For more information about the status byte refer to page 15 of the datasheet.