Page 1 of 1

Re: Pi and Arduino

Posted: Mon Apr 30, 2012 4:04 pm
by Si.
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

Re: Pi and Arduino

Posted: Mon Apr 30, 2012 4:49 pm
by MrBunsy
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.

Re: Pi and Arduino

Posted: Mon Apr 30, 2012 4:49 pm
by jbeale
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.

Re: Pi and Arduino

Posted: Mon Apr 30, 2012 4:50 pm
by rmm200
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.

Re: Pi and Arduino

Posted: Mon Apr 30, 2012 6:18 pm
by VBT
Thanks for the great article. Got me thinking now that I could include the Pi in my project once it arrives.

Re: Pi and Arduino

Posted: Mon Apr 30, 2012 6:47 pm
by buckett
This looks great, I'm wanting to do something similar. How would serial-serial differ?

Re: Pi and Arduino

Posted: Mon Apr 30, 2012 6:55 pm
by rmm200
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.

Re: Pi and Arduino

Posted: Mon Apr 30, 2012 7:05 pm
by mjtessmer
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.

Re: Pi and Arduino

Posted: 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

Re: Pi and Arduino

Posted: Mon Apr 30, 2012 7:44 pm
by rmm200
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).

Re: Pi and Arduino

Posted: 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

Re: Pi and Arduino

Posted: Tue May 01, 2012 11:06 am
by HeadCase
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.

Re: Pi and Arduino

Posted: Tue May 01, 2012 12:21 pm
by jamieoliver22
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!

Re: Pi and Arduino

Posted: Tue May 01, 2012 1:17 pm
by JoeDaStudd
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.

Re: Pi and Arduino

Posted: Tue May 01, 2012 2:30 pm
by GizmoB73
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.


Re: Pi and Arduino

Posted: Tue May 01, 2012 2:57 pm
by jbeale
Sorry to drift off-topic, but that "A79GW" DC-DC level converter with LCD display looks really neat! Does it measure current as well?

Re: Pi and Arduino

Posted: Tue May 01, 2012 3:13 pm
by GizmoB73
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.

Re: Pi and Arduino

Posted: 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

Re: Pi and Arduino

Posted: Tue May 01, 2012 4:31 pm
by GizmoB73
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.

Re: Pi and Arduino

Posted: Fri May 11, 2012 8:45 pm
by Si.
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.

Re: Pi and Arduino

Posted: Sat May 12, 2012 12:45 am
by Jim Manley
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?

Re: Pi and Arduino

Posted: Sat May 12, 2012 7:03 am
by Si.
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.

Re: Pi and Arduino

Posted: Sun May 20, 2012 10:10 pm
by Gert van Loo
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.

Re: Pi and Arduino

Posted: Thu May 24, 2012 11:58 am
by GadgetUK
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.

Re: Pi and Arduino

Posted: Wed May 30, 2012 11:52 pm
by TankSlappa
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