1
0
Fork 0
mirror of https://github.com/kidoman/embd synced 2025-07-04 20:37:46 +02:00
This commit is contained in:
Max Matveev 2016-02-06 00:14:45 -08:00
parent 7054cdbeea
commit fef92bd936
2 changed files with 85 additions and 0 deletions

35
samples/npa700b001d.go Normal file
View 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))
}