Si.
Posts: 24
Joined: Mon Apr 30, 2012 2:53 pm
Contact: Website

Re: Pi and Arduino

Mon Apr 30, 2012 4:04 pm

I have just got my Pi talking to an Arduino over USB using Python.

Full instructions on my blog here:

http://www.doctormonk.com/2012.....duino.html

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

Re: Pi and Arduino

Mon Apr 30, 2012 4:49 pm

Have you considered using the Pi's UART instead?  Would leave the USB ports free for even more stuff - like connecting the PI+AVR to a PC.

User avatar
jbeale
Posts: 3441
Joined: Tue Nov 22, 2011 11:51 pm
Contact: Website

Re: Pi and Arduino

Mon Apr 30, 2012 4:49 pm

Thanks for a clear an well-written article on Pi-Arduino interfacing!

As far as I can tell, you are using the USB link as a virtual serial port from both ends. You write "I suspect the FTDI generation Arduinos before the Uno may have trouble with USB" but I'm not sure why. I would expect it to work exactly the same way.

rmm200
Posts: 259
Joined: Sat Mar 03, 2012 10:25 pm

Re: Pi and Arduino

Mon Apr 30, 2012 4:50 pm

I plan on hooking my Pi up to my Arduino using serial - serial; but good to see USB works too. Makes sense - I use USB to program the Arduino.

User avatar
VBT
Posts: 21
Joined: Sat Mar 10, 2012 12:33 am
Contact: Website

Re: Pi and Arduino

Mon Apr 30, 2012 6:18 pm

Thanks for the great article. Got me thinking now that I could include the Pi in my project once it arrives.

buckett
Posts: 9
Joined: Fri Apr 20, 2012 8:49 pm

Re: Pi and Arduino

Mon Apr 30, 2012 6:47 pm

This looks great, I'm wanting to do something similar. How would serial-serial differ?

rmm200
Posts: 259
Joined: Sat Mar 03, 2012 10:25 pm

Re: Pi and Arduino

Mon Apr 30, 2012 6:55 pm

Three additional wires from Pi to Arduino (gnd, Snd, Rcv). I don't think level shifting required - this is not RS232. Different drivers on each end; should be transparent to user. Different device IDs.

mjtessmer
Posts: 27
Joined: Sun Nov 20, 2011 12:50 am

Re: Pi and Arduino

Mon Apr 30, 2012 7:05 pm

rmm200 said:


Three additional wires from Pi to Arduino (gnd, Snd, Rcv). I don't think level shifting required - this is not RS232. Different drivers on each end; should be transparent to user. Different device IDs.



The standard Arduino's serial port is 0-5v, the RPi's serial port on

the GPIO connector is 0-3v3; and is not 5v tolerant.  You would

need a voltage level translator between the Arduino and RPi.

User avatar
gordon@drogon.net
Posts: 2020
Joined: Tue Feb 07, 2012 2:14 pm
Location: Devon, UK
Contact: Website

Re: Pi and Arduino

Mon Apr 30, 2012 7:17 pm

Si. said:


I have just got my Pi talking to an Arduino over USB using Python.

Full instructions on my blog here:

http://www.doctormonk.com/2012.....duino.html



Looks good!

I've been doing work on this myself, but don't have a Python driver for my stuff, however what I'm doing is extending the Arduino "Wiring" stuff back to anything really (ie. any Linux box or anything else that can talk rs232).

Maybe someone can write a Python interface for it.. (Maybe I will, but Python isn't my thing yet)

My stuff is here: https://projects.drogon.net/drogon-remote-control/ and a picture of it working (from BASIC):



So the program running on the Pi there is sending commands down the USB serial line to set bits, and read inputs (analog and digital) and just put the results up on the screen.

Gordon
--
Gordons projects: https://projects.drogon.net/

rmm200
Posts: 259
Joined: Sat Mar 03, 2012 10:25 pm

Re: Pi and Arduino

Mon Apr 30, 2012 7:44 pm

mjtessmer said:


rmm200 said:


Three additional wires from Pi to Arduino (gnd, Snd, Rcv). I don't think level shifting required - this is not RS232. Different drivers on each end; should be transparent to user. Different device IDs.


The standard Arduino's serial port is 0-5v, the RPi's serial port on

the GPIO connector is 0-3v3; and is not 5v tolerant.  You would

need a voltage level translator between the Arduino and RPi.



Looks like two resistors on the Arduino transmit line, to divide it down to 3V should be enough. The Pi transmit line should be high enough to keep the Arduino TTL happy (.6 * VCC).

User avatar
gordon@drogon.net
Posts: 2020
Joined: Tue Feb 07, 2012 2:14 pm
Location: Devon, UK
Contact: Website

Re: Pi and Arduino

Mon Apr 30, 2012 7:54 pm

jbeale said:


Thanks for a clear an well-written article on Pi-Arduino interfacing!

As far as I can tell, you are using the USB link as a virtual serial port from both ends. You write "I suspect the FTDI generation Arduinos before the Uno may have trouble with USB" but I'm not sure why. I would expect it to work exactly the same way.



I have a couple of early ones - a 2009 and a clone. No issues at all. I run all mine at 115200 baud - and they "just work".

Gordon
--
Gordons projects: https://projects.drogon.net/

HeadCase
Posts: 50
Joined: Sat Sep 03, 2011 8:11 am

Re: Pi and Arduino

Tue May 01, 2012 11:06 am

jbeale said:


Thanks for a clear an well-written article on Pi-Arduino interfacing!

As far as I can tell, you are using the USB link as a virtual serial port from both ends. You write "I suspect the FTDI generation Arduinos before the Uno may have trouble with USB" but I'm not sure why. I would expect it to work exactly the same way.


I can confirm that the Debian distro RPi recognizes an FTDI FT245RL device connected to the USB port and communicates using a terminal program. As yet I can't say what the cpu load is at high transfer rates, but at slow speeds it it just worked out of the box.

jamieoliver22
Posts: 22
Joined: Sat Mar 03, 2012 2:19 am

Re: Pi and Arduino

Tue May 01, 2012 12:21 pm

This is exactly what I intend to do when I've got chance, I want to link my Arduino and Raspberry Pi togther to provide a fully automated system with a suitable controller interface.

Many thanks for posting!

JoeDaStudd
Posts: 274
Joined: Fri Jan 27, 2012 1:34 pm

Re: Pi and Arduino

Tue May 01, 2012 1:17 pm

Excellent. I knew they should work together, but its always nice to get a confirmation.

Good job too as I brought £40's worth of Arduino parts just for my soon to be delivered RasPi.

GizmoB73
Posts: 80
Joined: Fri Jan 27, 2012 12:51 pm

Re: Pi and Arduino

Tue May 01, 2012 2:30 pm

I have my Pi hooked up to my Arduino via the UART on both boards.

I used this exact level converter (I actually got mine from ebay but they have sold out now):

http://www.sparkfun.com/products/8745

I probably could have done it with a couple of resistors but at this price I didn't think it was worth the hassle.

Excuse the spaghetti wiring in the background but this is what it looks like.


User avatar
jbeale
Posts: 3441
Joined: Tue Nov 22, 2011 11:51 pm
Contact: Website

Re: Pi and Arduino

Tue May 01, 2012 2:57 pm

Sorry to drift off-topic, but that "A79GW" DC-DC level converter with LCD display looks really neat! Does it measure current as well?

GizmoB73
Posts: 80
Joined: Fri Jan 27, 2012 12:51 pm

Re: Pi and Arduino

Tue May 01, 2012 3:13 pm

It can supply up to 3 Amps and gives a bar chart showing how close you are getting to the 3 Amp limit.  It doesn't give a specific current reading, but that would be really nice.

I just used this because I needed a solid 5v supply under load and I had this going spare from an old project.

User avatar
gordon@drogon.net
Posts: 2020
Joined: Tue Feb 07, 2012 2:14 pm
Location: Devon, UK
Contact: Website

Re: Pi and Arduino

Tue May 01, 2012 3:51 pm

GizmoB73 said:


Excuse the spaghetti wiring in the background but this is what it looks like.


Fantasic! Love the tupperware case for it too!

I've just gotten an SKPANG case for mine - however (doh!) forgot to order their little breadboard to go with it. Wish they made that more clear on their website!

Gordon
--
Gordons projects: https://projects.drogon.net/

GizmoB73
Posts: 80
Joined: Fri Jan 27, 2012 12:51 pm

Re: Pi and Arduino

Tue May 01, 2012 4:31 pm

GordonH said:

Fantasic! Love the tupperware case for it too!
I've just gotten an SKPANG case for mine - however (doh!) forgot to order their little breadboard to go with it. Wish they made that more clear on their website!

Gordon


It's just an old business card box, I couldn't decide what I wanted at first and still not sure, but I have ordered one of these for now:

http://www.ebay.co.uk/itm/1108.....26_rdc%3D1

That is the Slice-Of-Pi addon board.  Pretty simple, think I will solder the level converter onto it to tidy the wiring up a bit.

Si.
Posts: 24
Joined: Mon Apr 30, 2012 2:53 pm
Contact: Website

Re: Pi and Arduino

Fri May 11, 2012 8:45 pm

Just wanted to say thanks for all the positive comments about the original post and if anyone is at the Bay Area Maker Faire next week, I'll be talking about Arduino in the Maker Shed on Sat at 7:30.

I'll have my Pi there too and if I can sort out the AV I'll give a quick demo of Pi talking to Arduino.

I'll also be around the McGraw-Hill stand a fair bit if anyone wants to say hi.

User avatar
Jim Manley
Posts: 1600
Joined: Thu Feb 23, 2012 8:41 pm
Location: SillyCon Valley, California, and Powell, Wyoming, USA, plus The Universe
Contact: Website

Re: Pi and Arduino

Sat May 12, 2012 12:45 am

I will also be at the Bay Area Maker Faire Saturday afternoon (19 May) and most of Sunday (20 May) until closing representing the Computer History Museum in Mountain View (1401 N. Shoreline Blvd., the North exit off U.S. 101, about 17 miles South of the Faire venue in San Mateo). If we Pi-sters don"t coordinate otherwise, I"ll be at Eben"s talk at 1 PM Saturday at the Center Stage and I will have an operating Pi in mobile mode complete with a portable display (batteries _will_ be included! ). I also have an Arduino board and I will try to have a Pi-duino demonstration where the Pi will serve as a download host for the Arduino, as well as maybe demonstrating direct-control integration.

Anyone want to coordinate for lunch/dinner either day?
The best things in life aren't things ... but, a Pi comes pretty darned close! :D
"Education is not the filling of a pail, but the lighting of a fire." -- W.B. Yeats
In theory, theory & practice are the same - in practice, they aren't!!!

Si.
Posts: 24
Joined: Mon Apr 30, 2012 2:53 pm
Contact: Website

Re: Pi and Arduino

Sat May 12, 2012 7:03 am

Great! I would love to meet up. I also hope to get out and see your museum some time while I'm over.

Maybe we should just try and meet up after Eben's talk. If its nice, then Pi / Arduino folk could just find somewhere at the venue to eat?

Si.

User avatar
Gert van Loo
Posts: 2482
Joined: Tue Aug 02, 2011 7:27 am
Contact: Website

Re: Pi and Arduino

Sun May 20, 2012 10:10 pm

The Gertboard has an Atmel chip which can be connected direct to the Raspberry-Pi UART port with two jumpers. On my board it runs of 3V3 hence I limited the operating frequency to 12 MHz. I have exchanged data over the UART between the two.
Next step is to have an Atmel development environment running in the Raspberry-Pi. I have no time for that so I am looking for an Arduino expert to give a Gertboard to who gets the system running. Ideally using the standard boot loader (but tweaked the get the baudrate adapted to 12 MHz)
I'll be honest: I have only three assembled rev-3 boards at them moment so I am looking for a dedicated developer who can really spend some time on it.

GadgetUK
Posts: 61
Joined: Thu Jan 19, 2012 6:02 pm

Re: Pi and Arduino

Thu May 24, 2012 11:58 am

Gert,

I've got the ArduinoIDE working on the Pi using a USB connection, details here

http://raspberrypi.homelabs.org.uk/rasp ... ment-tool/

If you have a gertboard available, I'd be willing to test to see if it works. I've got details of changes required to support 12MHz, although dropping to 8MHz is easier as there are already arduino's running at 3.3v with an 8MHz clock.

TankSlappa
Posts: 18
Joined: Wed May 30, 2012 11:38 pm

Re: Pi and Arduino

Wed May 30, 2012 11:52 pm

I planning a similar hook-up when my Pi has been baked and posted.

The ATmega will be acting as a I/O pre-processor for the Pi, doing all the background stuff, and also acting as a firewall in the even something goes *phut*. ATmega328 is far cheaper and easier to replace than an ARM!

Hopefully it will also be able to put the Pi to sleep and wake it up if something interesting happens it should be told about.

On the subject of voltages, the ATmega328p will happily run on 3.3v, even at 16Mhz. Officially this is out of spec, but I've got several boards which confirm there isn't a problem, and the ATmega328p based JeeNode boards are all run at 3.3v and 16Mhz.

Running at 3.3v gives you access to other fun things, such as the RFM12B radio module and a host of I2C toys.

- Yes Soren, I'm watching you SPI based RFM12B thread ;-)
http://www.raspberrypi.org/phpBB3/viewt ... f=9&t=3404

Return to “Interfacing (DSI, CSI, I2C, etc.)”