Documentation ¶
Index ¶
- Constants
- type BMP
- func (me *BMP) Configuration() *Configuration
- func (me *BMP) Init() error
- func (me *BMP) ReadAll() (float64, float64, error)
- func (me *BMP) ReadPressure() (float64, error)
- func (me *BMP) ReadTemperature() (float64, error)
- func (me *BMP) Reset() error
- func (me *BMP) SetConfiguration(cfg *Configuration) error
- type Configuration
- type FilteringCoefficient
- type Oversampling
- type PowerMode
- type StandbyTime
Constants ¶
const ( // AddressDefault the default I2C address BMP280 uses when the SDO pin is grounded AddressDefault uint8 = 0x76 // AddressLegacy the default I2C address for BMP180. BMP280 can also have this I2C address when SDO pin is connected to Vddio AddressLegacy uint8 = 0x77 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BMP ¶
type BMP struct {
// contains filtered or unexported fields
}
BMP a BMP280 sensor
func NewBMP280 ¶
NewBMP280 create an initialize a new BMP280 sensor. Returns the newly created BMP280 sensor
func NewBMP280WithConfig ¶
func NewBMP280WithConfig(dev *i2c.Dev, cfg *Configuration) (*BMP, error)
NewBMP280WithConfig create an initialize a new BMP280 sensor and set up its initial configuration. Returns the newly created BMP280 sensor or any errors that occurred when configuring it.
func (*BMP) Configuration ¶
func (me *BMP) Configuration() *Configuration
Configuration get the current configuration for this BMP280 sensor
func (*BMP) Init ¶
Init initializes the BMP280 sensor with calibration data saved in the BMP280's registers
func (*BMP) ReadAll ¶
ReadAll reads both temperature and pressure sensor data at once. Returns temperature value, pressure value, or any errors that occurred
func (*BMP) ReadPressure ¶
ReadPressure read the latest pressure reading from the BMP280. Returns the pressure in Pascals or any i2c errors that occurred
func (*BMP) ReadTemperature ¶
ReadTemperature read the latest temperature reading from the BMP280. Returns the temperature in Celsius or any i2c errors that occurred
func (*BMP) SetConfiguration ¶
func (me *BMP) SetConfiguration(cfg *Configuration) error
SetConfiguration set up the configuration for how this BMP280 sensor should operate. Returns any errors that occur when configuring the sensor
type Configuration ¶
type Configuration struct { StandbyTime StandbyTime IIRFiltering FilteringCoefficient TemperatureOversampling Oversampling PressureOversampling Oversampling Mode PowerMode }
Configuration additional configuration options for the BMP280 sensor
func ConfigDefault ¶
func ConfigDefault() *Configuration
ConfigDefault returns a default configuration for the BMP280 sensor. This configuration offers a decent compromise between power consumption, resolution, and responsiveness
func ConfigHighSpeed ¶
func ConfigHighSpeed() *Configuration
ConfigHighSpeed returns a configuration for low resolution, high speed (~125 Hz refresh rate), high power consumption applications.
func ConfigLowPower ¶
func ConfigLowPower() *Configuration
ConfigLowPower returns a configuration for low resolution, low speed, ultra-low power consumption applications
type FilteringCoefficient ¶
type FilteringCoefficient uint8
FilteringCoefficient options for filtering data to smooth sudden spikes in sensor readings
const ( // FilteringOff no filtering. Each value is the last raw value read from the sensor FilteringOff FilteringCoefficient = 0x00 // Filtering2 Slight filtering. Takes about 2 samples to start seeing significant changes in sensor values Filtering2 FilteringCoefficient = 0x02 // Filtering4 Some filtering. Takes about 5 samples to start seeing significant changes in sensor values Filtering4 FilteringCoefficient = 0x03 // Filtering8 High filtering. Takes about 11 samples to start seeing significant changes in sensor values Filtering8 FilteringCoefficient = 0x04 // Filtering16 Very high filtering. Takes about 22 samples to start seeing significant changes in sensor values Filtering16 FilteringCoefficient = 0x05 )
type Oversampling ¶
type Oversampling uint8
Oversampling defines how much sampling do to for a measurement. Higher sampling means higher precision, but slower measurement speeds
const ( // OversampleSkip skip this measurement OversampleSkip Oversampling = 0x00 // OversampleX1 16 bit resolution (2.62 Pa or 0.0050 C) OversampleX1 Oversampling = 0x01 // OversampleX2 17 bit resolution (1.31 Pa or 0.0025 C) OversampleX2 Oversampling = 0x02 // OversampleX4 18 bit resolution (0.66 Pa or 0.0012 C) OversampleX4 Oversampling = 0x03 // OversampleX8 19 bit resolution (20.33 Pa or 0.0006 C) OversampleX8 Oversampling = 0x04 // OversampleX16 20 bit resolution (0.16 Pa or 0.0003 C) OversampleX16 Oversampling = 0x05 )
type PowerMode ¶
type PowerMode uint8
PowerMode indicates what power mode the BMP sensor should operate in
const ( // ModeSleep No measurements are performed. Power consumption is at a minimum. All registers are accessible ModeSleep PowerMode = 0x00 // ModeForced Single measurements are performed according to the select measurement and filter options. Sensor returns to sleep mode after measurement. ModeForced PowerMode = 0x01 // ModeNormal Continuously cycles between an active measurement period and inactive standby period (defined by Standby Time). ModeNormal PowerMode = 0x03 )
type StandbyTime ¶
type StandbyTime uint8
StandbyTime defines how long between measurements during NormalMode operation
const ( // Standby500u 500 microseconds Standby500u StandbyTime = 0x00 // Standby062 62.5 milliseconds Standby062 StandbyTime = 0x01 // Standby125 125 milliseconds Standby125 StandbyTime = 0x02 // Standby250 250 milliseconds Standby250 StandbyTime = 0x03 // Standby500 500 milliseconds Standby500 StandbyTime = 0x04 // Standby1s 1 second Standby1s StandbyTime = 0x05 // Standby2s 2 seconds Standby2s StandbyTime = 0x06 // Standby4s 4 seconds Standby4s StandbyTime = 0x07 )