mirror of
https://github.com/kidoman/embd
synced 2025-07-03 11:57:38 +02:00
initial commit
This commit is contained in:
commit
bc8776440f
9 changed files with 1034 additions and 0 deletions
38
samples/bmp085.go
Normal file
38
samples/bmp085.go
Normal file
|
@ -0,0 +1,38 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
"time"
|
||||
|
||||
"github.com/kid0m4n/go-rpi/i2c"
|
||||
"github.com/kid0m4n/go-rpi/sensor/bmp085"
|
||||
)
|
||||
|
||||
func main() {
|
||||
bus, err := i2c.NewBus(1)
|
||||
if err != nil {
|
||||
log.Panic(err)
|
||||
}
|
||||
baro := bmp085.New(bus)
|
||||
defer baro.Close()
|
||||
|
||||
for {
|
||||
temp, err := baro.Temperature()
|
||||
if err != nil {
|
||||
log.Panic(err)
|
||||
}
|
||||
log.Printf("Temp is %v", temp)
|
||||
pressure, err := baro.Pressure()
|
||||
if err != nil {
|
||||
log.Panic(err)
|
||||
}
|
||||
log.Printf("Pressure is %v", pressure)
|
||||
altitude, err := baro.Altitude()
|
||||
if err != nil {
|
||||
log.Panic(err)
|
||||
}
|
||||
log.Printf("Altitude is %v", altitude)
|
||||
|
||||
time.Sleep(500 * time.Millisecond)
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue