mirror of
https://github.com/kidoman/embd
synced 2025-07-04 20:37:46 +02:00
NPA-700 sensor support - requires https://github.com/kidoman/embd/pull/37
This commit is contained in:
parent
7054cdbeea
commit
fef92bd936
2 changed files with 85 additions and 0 deletions
35
samples/npa700b001d.go
Normal file
35
samples/npa700b001d.go
Normal file
|
@ -0,0 +1,35 @@
|
|||
// +build ignore
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
|
||||
"github.com/zlowred/embd"
|
||||
"github.com/zlowred/embd/sensor/npa700"
|
||||
|
||||
_ "github.com/zlowred/embd/host/all"
|
||||
)
|
||||
|
||||
func main() {
|
||||
flag.Parse()
|
||||
|
||||
if err := embd.InitI2C(); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
defer embd.CloseI2C()
|
||||
|
||||
bus := embd.NewI2CBus(1)
|
||||
|
||||
sensor := npa700.New(bus)
|
||||
|
||||
err := sensor.Read()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
fmt.Printf("Temp is %fC\n", sensor.Celsius())
|
||||
fmt.Printf("Temp is %fF\n", sensor.Fahrenheit())
|
||||
fmt.Printf("Pres is %fPa\n", sensor.Pascals(0, 1638, 14745, -6894.76, 6894.76))
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue