try query MCP3208

14 views
Skip to first unread message

Thorsten Sauter

unread,
Jun 3, 2018, 7:34:23 AM6/3/18
to gobotio
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,

Ron Evans

unread,
Jun 4, 2018, 5:45:14 AM6/4/18
to gobotio
Hi, there


It seems like there might be an incompatibility with the protocol used by this chip and the associated Gobot code, but I do not have one of the MCP3208 right at the moment for testing.
Reply all
Reply to author
Forward
0 new messages