Version: v0.0.0-...-c0701d1 Latest Latest

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

Go to latest
Published: Aug 13, 2019 License: MIT Imports: 7 Imported by: 0




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

	// Connection retries definition
	ConnAttempts = 5

	// Sea level reference pressure in hPa
	QNH = 1013.25

	// Buffer size for reading data from BMP
	BufSize = 256

	// Read delay between chip reading attempts
	ReadDelay = time.Millisecond


This section is empty.


func CalcAltitude

func CalcAltitude(press float64) (altitude float64)


type BMP280

type BMP280 struct {
	Delay time.Duration

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

	T_fine int32

	C    <-chan *BMPData
	CBuf <-chan *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 or bmp280.Address2 powerMode is one of bmp280.SleepMode, bmp280.ForcedMode, or bmp280.NormalMode standby is one of the bmp280.StandbyTimeX filter is one of bmp280.FilterCoeffX tempRes is one of bmp280.OversampX presRes is one of bmp280.XMode

func (*BMP280) CalcCompensatedPress

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

func (*BMP280) CalcCompensatedTemp

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

func (*BMP280) Close

func (bmp *BMP280) Close()

Close closes the BMP280

func (*BMP280) GetFilterCoeff

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

func (*BMP280) GetOversampPress

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

func (*BMP280) GetOversampTemp

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

func (*BMP280) GetPowerMode

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

func (*BMP280) GetStandbyTime

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

func (*BMP280) ReadCorrectionSettings

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

func (*BMP280) SetFilterCoeff

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

func (*BMP280) SetOversampPress

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

func (*BMP280) SetOversampTemp

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

func (*BMP280) SetPowerMode

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

func (*BMP280) SetStandbyTime

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

type BMPData

type BMPData struct {
	Temperature float64
	Pressure    float64
	T           time.Duration

Source Files


Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to