Adafruit LPS2X Barometric Pressure Sensor Library
Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
Adafruit_LPS2X Class Referenceabstract

Class that stores state and functions for interacting with the LPS2X I2C Barometric Pressure & Temperature Sensor. More...

#include <Adafruit_LPS2X.h>

Inheritance diagram for Adafruit_LPS2X:
Adafruit_LPS22 Adafruit_LPS25

Public Member Functions

 Adafruit_LPS2X ()
 Construct a new Adafruit_LPS2X::Adafruit_LPS2X object.
 
bool begin_I2C (uint8_t i2c_addr=LPS2X_I2CADDR_DEFAULT, TwoWire *wire=&Wire, int32_t sensor_id=0)
 Sets up the hardware and initializes I2C. More...
 
bool begin_SPI (uint8_t cs_pin, SPIClass *theSPI=&SPI, int32_t sensor_id=0)
 Sets up the hardware and initializes hardware SPI. More...
 
bool begin_SPI (int8_t cs_pin, int8_t sck_pin, int8_t miso_pin, int8_t mosi_pin, int32_t sensor_id=0)
 Sets up the hardware and initializes software SPI. More...
 
void setPresThreshold (uint16_t hPa_delta)
 Set the pressure threshold register for interrupt levels. More...
 
bool getEvent (sensors_event_t *pressure, sensors_event_t *temp)
 Gets the pressure sensor and temperature values as sensor events. More...
 
void reset (void)
 Performs a software reset initializing registers to their power on state.
 
Adafruit_Sensor * getTemperatureSensor (void)
 Gets an Adafruit Unified Sensor object for the temp sensor component. More...
 
Adafruit_Sensor * getPressureSensor (void)
 Gets an Adafruit Unified Sensor object for the presure sensor component. More...
 

Protected Member Functions

virtual bool _init (int32_t sensor_id)=0
 The subclasses' hardware initialization function. More...
 
void _read (void)
 Updates the measurement data for all sensors simultaneously.
 

Protected Attributes

float _temp
 Last reading's temperature (C)
 
float _pressure
 Last reading's pressure (hPa)
 
uint16_t _sensorid_pressure
 ID number for pressure.
 
uint16_t _sensorid_temp
 ID number for temperature.
 
float temp_scaling = 1
 Different chips have different scalings.
 
float temp_offset = 1
 Different chips have different offsets.
 
uint8_t inc_spi_flag
 If this chip has a bitflag for incrementing SPI registers. More...
 
bool isOneShot = false
 true if data rate is one-shot
 
Adafruit_I2CDevice * i2c_dev = NULL
 Pointer to I2C bus interface.
 
Adafruit_SPIDevice * spi_dev = NULL
 Pointer to SPI bus interface.
 
Adafruit_LPS2X_Temptemp_sensor = NULL
 Temp sensor data object.
 
Adafruit_LPS2X_Pressurepressure_sensor
 Pressure sensor data object. More...
 
Adafruit_BusIO_Register * ctrl1_reg = NULL
 The first control register.
 
Adafruit_BusIO_Register * ctrl2_reg = NULL
 The second control register.
 
Adafruit_BusIO_Register * ctrl3_reg = NULL
 The third control register.
 
Adafruit_BusIO_Register * threshp_reg = NULL
 Pressure threshold.
 

Friends

class Adafruit_LPS2X_Temp
 
class Adafruit_LPS2X_Pressure
 

Detailed Description

Class that stores state and functions for interacting with the LPS2X I2C Barometric Pressure & Temperature Sensor.

Member Function Documentation

◆ begin_I2C()

bool Adafruit_LPS2X::begin_I2C ( uint8_t  i2c_address = LPS2X_I2CADDR_DEFAULT,
TwoWire *  wire = &Wire,
int32_t  sensor_id = 0 
)

Sets up the hardware and initializes I2C.

Parameters
i2c_addressThe I2C address to be used.
wireThe Wire object to be used for I2C connections.
sensor_idThe unique ID to differentiate the sensors from others
Returns
True if initialization was successful, otherwise false.

◆ begin_SPI() [1/2]

bool Adafruit_LPS2X::begin_SPI ( uint8_t  cs_pin,
SPIClass *  theSPI = &SPI,
int32_t  sensor_id = 0 
)

Sets up the hardware and initializes hardware SPI.

Parameters
cs_pinThe arduino pin # connected to chip select
theSPIThe SPI object to be used for SPI connections.
sensor_idThe user-defined ID to differentiate different sensors
Returns
True if initialization was successful, otherwise false.

◆ begin_SPI() [2/2]

bool Adafruit_LPS2X::begin_SPI ( int8_t  cs_pin,
int8_t  sck_pin,
int8_t  miso_pin,
int8_t  mosi_pin,
int32_t  sensor_id = 0 
)

Sets up the hardware and initializes software SPI.

Parameters
cs_pinThe arduino pin # connected to chip select
sck_pinThe arduino pin # connected to SPI clock
miso_pinThe arduino pin # connected to SPI MISO
mosi_pinThe arduino pin # connected to SPI MOSI
sensor_idThe user-defined ID to differentiate different sensors
Returns
True if initialization was successful, otherwise false.

◆ setPresThreshold()

void Adafruit_LPS2X::setPresThreshold ( uint16_t  hPa_delta)

Set the pressure threshold register for interrupt levels.

Parameters
hPa_deltaThe u16 that will be written to the register, check the datasheet for more info on the format of this value!

◆ getEvent()

bool Adafruit_LPS2X::getEvent ( sensors_event_t *  pressure,
sensors_event_t *  temp 
)

Gets the pressure sensor and temperature values as sensor events.

Parameters
pressureSensor event object that will be populated with pressure data
tempSensor event object that will be populated with temp data
Returns
True

◆ getTemperatureSensor()

Adafruit_Sensor * Adafruit_LPS2X::getTemperatureSensor ( void  )

Gets an Adafruit Unified Sensor object for the temp sensor component.

Returns
Adafruit_Sensor pointer to temperature sensor

◆ getPressureSensor()

Adafruit_Sensor * Adafruit_LPS2X::getPressureSensor ( void  )

Gets an Adafruit Unified Sensor object for the presure sensor component.

Returns
Adafruit_Sensor pointer to pressure sensor

◆ _init()

virtual bool Adafruit_LPS2X::_init ( int32_t  sensor_id)
protectedpure virtual

The subclasses' hardware initialization function.

!

Parameters
sensor_idThe unique sensor id we want to assign it
Returns
True on success, false if something went wrong!

Implemented in Adafruit_LPS22, and Adafruit_LPS25.

Friends And Related Function Documentation

◆ Adafruit_LPS2X_Temp

friend class Adafruit_LPS2X_Temp
friend

Gives access to private members to Temp data object

◆ Adafruit_LPS2X_Pressure

friend class Adafruit_LPS2X_Pressure
friend

Gives access to private members to Pressure data object

Member Data Documentation

◆ inc_spi_flag

uint8_t Adafruit_LPS2X::inc_spi_flag
protected
Initial value:
=
0

If this chip has a bitflag for incrementing SPI registers.

◆ pressure_sensor

Adafruit_LPS2X_Pressure* Adafruit_LPS2X::pressure_sensor
protected
Initial value:
=
NULL

Pressure sensor data object.


The documentation for this class was generated from the following files: