final fixes, read correct sensor id from reg

pull/827/head
ori 2023-09-22 20:09:10 +03:00 zatwierdzone przez Adrian Batzill
rodzic c71c010865
commit d7d4be46ba
3 zmienionych plików z 12 dodań i 4 usunięć

Wyświetl plik

@ -32,8 +32,8 @@ const (
MPUREG_WHO_AM_I_VAL_60X0 = 0x68 // Expected value for MPU6000 and MPU6050 (and MPU9150)
MPUREG_WHO_AM_I_VAL_UNKNOWN = 0x75 // Unknown MPU found on recent batch of gy91 boards see discussion 182
ICMREG_WHO_AM_I = 0x00
ICMREG_WHO_AM_I_VAL = 0xEA // Expected value.
PRESSURE_WHO_AM_I = bmp388.Address // Expected address for bosch pressure sensors bmpXXX.
ICMREG_WHO_AM_I_VAL = 0xEA // Expected value.
PRESSURE_WHO_AM_I = bmp388.RegChipId // Expected address for bosch pressure sensors bmpXXX.
)
var (
@ -96,6 +96,7 @@ func initPressureSensor() (ok bool) {
return true
}
} else {
log.Printf("using BMP-280")
bmp, err := sensors.NewBMP280(&i2cbus, 100*time.Millisecond)
if err == nil {
myPressureReader = bmp

Wyświetl plik

@ -15,7 +15,11 @@ type BMP388 struct {
func NewBMP388(i2cbus *embd.I2CBus) (*BMP388, error) {
bmp := bmp388.BMP388{Address: bmp388.Address, Config: bmp388.Config{}, Bus: i2cbus} //new sensor
bmp := bmp388.BMP388{Address: bmp388.Address, Config: bmp388.Config{
Temperature: bmp388.Sampling8X,
Pressure: bmp388.Sampling2X,
IIR: bmp388.Coeff0,
}, Bus: i2cbus} //new sensor
// retry to connect until sensor connected
var connected bool
for n := 0; n < 5; n++ {

Wyświetl plik

@ -2,15 +2,18 @@ package main
import (
"fmt"
"time"
"github.com/b3nn0/stratux/sensors/bmp388"
"github.com/kidoman/embd"
"time"
_ "github.com/kidoman/embd/host/all"
)
func main() {
i2cbus := embd.NewI2CBus(1)
bmp := bmp388.BMP388{Bus: &i2cbus, Address: bmp388.Address}
bmp.Configure(bmp.Config)
fmt.Println("t,temp,press,alt")