jAMDup
Posts: 2
Joined: Fri Oct 31, 2014 11:03 pm

Arduino and Pi

Fri Oct 31, 2014 11:07 pm

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!

User avatar
DougieLawson
Posts: 36516
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: Arduino and Pi

Fri Oct 31, 2014 11:34 pm

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().
Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

jAMDup
Posts: 2
Joined: Fri Oct 31, 2014 11:03 pm

Re: Arduino and Pi

Sat Nov 01, 2014 10:25 am

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?

mikerr
Posts: 2783
Joined: Thu Jan 12, 2012 12:46 pm
Location: UK
Contact: Website

Re: Arduino and Pi

Sat Nov 01, 2014 10:31 am

Yes you can do it with the USB cable the arduino comes with, nothing else required:

http://blog.oscarliang.net/connect-rasp ... usb-cable/
Last edited by mikerr on Sat Nov 01, 2014 1:53 pm, edited 1 time in total.
Android app - Raspi Card Imager - download and image SD cards - No PC required !

User avatar
MrBunsy
Posts: 185
Joined: Mon Feb 20, 2012 1:48 pm
Location: Southampton, UK
Contact: Website

Re: Arduino and Pi

Sat Nov 01, 2014 10:33 am

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.

ame
Posts: 3172
Joined: Sat Aug 18, 2012 1:21 am
Location: Korea

Re: Arduino and Pi

Sat Nov 01, 2014 10:46 am

Take a look at "nanpy". It sounds just like what you want.

User avatar
B.Goode
Posts: 8987
Joined: Mon Sep 01, 2014 4:03 pm
Location: UK

Re: Arduino and Pi

Sat Nov 01, 2014 12:35 pm

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

User avatar
DougieLawson
Posts: 36516
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: Arduino and Pi

Sat Nov 01, 2014 12:43 pm

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.
Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

User avatar
pluggy
Posts: 3635
Joined: Thu May 31, 2012 3:52 pm
Location: Barnoldswick, Lancashire,UK
Contact: Website

Re: Arduino and Pi

Sat Nov 01, 2014 12:48 pm

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.
Don't judge Linux by the Pi.......
I must not tread on too many sacred cows......

User avatar
DougieLawson
Posts: 36516
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: Arduino and Pi

Sat Nov 01, 2014 1:04 pm

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.
Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

User avatar
pluggy
Posts: 3635
Joined: Thu May 31, 2012 3:52 pm
Location: Barnoldswick, Lancashire,UK
Contact: Website

Re: Arduino and Pi

Sat Nov 01, 2014 1:42 pm

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.....
Don't judge Linux by the Pi.......
I must not tread on too many sacred cows......

User avatar
pluggy
Posts: 3635
Joined: Thu May 31, 2012 3:52 pm
Location: Barnoldswick, Lancashire,UK
Contact: Website

Re: Arduino and Pi

Sat Nov 01, 2014 1:43 pm

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.
Don't judge Linux by the Pi.......
I must not tread on too many sacred cows......

Return to “General discussion”