Page 1 of 1

Interfacing Raspberry Pi with Arduino and power safety

Posted: Mon Nov 07, 2016 3:10 pm
by jorrit
Hi, not sure if this is the right board but I think it is so let's go for it.

Basically I have a raspberry pi (3) and two Arduino's. The Arduino's are currently each connected with an USB cable (so the arduino's are getting power from the raspberry pi). A Java program runs on the pi using the RXTX library to drive both arduino's and this works perfectly (after some tweaking here and there).

However, at some point I'm going to need a direct connection from one of the Arduino's to the pi to measure an audio signal (a bit like a digital oscilloscope). I know one has to be careful when doing that kind of direct connection due to power issues but is this also the case if the arduino's are powered (through USB) directly from the pi anyway? What's the easiest way to set this up?

Additionally how would I read out such a signal directly from java? What kind of library can I use for that?

Thanks for any advice.

Re: Interfacing Raspberry Pi with Arduino and power safety

Posted: Wed Nov 09, 2016 7:56 pm
by jorrit
Nobody knows? Or is this the wrong place to ask?

Re: Interfacing Raspberry Pi with Arduino and power safety

Posted: Wed Nov 09, 2016 8:23 pm
by mikronauts
By far the easiest is to keep using the USB/serial link that exists.

It is also the fastest.
jorrit wrote:Hi, not sure if this is the right board but I think it is so let's go for it.

Basically I have a raspberry pi (3) and two Arduino's. The Arduino's are currently each connected with an USB cable (so the arduino's are getting power from the raspberry pi). A Java program runs on the pi using the RXTX library to drive both arduino's and this works perfectly (after some tweaking here and there).

However, at some point I'm going to need a direct connection from one of the Arduino's to the pi to measure an audio signal (a bit like a digital oscilloscope). I know one has to be careful when doing that kind of direct connection due to power issues but is this also the case if the arduino's are powered (through USB) directly from the pi anyway? What's the easiest way to set this up?

Additionally how would I read out such a signal directly from java? What kind of library can I use for that?

Thanks for any advice.

Re: Interfacing Raspberry Pi with Arduino and power safety

Posted: Fri Nov 11, 2016 9:53 am
by jorrit
mikronauts wrote:By far the easiest is to keep using the USB/serial link that exists.

It is also the fastest.
That's interesting. How fast can I actually go with this? I'm used to doing Serial.begin(9600) in the Arduino code. How fast can I go with this?

Re: Interfacing Raspberry Pi with Arduino and power safety

Posted: Sun Nov 13, 2016 12:47 am
by richrarobi
I don't think it is totally a good idea to power your arduino's from the pi - if you start driving things off th arduino's the power drain will mount up. You should consider separate power direct to the power ports of those arduino boards. Maybe a powered usb hub would be enough to isolate the pi ?
I haven't used the arduino on the pi for a while, but I didn't like the way the things passed power through the usb port, especially when servos started moving and using power. If I remember correctly, I used the serial pins on the gpio, and a level shifter circuit to keep the 3.3volts away from the 5v, with a 9v power adapter into the barrel connector

I think the serial via gpio port goes up to 19,200 maybe more - from dim memory

There is a thread about this under arduino and nanpy.

Re: Interfacing Raspberry Pi with Arduino and power safety

Posted: Sun Nov 13, 2016 6:57 am
by jorrit
Well I have a good power supply for the PI and the Arduino's are not taking that much power I thought. Not doing any moving parts or such. Just sensors and audio output for a single loudspeaker.

Re: Interfacing Raspberry Pi with Arduino and power safety

Posted: Sun Nov 13, 2016 7:08 am
by Major Tom
The only problem you are likely to have is if you connect an Arduino pin configured as an output to the Raspberry Pi GPIO. But only if you have a 5V Arduino (which I suppose most of them are).

You shouldn't drive the Pi GPIO input with a voltage greater than 3.3V as you will damage the I/O pin circuitry on the chip. If you want to connect a 5V signal to the Pi input then use a simple voltage divider (for slow-moving signals) or a level shifter (for faster signals) to convert the 5V to 3.3V.

Re: Interfacing Raspberry Pi with Arduino and power safety

Posted: Sun Nov 13, 2016 7:29 am
by jorrit
Well for now I'm only using USB connections (so serial) and no other connections between the Pi and the two arduino's. I want to keep it like that since that also makes it easier to prototype my java program on a normal laptop