Page 1 of 1

Arduino and Pi

Posted: Fri Oct 31, 2014 11:07 pm
by jAMDup
Hello!
I was just wondering whether I could use the GPIO pins of the arduino through some python code executed by a Pi. For example some motors.
Thanks!

Re: Arduino and Pi

Posted: Fri Oct 31, 2014 11:34 pm
by DougieLawson
Yes.

Send control signals from the Pi to the Arduino using python's serial interface, send data back from the Arduino using Serial.print() and/or Serial.println().

Re: Arduino and Pi

Posted: Sat Nov 01, 2014 10:25 am
by jAMDup
Thanks!
But how would I connect the arduino and Pi together so that I could use the arduino's GPIO pins? Just by a normal USB cable?

Re: Arduino and Pi

Posted: Sat Nov 01, 2014 10:31 am
by mikerr
Yes you can do it with the USB cable the arduino comes with, nothing else required:

http://blog.oscarliang.net/connect-rasp ... usb-cable/

Re: Arduino and Pi

Posted: Sat Nov 01, 2014 10:33 am
by MrBunsy
You'd need to write some software to run on the arduino and do what you want with the GPIO based on what commands you send over whichever link you go for. You could use the Pi's UART if you didn't want to use USB.

Re: Arduino and Pi

Posted: Sat Nov 01, 2014 10:46 am
by ame
Take a look at "nanpy". It sounds just like what you want.

Re: Arduino and Pi

Posted: Sat Nov 01, 2014 12:35 pm
by B.Goode
For software integration, firmata is a similar solution to nanpy.

For hardware integration, one solution is an addon board for the RPi, such as PiDuino. http://skpang.co.uk/blog/archives/1010

Re: Arduino and Pi

Posted: Sat Nov 01, 2014 12:43 pm
by DougieLawson
B.Goode wrote: For hardware integration, one solution is an addon board for the RPi, such as PiDuino. http://skpang.co.uk/blog/archives/1010
Or Dexter Industries Arduberry https://www.dexterindustries.com/Arduberry/
Note: I've written an article about that for issue #28 of the MagPi magazine.

Re: Arduino and Pi

Posted: Sat Nov 01, 2014 12:48 pm
by pluggy
An alternative to using USB, is to use the Pi's GPIO serial TX/RX to the Arduino's RX/TX communicating via ttyAMA0. You need a voltage divider on the Arduino's 5v output to stop it damaging the Pi's 3.3v input, but the other connections are direct. In this case you don't need a full Arduino, you can just use the easily obtainable chip on a DIY circuit board. Ideal for a Pi 'A' (if you can still get one) when you're using the 1 USB port for communication with the outside world (eg Wifi adaptor) and you don't want the expense/ extra power load of a USB hub.

Re: Arduino and Pi

Posted: Sat Nov 01, 2014 1:04 pm
by DougieLawson
pluggy wrote: You need a voltage divider on the Arduino's 5v output to stop it damaging the Pi's 3.3v input, but the other connections are direct.
Only if you're running your Arduino at 5V0. You can run them at 3V3.

Re: Arduino and Pi

Posted: Sat Nov 01, 2014 1:42 pm
by pluggy
DougieLawson wrote:
B.Goode wrote: For hardware integration, one solution is an addon board for the RPi, such as PiDuino. http://skpang.co.uk/blog/archives/1010
Or Dexter Industries Arduberry https://www.dexterindustries.com/Arduberry/
Note: I've written an article about that for issue #28 of the MagPi magazine.
I was getting excited by the Piduino until I discovered it uses the 3.3V version of the Atmega chip. 5v is so much more friendly.....

Re: Arduino and Pi

Posted: Sat Nov 01, 2014 1:43 pm
by pluggy
DougieLawson wrote:
pluggy wrote: You need a voltage divider on the Arduino's 5v output to stop it damaging the Pi's 3.3v input, but the other connections are direct.
Only if you're running your Arduino at 5V0. You can run them at 3V3.
To me it defeats the whole point of having an Arduino. I use them because some of what I do is very difficult at 3.3 V. Border line photo-transistor circuits.... getting a 2.5v trigger point to fire reliably in a sea of noise is so much easier than 1.65 v.