mirror of
https://github.com/kidoman/embd
synced 2025-07-03 03:47:33 +02:00
fix bug with negative currents and add Power
This commit is contained in:
parent
69655b6c03
commit
e87156263c
2 changed files with 30 additions and 6 deletions
|
@ -23,7 +23,7 @@ func main() {
|
|||
|
||||
bus := embd.NewI2CBus(1)
|
||||
|
||||
ina := ina219.New(bus, 0x40, 0.1)
|
||||
ina := ina219.New(bus, 0x40, 0.001)
|
||||
defer ina.Close()
|
||||
|
||||
for {
|
||||
|
@ -42,7 +42,12 @@ func main() {
|
|||
panic(err)
|
||||
}
|
||||
|
||||
fmt.Printf("Shunt Voltage=%v Voltage=%v Current=%v\n", sv, v, c)
|
||||
p, err := ina.Power()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
fmt.Printf("Shunt Voltage=%v Voltage=%v Current=%v Power=%v \n", sv, v, c, p)
|
||||
|
||||
time.Sleep(500 * time.Millisecond)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue