bmp280

package
v0.19.2 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2021 License: BSD-3-Clause Imports: 2 Imported by: 0

Documentation

Overview

Package bmp280 provides a driver for the BMP280 digital temperature & pressure sensor by Bosch.

Datasheet: https://www.bosch-sensortec.com/media/boschsensortec/downloads/datasheets/bst-bmp280-ds001.pdf

Index

Constants

View Source
const (
	REG_ID        = 0xD0 // WHO_AM_I
	REG_RESET     = 0xE0
	REG_STATUS    = 0xF3
	REG_CTRL_MEAS = 0xF4
	REG_CONFIG    = 0xF5
	REG_TEMP      = 0xFA
	REG_PRES      = 0xF7
	REG_CALI      = 0x88

	CHIP_ID   = 0x58
	CMD_RESET = 0xB6
)

Registers

View Source
const Address = 0x77

The I2C address which this device listens to.

Variables

This section is empty.

Functions

This section is empty.

Types

type Device

type Device struct {
	Address uint16

	Temperature Oversampling
	Pressure    Oversampling
	Mode        Mode
	Standby     Standby
	Filter      Filter
	// contains filtered or unexported fields
}

Device wraps an I2C connection to a BMP280 device.

func New

func New(bus drivers.I2C) Device

New creates a new BMP280 connection. The I2C bus must already be configured.

This function only creates the Device object, it does not initialize the device. You must call Configure() first in order to use the device itself.

func (*Device) Configure

func (d *Device) Configure(standby Standby, filter Filter, temp Oversampling, pres Oversampling, mode Mode)

Configure sets up the device for communication and read the calibration coefficients.

func (*Device) Connected

func (d *Device) Connected() bool

Connected returns whether a BMP280 has been found. It does a "who am I" request and checks the response.

func (*Device) PrintCali

func (d *Device) PrintCali()

PrintCali prints the Calibration information.

func (*Device) ReadPressure

func (d *Device) ReadPressure() (pressure int32, err error)

ReadPressure returns the pressure in milli pascals (mPa).

func (*Device) ReadTemperature

func (d *Device) ReadTemperature() (temperature int32, err error)

ReadTemperature returns the temperature in celsius milli degrees (°C/1000).

func (*Device) Reset

func (d *Device) Reset()

Reset preforms complete power-on-reset procedure. It is required to call Configure afterwards.

type Filter

type Filter uint

Filter unwanted changes in measurement caused by external (environmental) or internal changes (IC).

const (
	FILTER_OFF Filter = iota
	FILTER_2X
	FILTER_4X
	FILTER_8X
	FILTER_16X
)

type Mode

type Mode uint

Mode is the Power Mode.

const (
	MODE_SLEEP  Mode = 0x00
	MODE_FORCED Mode = 0x01
	MODE_NORMAL Mode = 0x03
)

type Oversampling

type Oversampling uint

OversamplingMode is the oversampling ratio of the temperature or pressure measurement.

const (
	SAMPLING_SKIPPED Oversampling = iota
	SAMPLING_1X
	SAMPLING_2X
	SAMPLING_4X
	SAMPLING_8X
	SAMPLING_16X
)

type Standby

type Standby uint

Standby is the inactive period between the reads when the sensor is in normal power mode.

const (
	STANDBY_1MS Standby = iota
	STANDBY_63MS
	STANDBY_125MS
	STANDBY_250MS
	STANDBY_500MS
	STANDBY_1000MS
	STANDBY_2000MS
	STANDBY_4000MS
)

Jump to

Keyboard shortcuts

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