SparkFun Absolute Digital Barometer - LPS28DFW (Qwiic) Hookup Guide

Pages
Contributors: El Duderino
Favorited Favorite 0

LPS28DFW Arduino Library

Note: This library assumes you are using the latest version of the Arduino IDE on your desktop. 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.

The SparkFun LPS28DFW Arduino Library provides a quick and easy way to get started configuring and measuring pressure data from the sensor. Install the library using the Arduino Library Manager tool by searching for "SparkFun LPS28DFW". Users who prefer to manually install the library can download a copy of it from the GitHub repository by clicking the button below:

Library Functions

The list below outlines and describes the functions available in the SparkFun LPS28DFW Arduino Library. For detailed information on the parameters and use of all functions, refer to the .cpp file in the library.

Device Initialization and Configuration

  • 'int32_t begin(uint8_t address = LPS28DFW_I2C_ADDRESS_DEFAULT, TwoWire& wirePort = Wire);' - Begin communication with the sensor over I2 at the defined address and on the defined port. If no error occur, perform a soft reset and initialize the sensor.
  • 'int32_t init();' - Enables the BDU and IF_ADD_INC bits in the control registers.
  • 'int32_t boot();' - Enables the BOOT bit in the control registers
  • 'int32_t reset();' - Resets the sensor.
  • 'int32_t setModeConfig(lps28dfw_md_t* mode);' - Configures the operation mode settings for the sensor including range and ODR.
  • 'int32_t getModeConfig(lps28dfw_md_t* mode);' - Returns the operation mode settings.
  • 'int32_t getStatus(lps28dfw_stat_t* status);' - Returns the sensor status bits such as data ready, overrun, etc.

Sensor Data

  • 'int32_t getSensorData();' - Get pressure data from the sensor.

Interrupt Control and Feature Selection

  • 'int32_t setInterruptMode(lps28dfw_int_mode_t* intMode);' - Configures the interrupt pin to be either HIGH/LOW and LATCHED/PULSED.
  • 'int32_t enableInterrupts(lps28dfw_pin_int_route_t* intRoute);' - Enables the data ready and FIFO interrupt conditions.
  • 'int32_t getInterruptStatus(lps28dfw_all_sources_t* status);' - Returns the status of the interrupt flags.

FIFO Buffer Control

  • 'int32_t setFIFOConfig(lps28dfw_fifo_md_t* fifoConfig);' - Sets the FIFO configuration parameters.
  • 'int32_t getFIFOConfig(lps28dfw_fifo_md_t* fifoConfig);' - Returns settigs of FIFO buffer.
  • 'int32_t getFIFOLength(uint8_t* numData);' - Returns the number of samples stored in the FIFO buffer (up to 128).
  • 'int32_t getFIFOData(lps28dfw_fifo_data_t* data, uint8_t numData);' - Gets pressure data from the FIFO buffer.
  • 'int32_t flushFIFO();' - Clear all data from the FIFO buffer.

Reference Mode Control

  • 'int32_t setReferenceMode(lps28dfw_ref_md_t* mode);' - Sets the sensor to operate in reference mode. When called it stores the latest pressure data as a reference pressure. The reference pressure can be used with Threshold Mode to trigger interrupts.
  • 'int32_t setThresholdMode(lps28dfw_int_th_md_t* mode);' - Configures the sensor to trigger interrupts when the pressure measured exceeds a threshold relative to the defined reference pressure.
  • 'int32_t getReferencePressure(int16_t* pressRaw);' - Returns the value stored for the reference pressure.