kopia lustrzana https://github.com/cyoung/stratux
final fixes, read correct sensor id from reg
rodzic
c71c010865
commit
d7d4be46ba
|
@ -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_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
|
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 = 0x00
|
||||||
ICMREG_WHO_AM_I_VAL = 0xEA // Expected value.
|
ICMREG_WHO_AM_I_VAL = 0xEA // Expected value.
|
||||||
PRESSURE_WHO_AM_I = bmp388.Address // Expected address for bosch pressure sensors bmpXXX.
|
PRESSURE_WHO_AM_I = bmp388.RegChipId // Expected address for bosch pressure sensors bmpXXX.
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -96,6 +96,7 @@ func initPressureSensor() (ok bool) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
log.Printf("using BMP-280")
|
||||||
bmp, err := sensors.NewBMP280(&i2cbus, 100*time.Millisecond)
|
bmp, err := sensors.NewBMP280(&i2cbus, 100*time.Millisecond)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
myPressureReader = bmp
|
myPressureReader = bmp
|
||||||
|
|
|
@ -15,7 +15,11 @@ type BMP388 struct {
|
||||||
|
|
||||||
func NewBMP388(i2cbus *embd.I2CBus) (*BMP388, error) {
|
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
|
// retry to connect until sensor connected
|
||||||
var connected bool
|
var connected bool
|
||||||
for n := 0; n < 5; n++ {
|
for n := 0; n < 5; n++ {
|
||||||
|
|
|
@ -2,15 +2,18 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/b3nn0/stratux/sensors/bmp388"
|
"github.com/b3nn0/stratux/sensors/bmp388"
|
||||||
"github.com/kidoman/embd"
|
"github.com/kidoman/embd"
|
||||||
"time"
|
_ "github.com/kidoman/embd/host/all"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
|
||||||
i2cbus := embd.NewI2CBus(1)
|
i2cbus := embd.NewI2CBus(1)
|
||||||
bmp := bmp388.BMP388{Bus: &i2cbus, Address: bmp388.Address}
|
bmp := bmp388.BMP388{Bus: &i2cbus, Address: bmp388.Address}
|
||||||
|
bmp.Configure(bmp.Config)
|
||||||
|
|
||||||
fmt.Println("t,temp,press,alt")
|
fmt.Println("t,temp,press,alt")
|
||||||
|
|
||||||
|
|
Ładowanie…
Reference in New Issue