Raspberry Pi / A-Star I2C Unreliable

I am trying to connect a A-Star 32U4 to a Raspberry Pi using an I2C bus. It sort of works, but isn’t reliable (sometimes messages are transferred successfully, other times they are mangled). Short (12-15 character) ASCII strings are transferred over the I2C bus.

I am using the Raspberry Pi Bridge on the A-Star.

The Raspberry Pi is running Android Things. The A-Star is running custom C code. I think things worked a bit better after I (tried to) enable pull-up resistors on the A-Star:

DDRD &= ~(1 << 0);
DDRD &= ~(1 << 1);
PORTD |= (1 << 0);
PORTD |= (1 << 1);

Thanks for any suggestions you might have.

-tjs

Hello, tjs.

I suspect the issue is due to the Raspberry Pi’s I2C clock-stretching bug, which can prevent communication with some devices or, in this case, corrupt data. You can find more details on the bug and some workaround suggestions here.

If you are using one of our A-Star 32U4 Robot Controllers with Raspberry Pi Bridge, you might find this blog post on how to get the Raspberry Pi and A-Star to communicate over an I2C channel helpful and consider using our Raspberry Pi slave library for Arduino.

- Amanda