bmp280

package
v0.0.0-...-7c269d2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 4, 2020 License: MIT Imports: 8 Imported by: 1

Documentation

Index

Constants

View Source
const (
	QNH            = 1013.25          // Sea level reference pressure in hPa
	BufSize        = 256              // Buffer size for reading data from BMP
	ExtraReadDelay = time.Millisecond // Delay between chip reading polls
)
View Source
const (
	// I2C Address Definitions
	Address1 = 0x76
	Address2 = 0x77
	// Chip ID Definitions
	ChipID1 = 0x56
	ChipID2 = 0x57
	ChipID3 = 0x58
	// Power Mode Definitions
	SleepMode     = 0x00
	ForcedMode    = 0x01
	NormalMode    = 0x03
	SoftResetCode = 0xB6
	// Standby Time Definitions
	StandbyTime1ms    = 0x00
	StandbyTime63ms   = 0x01
	StandbyTime125ms  = 0x02
	StandbyTime250ms  = 0x03
	StandbyTime500ms  = 0x04
	StandbyTime1000ms = 0x05
	StandbyTime2000ms = 0x06
	StandbyTime4000ms = 0x07
	// Filter Definitions
	FilterCoeffOff = 0x00
	FilterCoeff2   = 0x01
	FilterCoeff4   = 0x02
	FilterCoeff8   = 0x03
	FilterCoeff16  = 0x04
	// Oversampling Definitions
	OversampSkipped = 0x00
	Oversamp1x      = 0x01
	Oversamp2x      = 0x02
	Oversamp4x      = 0x03
	Oversamp8x      = 0x04
	Oversamp16x     = 0x05
	// Working Mode Definitions
	UltraLowPowerMode       = 0x00
	LowPowerMode            = 0x01
	StandardResolutionMode  = 0x02
	HighResolutionMode      = 0x03
	UltraHighResolutionMode = 0x04

	// BMP280 registers
	RegisterCompData      = 0x88
	RegisterChipID        = 0xD0
	RegisterSoftReset     = 0xE0
	RegisterStatus        = 0xF3
	RegisterControl       = 0xF4
	RegisterConfig        = 0xF5
	RegisterPressDataMSB  = 0xF7
	RegisterPressDataLSB  = 0xF8
	RegisterPressDataXLSB = 0xF9
	RegisterTempDataMSB   = 0xFA
	RegisterTempDataLSB   = 0xFB
	RegisterTempDataXLSB  = 0xFC
)

Variables

This section is empty.

Functions

func CalcAltitude

func CalcAltitude(press float64) (altitude float64)

CalcAltitude converts pressure in hPa to altitude in ft.

Types

type BMP280

type BMP280 struct {
	Address byte
	ChipID  byte

	Delay time.Duration

	DigT map[int]int32
	DigP map[int]int64

	T_fine int32

	C    <-chan *sensors.BMPData
	CBuf <-chan *sensors.BMPData
	// contains filtered or unexported fields
}

func NewBMP280

func NewBMP280(i2cbus *embd.I2CBus, address, powerMode, standby, filter, tempRes, presRes byte) (bmp *BMP280, err error)

NewBMP280 returns a BMP280 object with the chosen settings: address is one of bmp280.Address1 (0x76) or bmp280.Address2 (0x77). powerMode is one of bmp280.SleepMode, bmp280.ForcedMode, or bmp280.NormalMode. standby is one of the bmp280.StandbyTimeX (1ms up to 4000ms). filter is one of bmp280.FilterCoeffX. tempRes is one of bmp280.OversampX (up to 16x). presRes is one of bmp280.XMode (low power mode, etc). See BMP280 datasheet for details.

func (*BMP280) CalcCompensatedPress

func (bmp *BMP280) CalcCompensatedPress(raw_press int64) (press float64)

CalcCompensatedPress converts the raw measurement from the sensor, a 64-bit int, to an actual float pressure in hPa.

func (*BMP280) CalcCompensatedTemp

func (bmp *BMP280) CalcCompensatedTemp(raw_temp int32) (temp float64)

CalcCompensatedTemp converts the raw measurement from the sensor, a 32-bit int, to an actual float temperature in deg C.

func (*BMP280) Close

func (bmp *BMP280) Close()

Close closes the BMP280

func (*BMP280) GetFilterCoeff

func (bmp *BMP280) GetFilterCoeff() (filterCoeff byte, err error)

GetFilterCoeff returns the current filter coefficient of the sensor. Possible values are: bmp280.FilterCoeffOff = 0x00 bmp280.FilterCoeff2 = 0x01 bmp280.FilterCoeff4 = 0x02 bmp280.FilterCoeff8 = 0x03 bmp280.FilterCoeff16 = 0x04 See BMP280 datasheet for explanations.

func (*BMP280) GetOversampPress

func (bmp *BMP280) GetOversampPress() (oversampPres byte, err error)

GetOversampPress returns the current pressure oversampling setting for the sensor. Possible values are: bmp280.OversampSkipped = 0x00 bmp280.Oversamp1x = 0x01 bmp280.Oversamp2x = 0x02 bmp280.Oversamp4x = 0x03 bmp280.Oversamp8x = 0x04 bmp280.Oversamp16x = 0x05 See BMP280 datasheet for explanations.

func (*BMP280) GetOversampTemp

func (bmp *BMP280) GetOversampTemp() (oversampTemp byte, err error)

GetOversampTemp returns the current temperature oversampling setting for the sensor. Possible values are: bmp280.OversampSkipped = 0x00 bmp280.Oversamp1x = 0x01 bmp280.Oversamp2x = 0x02 bmp280.Oversamp4x = 0x03 bmp280.Oversamp8x = 0x04 bmp280.Oversamp16x = 0x05 See BMP280 datasheet for explanations.

func (*BMP280) GetPowerMode

func (bmp *BMP280) GetPowerMode() (powerMode byte, err error)

GetPowerMode returns the current power mode of the chip. Possible values are: bmp280.SleepMode = 0x00 bmp280.ForcedMode = 0x01 bmp280.NormalMode = 0x03 See BMP280 datasheet for explanations.

func (*BMP280) GetStandbyTime

func (bmp *BMP280) GetStandbyTime() (standbyTime byte, err error)

GetStandbyTime returns the current standby time between sensor reads. Possible values are: bmp280.StandbyTime1ms = 0x00 bmp280.StandbyTime63ms = 0x01 bmp280.StandbyTime125ms = 0x02 bmp280.StandbyTime250ms = 0x03 bmp280.StandbyTime500ms = 0x04 bmp280.StandbyTime1000ms = 0x05 bmp280.StandbyTime2000ms = 0x06 bmp280.StandbyTime4000ms = 0x07 See BMP280 datasheet for explanations.

func (*BMP280) ReadCorrectionSettings

func (bmp *BMP280) ReadCorrectionSettings() (err error)

ReadCorrectionSettings is used to read correction settings for the chip, set at the factory to read properly calibrated temperature and pressure.

func (*BMP280) SetFilterCoeff

func (bmp *BMP280) SetFilterCoeff(filterCoeff byte) error

SetFilterCoeff sets the current filter coefficient of the sensor. Possible values are: bmp280.FilterCoeffOff = 0x00 bmp280.FilterCoeff2 = 0x01 bmp280.FilterCoeff4 = 0x02 bmp280.FilterCoeff8 = 0x03 bmp280.FilterCoeff16 = 0x04 See BMP280 datasheet for explanations.

func (*BMP280) SetOversampPress

func (bmp *BMP280) SetOversampPress(oversampPres byte) error

SetOversampPress sets the current pressure oversampling setting for the sensor. Possible values are: bmp280.OversampSkipped = 0x00 bmp280.Oversamp1x = 0x01 bmp280.Oversamp2x = 0x02 bmp280.Oversamp4x = 0x03 bmp280.Oversamp8x = 0x04 bmp280.Oversamp16x = 0x05 See BMP280 datasheet for explanations.

func (*BMP280) SetOversampTemp

func (bmp *BMP280) SetOversampTemp(oversampTemp byte) error

SetOversampTemp sets the current temperature oversampling setting for the sensor. Possible values are: bmp280.OversampSkipped = 0x00 bmp280.Oversamp1x = 0x01 bmp280.Oversamp2x = 0x02 bmp280.Oversamp4x = 0x03 bmp280.Oversamp8x = 0x04 bmp280.Oversamp16x = 0x05 See BMP280 datasheet for explanations.

func (*BMP280) SetPowerMode

func (bmp *BMP280) SetPowerMode(powerMode byte) error

SetPowerMode sets the power mode of the chip. Possible values are: bmp280.SleepMode = 0x00 bmp280.ForcedMode = 0x01 bmp280.NormalMode = 0x03 bmp280.SoftResetCode = 0xB6 See BMP280 datasheet for explanations.

func (*BMP280) SetStandbyTime

func (bmp *BMP280) SetStandbyTime(standbyTime byte) error

SetStandbyTime sets the standby time between chip reads. Possible values are: bmp280.StandbyTime1ms = 0x00 bmp280.StandbyTime63ms = 0x01 bmp280.StandbyTime125ms = 0x02 bmp280.StandbyTime250ms = 0x03 bmp280.StandbyTime500ms = 0x04 bmp280.StandbyTime1000ms = 0x05 bmp280.StandbyTime2000ms = 0x06 bmp280.StandbyTime4000ms = 0x07 See BMP280 datasheet for explanations.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL