StereoPi and Arduino I2C

StereoPi hardware discussion
Post Reply
Posts: 5
Joined: Thu Dec 05, 2019 5:22 am

StereoPi and Arduino I2C

Post by angelyn.mercado »


I'm trying to send data to Arduino from StereoPi through Serial connection and then send it through Arduino's I2C but for some reason I can't make it work.

Basically the workflow is:
Pi data --(serial)--> Arduino --(I2C)--> receiver

I was able to make it work when the Arduino is connected to my laptop. But then, when I connected it to StereoPi, no data is sent. Are there any limitations in the functionality of the USB/ USB driver in StereoPi that hinders me to send data through Arduino?


Posts: 5
Joined: Thu Dec 05, 2019 5:22 am

Re: StereoPi and Arduino I2C

Post by angelyn.mercado »

Figured it out. Was missing external power on Arduino. Supplied extra 5V to the board and it's now working.

Posts: 164
Joined: Tue May 21, 2019 12:33 pm
Location: France

Re: StereoPi and Arduino I2C

Post by stereomaton »

You solved it while I wrote an answer. I post it nonetheless because some people reading your topic in the future might find it useful.

That said, I am a bit confused.
If you used the USB-serial interface (as I supposed in my answer) the 5V power should already be provided.
If you use actual hardware serial, beware that it does not support 5V logic. Using only stereopi TX is kinda safe as only 3V3 logic is emitted and Arduino is able to read it, but do not connect the other line(s).


I was about to comment that serial has its own lines separated from USB, but I just realised that the Arduino has an embedded serial-USB converter that you didn't mention explicitly and is probably the one that you tried to use.

If you effectively want to access the USB-serial interface of the Arduino and not the bare serial one as you suggested in your schematic, it behaves as a regular USB-serial interface in Linux.
In particular it will create a device node (typically /dev/ttyUSB0 or /dev/ttyACM0) through which you can access to the bus. Notice that you should have the rights to access this node (check permissions affected to the node and the groups your user is in) and that you should configure the tty (baudrate, stop bits, byte size, stream control and so on including the special high level [not strictly serial] parts such as disabling tty local echo or special characters)
Also notice that end-of-line characters are usually LF in Linux and CR+LF in Windows which might create conflicts depending on your serial protocol.

I would suggest to test your bare communication through USB-serial in the first place. Your example:
1. Upload a sketch (in Arduino) that sends incrementing numbers automatically and check you can receive it (reception is easier) with a dedicated serial program (gtkterm and putty are graphical programs that I think of) and with your targeted programming interface
2. Upload a sketch that repeat every character it receives + 1. The increment is to avoid confusion with a possible local echo. Again check with dedicated serial tool and intended final interface.
3. Only when the first two are validated, start to check protocol possible issues like end-of-line characters.

Finally, notice that if your sensor supports 3V I2C, you have the option to connect it to the I2C bus of the stereopi without passing through an Arduino. Depending on your application it might be relevant. On the other hand, since you already have a working setup, it might also be relevant to use it with its USB-serial interface.
Stereophotographer and hacker
Despite my quite active participation in the forum, I am not in the StereoPi team
StereoPi Standard Edition + CM3Lite module + a few cameras

User avatar
Site Admin
Posts: 548
Joined: Tue Apr 16, 2019 9:23 am

Re: StereoPi and Arduino I2C

Post by Realizator »

Wow, Stereomaton, thank you for your detailed answer!
Angelyn.mercado, I'm glad you've solved your problem!
My two cents: in our practice the most frequent UART connection problem was different grounds of RPi and Arduino (or APM/Pixhaxk devices).
Eugene a.k.a. Realizator

Post Reply