Hello all,
I am trying to query a MCP3208 on Raspberry Pi Zero W.
Unfortunately, I always get zero values from any of the eight channels.
I guess I need to specifiy the connection parameters at some point. But I have no idea how can do this. The spi struct does not expose any function for this.
SCLK = 18 # Serial-Clock
MOSI = 24 # Master-Out-Slave-In
MISO = 23 # Master-In-Slave-Out
CS = 25 # Chip-Select
Currently, my code looks like this:
func main() {
flag.Parse()
a := raspi.NewAdaptor()
adc := spi.NewMCP3208Driver(a)
work := func() {
gobot.Every(1*time.Second, func() {
for i := 0; i < 8; i++ {
result, err := adc.Read(i)
if err != nil {
fmt.Printf("E: A%d: %v\n", i, err)
return
}
fmt.Printf("--> A%d: %d\n", i, result)
}
})
}
robot := gobot.NewRobot("gtest",
[]gobot.Connection{a},
[]gobot.Device{adc},
work,
)
robot.Start()
}
Any ideas are welcome!
Thank you very much.
Regards,