Documentation ¶
Overview ¶
Package bme280 controls a Bosch BME280 device over I²C.
Datasheet ¶
https://ae-bst.resource.bosch.com/media/_tech/media/datasheets/BST-BME280_DS001-11.pdf
Example ¶
bus, err := i2creg.Open("") if err != nil { log.Fatalf("failed to open I²C: %v", err) } defer bus.Close() dev, err := NewI2C(bus, nil) if err != nil { log.Fatalf("failed to initialize bme280: %v", err) } env := devices.Environment{} if err := dev.Sense(&env); err != nil { log.Fatal(err) } fmt.Printf("%8s %10s %9s\n", env.Temperature, env.Pressure, env.Humidity)
Output:
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Dev ¶
type Dev struct {
// contains filtered or unexported fields
}
Dev is an handle to a bme280.
func NewI2C ¶
NewI2C returns an object that communicates over I²C to BME280 environmental sensor.
It is recommended to call Halt() when done with the device so it stops sampling.
func NewSPI ¶
NewSPI returns an object that communicates over SPI to BME280 environmental sensor.
Recommended values are O4x for oversampling, S20ms for standby and FOff for filter if planing to call frequently, else use S500ms to get a bit more than one reading per second.
It is recommended to call Halt() when done with the device so it stops sampling.
When using SPI, the CS line must be used.
func (*Dev) Halt ¶
Halt stops the bme280 from acquiring measurements.
It is recommended to call to reduce idle power usage.
type Filter ¶
type Filter uint8
Filter specifies the internal IIR filter to get steady measurements without using oversampling. This is mainly used to reduce power consumption.
type Opts ¶
type Opts struct { Temperature Oversampling Pressure Oversampling Humidity Oversampling Standby Standby Filter Filter Address uint16 }
Opts is optional options to pass to the constructor.
Recommended (and default) values are O4x for oversampling, S20ms for standby and FOff for filter if planing to call frequently, else use S500ms to get a bit more than one reading per second.
Address is only used on creation of an I²C-device. Its default value is 0x76. It can be set to 0x77. Both values depend on HW configuration of the sensor's SDO pin. This has no effect with NewSPI()
BUG(maruel): Remove the Standby flag and replace with a WaitForNextSample(time.Duration). Then use the closest value automatically.
type Oversampling ¶
type Oversampling uint8
Oversampling affects how much time is taken to measure each of temperature, pressure and humidity.
Temperature must be measured for pressure and humidity to be measured. The duration is approximatively:
duration_in_ms = 1 + 2*temp + 2*press+0.5 + 2*humidy+0.5
Using high oversampling and low standby results in highest power consumption, but this is still below 1mA so we generally don't care.
const ( No Oversampling = 0 O1x Oversampling = 1 O2x Oversampling = 2 O4x Oversampling = 3 O8x Oversampling = 4 O16x Oversampling = 5 )
Possible oversampling values.
Notes ¶
Bugs ¶
Remove the Standby flag and replace with a WaitForNextSample(time.Duration). Then use the closest value automatically.
Directories ¶
Path | Synopsis |
---|---|
Package bme280smoketest is leveraged by periph-smoketest to verify that two BME280, one over I²C, one over SPI, read roughly the same temperature, humidity and pressure.
|
Package bme280smoketest is leveraged by periph-smoketest to verify that two BME280, one over I²C, one over SPI, read roughly the same temperature, humidity and pressure. |