HP20X Class
- ID: hp20x
- Name: High-accuracy Barometer
- Other Names: HP20X Barometer (High-Accuracy)
- Category: pressure
- Manufacturer: seeed
- Link: http://www.seeedstudio.com/depot/Grove-Barometer-HighAccuracy-p-1865.html
- Connection: i2c
This is a high-accuracy barometer providing pressure, altitude, and temperature data. It can be calibrated for a given altitude offset, and a wide range of interrupt generating capabilities are supported. As usual, see the HP20X datasheet for more details.
This module was developed using a Grove Barometer (High-Accuracy) based on an HP206C chip.
Item Index
Methods
Properties
- CMD_SOFT_RST
- CMD_ADC_CVT
- CMD_READ_PT
- CMD_READ_AT
- CMD_READ_P
- CMD_READ_A
- CMD_READ_T
- CMD_ANA_CAL
- CMD_READ_REG
- CMD_WRITE_REG
- CHNL_PT
- CHNL_T
- CHNL_SHIFT
- DSR_4096
- DSR_2048
- DSR_1024
- DSR_512
- DSR_256
- DSR_128
- DSR_SHIFT
- REG_ALT_OFF_LSB
- REG_ALT_OFF_MSB
- REG_PA_H_TH_LSB
- REG_PA_H_TH_MSB
- REG_PA_M_TH_LSB
- REG_PA_M_TH_MSB
- REG_PA_L_TH_LSB
- REG_PA_L_TH_MSB
- REG_T_H_TH
- REG_T_M_TH
- REG_T_L_TH
- REG_INT_EN
- REG_INT_CFG
- REG_INT_SRC
- REG_PARA
- INT_EN_T_WIN_EN
- INT_EN_PA_WIN_EN
- INT_EN_T_TRAV_EN
- INT_EN_PA_TRAV_EN
- INT_EN_T_RDY_EN
- INT_EN_PA_RDY_EN
- INT_CFG_T_WIN_CFG
- INT_CFG_PA_WIN_CFG
- INT_CFG_T_TRAV_CFG
- INT_CFG_PA_TRAV_CFG
- INT_CFG_T_RDY_CFG
- INT_CFG_PA_RDY_CFG
- INT_CFG_PA_MODE
- INT_SRC_T_WIN
- INT_SRC_PA_WIN
- INT_SRC_T_TRAV
- INT_SRC_PA_TRAV
- INT_SRC_T_RDY
- INT_SRC_PA_RDY
- INT_SRC_DEV_RDY
- INT_SRC_TH_ERR
- PARA_CMPS_EN
Methods
HP20X
-
bus
-
address
HP20X constructor
Parameters:
-
bus
NumberI2C bus to use
-
address
NumberAddress for this device
Returns:
init
-
dsr
Sets up initial values and starts operation
Parameters:
-
dsr
DSR_BITS_TData sampling rate; one of the DSR_BITS_T values
Returns:
True if successful
writeCmd
-
cmd
Sends a command to the device
Parameters:
-
cmd
NumberCommand to send; usually, one of the HP20X_CMD_T values
Returns:
True if successful
writeReg
-
reg
-
data
Writes a value to a register
Parameters:
-
reg
HP20X_REG_TRegister to write to; one of the HP20X_REG_T values
-
data
NumberValue to write
Returns:
True if successful
readReg
-
reg
Reads a register and returns its value
Parameters:
-
reg
HP20X_REG_TRegister to read; one of the HP20X_REG_T values
Returns:
Value of a specified register
readData
()
Number
Reads 3 bytes of data in response to a conversion request, and converts it to an integer
Returns:
Value read back (temperature, pressure, etc.)
isReady
()
Boolean
Checks to see if the DR_RDY bit is set, indicating the device can accept commands
Returns:
True if the device is ready, false otherwise
waitforDeviceReady
()
Boolean
Checks to see if the device is ready, and sleeps/retries if not. Returns once the device indicates it's ready.
Returns:
True if the device is ready; false if retries are exhausted
getTemperature
()
Number
Returns the temperature in Celsius
Returns:
Temperature
getPressure
()
Number
Returns the pressure in millibars
Returns:
Pressure
getAltitude
()
Number
Returns the computed altitude in meters
Returns:
Altitude
compensationEnable
-
enable
Enables or disables the on-chip compensator. This allows the chip to filter and clean up the output data.
Parameters:
-
enable
BooleanTrue to enable, false otherwise
setInterruptEnable
-
bits
Sets up the interrupt enable register. This register defines which events can cause a hardware interrupt pin to be pulled high (active).
Parameters:
-
bits
NumberOne or more of the INT_EN_BITS_T bits
Returns:
True if successful, false otherwise
setInterruptConfig
-
bits
Sets up the interrupt configuration register. This register defines which events can cause an interrupt to be indicated.
Parameters:
-
bits
NumberOne or more of the INT_EN_BITS_T bits
Returns:
True if successful, false otherwise
getInterruptSource
()
Number
Gets the interrupt source register. This register indicates which interrupts have been triggered. In addition, it indicates when certain operations have been completed.
Returns:
One of more of the INT_SRC_BITS_T values
setDSR
-
dsr
Sets the data sampling rate. Higher rates are more precise, but take more time per measurement.
Parameters:
-
dsr
DSR_BITS_TOne of the DSR_BITS_T values
recalibrateInternal
()
Starts an internal recalibration of analog blocks. This is faster than a soft reset.
softReset
()
Executes a soft reset. All register values are reset to power-on defaults. This function returns when the reset is complete and the device reports it is ready.
setAltitudeOffset
-
off
Sets the altitude offset for your region. See the datasheet for more details. Setting this correctly for your region is required for accurate altitude data.
Parameters:
-
off
NumberOffset
setPAThreshholds
-
low
-
med
-
high
Sets pressure/altitude thresholds for interrupt generation
Parameters:
-
low
NumberLow threshold to generate an interrupt
-
med
NumberMedium threshold to generate an interrupt
-
high
NumberHigh threshold to generate an interrupt
setTemperatureThreshholds
-
low
-
med
-
high
Sets temperature thresholds for interrupt generation
Parameters:
-
low
NumberLow threshold to generate an interrupt
-
med
NumberMedium threshold to generate an interrupt
-
high
NumberHigh threshold to generate an interrupt