kopia lustrzana https://github.com/cyoung/stratux
Support for BMP390 (untested)
rodzic
d7d4be46ba
commit
ab49130e70
|
@ -88,7 +88,7 @@ func initPressureSensor() (ok bool) {
|
||||||
log.Printf("Error identifying IMU: %s\n", err.Error())
|
log.Printf("Error identifying IMU: %s\n", err.Error())
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
if v == bmp388.ChipId {
|
if v == bmp388.ChipId || v == bmp388.ChipId390 {
|
||||||
log.Printf("BMP-388 detected")
|
log.Printf("BMP-388 detected")
|
||||||
bmp, err := sensors.NewBMP388(&i2cbus)
|
bmp, err := sensors.NewBMP388(&i2cbus)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
|
|
|
@ -6,6 +6,7 @@ and converted to use embed
|
||||||
*/
|
*/
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
|
|
||||||
"github.com/kidoman/embd"
|
"github.com/kidoman/embd"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -172,7 +173,7 @@ func (d *BMP388) ReadPressure() (float64, error) {
|
||||||
}
|
}
|
||||||
func (d *BMP388) Connected() bool {
|
func (d *BMP388) Connected() bool {
|
||||||
data, err := d.readRegister(RegChipId, 1)
|
data, err := d.readRegister(RegChipId, 1)
|
||||||
return err == nil && data[0] == ChipId // returns true if i2c comm was good and response equals 0x50
|
return err == nil && (data[0] == ChipId || data[0] == ChipId390) // returns true if i2c comm was good and response equals 0x50/0x60
|
||||||
}
|
}
|
||||||
func (d *BMP388) SetMode(mode Mode) error {
|
func (d *BMP388) SetMode(mode Mode) error {
|
||||||
d.Config.Mode = mode
|
d.Config.Mode = mode
|
||||||
|
|
|
@ -20,6 +20,7 @@ const (
|
||||||
|
|
||||||
const (
|
const (
|
||||||
ChipId byte = 0x50 // correct response if reading from chip id register
|
ChipId byte = 0x50 // correct response if reading from chip id register
|
||||||
|
ChipId390 byte = 0x60 // BMP390 is compatible to bmp388, just with different Chip ID, see #252
|
||||||
PwrPress byte = 0x01 // power on pressure sensor
|
PwrPress byte = 0x01 // power on pressure sensor
|
||||||
PwrTemp byte = 0x02 // power on temperature sensor
|
PwrTemp byte = 0x02 // power on temperature sensor
|
||||||
SoftReset byte = 0xB6 // command to reset all user configuration
|
SoftReset byte = 0xB6 // command to reset all user configuration
|
||||||
|
|
Ładowanie…
Reference in New Issue