Simple comms for A-Star 32U4 Robot Controllers with Raspberry Pi Bridge

Bringing an old project back, trying to find a more simple, manual solution to passing data from the Pi to the A-Star and back using the existing I2C command interface.

I have another project where I am running Python commands on the Raspberry Pi to manually drive (using the dual_mc33926_rpi library) and passing data between a A-Star Mini and the Pi over crude USB connection. The A-Star awaits input to move a pan-and-tilt while feeding sensor data back to the Raspberry.

The fantastic documentation I have found, including Paul’s project from 16 February 2016 are too comprehensive and complete… far over my head. I am just looking for any documentation anybody might have at a more simple, granular level regarding sending and receiving data over I2C on both Arduino and Raspberry.

Many thanks in advance!

The blog post by Paul that you mentioned is the main resource we have documenting how to connect an A-Star 32U4 to a Raspberry Pi using I²C. If you want to try getting it working again and you run into a specific problem, we would be happy to help. We do not have any simpler tutorials.

If you want to try doing things a different way, I would suggest that you try using the Wire library on the Arduino side:

However, that library does not allow you to simply read or write data from I2C. You have to call onReceive and onRequest to register two callback functions that run in an interrupt. Here is a tutorial I found but I am really skeptical of calling Serial.println from the callbacks:

On the Raspberry Pi side, I recommend using the i2c-gpio overlay to get around the Raspberry Pi’s I2C clock stretching bug. If you want to program in Python, I recommend the smbus2 library. We have some information about using the i2c-gpio overlay and smbus2, but it is for a different product: see the “Example I²C code for Linux in Python” section of the Tic user’s guide.


1 Like

By the way, there’s a surprise difficulty that you might run into if you try to set up i2c communication without following our tutorial. The AVR i2c module doesn’t support transitions directly from a write to a read, which is commonly used by functions like read_i2c_block_data() in the smbus2 library.

You can look at our Raspberry Pi code to see an example of how to get around that limitation, by separating the write from the read.

1 Like