Introduction: How to Make a Arduino+Raspberry Pi Robot Platform

Picture of How to Make a Arduino+Raspberry Pi Robot Platform

Ladvien's Lab

UPDATE: Lets Make Robots, my home digital hackerspace, was purchased by RobotShop. I don't want to go into, but the new owners banned myself and most of the veteran members. That stated, most of the links there will be broken. Luckily, I was able to make a copy of my content (the reason they banned me) and moved it to a Github site--it was a hurried move, so the content maybe a little rough right now.

This is not the definitive story on Pi and Arduino orchestration. Just my version.

Step 1: Berryboot

Picture of Berryboot

1. Get Berryboot.  Berryboot will allow you to download several Raspberry Pi images.


Step 2: SD Card Preperation

Picture of SD Card Preperation

Now extract the zip files to a blank SD card.

Step 3: Berryboot

Picture of Berryboot

Put the BerryBoot SD card in your Pi and boot it up.

2. Setup RPi with Raspbian Wheezy (first option).

Step 4: WiFi Dongle

3. Setup your WiFi dongle.  I believe BerryBoot will now setup your WiFi dongle on initial boot, which it did for me (even gave me the option to download the image via WiFi).  But, I had trouble getting my WiFi dongle pulled up after booting Raspbian Wheezy.

If you have difficulty with manual WiFi dongle setup, you might try this video.

Lastly, if you are looking for a WiFi dongle for cheap, with good range, and uses very little mAhs (the Pi can only feed about 700mAhs through the USB port).  You might try this one, $6.17.

Step 5: SSH

Picture of SSH

4. Setup PuTTY on your Desktop Computer.  Follow this video. This will allow you to begin SSHing into the Pi.  That way you don't have to look at a little RCA screen like me.  For those who aren't familiar with SSH (like I was before this video), the video will explain it.  At risk of oversimplification, it allows you to access your Raspberry Pi command line through your desktop.

You have to plug in your Pi's network number.  You can find this by pulling up your wireless hub's configuration page.  You should see what address your Pi is listed at.  For some strange reason, if it doesn't list the device name, just view the page while the Pi is up, then unplug your Pi and refresh the wireless hub configuration page.  The device that disappeared is your Pi.  I've never had to change the port number, but beware you might need to depending on your setup.

Step 6: SSH

Picture of SSH

You have to plug in your Pi's network number.  You can find this by pulling up your wireless hub's configuration page.  You should see what address your Pi is listed at.  For some strange reason, if it doesn't list the device name, just view the page while the Pi is up, then unplug your Pi and refresh the wireless hub configuration page.  The device that disappeared is your Pi.  I've never had to change the port number, but beware you might need to depending on your setup.

If you want to know whether your have the correct information, try login' in and if you get a screen like this, your good.

Your username and password are by default: pi, raspberry

Remember! In the case of a Raspberry Pi, always share your password, 'cause everyone has it anyway :)

Step 7: SSH

Picture of SSH

Once you have PuTTY setup, you should be able to bring up your Pi command line, something like this:

Step 8: VNC

Picture of VNC

5. Setup VNCServer on your Raspberry Pi.  Follow this video. (Or this walkthrough). Putty will let you access your Pi's command line, but setting up a VNC will actually allow you to access your Pi's Desktop GUI from your PC, in the same manner as Putty. 



6. Setup a VNC Client on your Desktop Computer. Real VNC.  There are many different programs, I happened to end up using Real VNC.

Once you have VNC setup on both machines, PuTTY into your Pi and start the VNC server. 

$sudo vncserver

Step 9:

Picture of

Two notes here, if you did better with the video instructions than I did, your vncserver will start automatically on boot.  Unfortunately, I have to type it each time (I'm too lazy to figure out the boot part of it).  As a result, you'll have problems running certain Python scripts through VNC if you don't use $sudo vncserver

You should end up with at a windowed version of your Raspberry Pi desktop.  One more note, somewhere in the video it gets you to setup the "geometry" of the VNC desktop.  The limitations you put there will be reflected in the quality of the desktop you see in the window.  In essence, if you put in 640x480, that's the resolution this desktop will end up.  So, please, take advantage of the Pi's GPU :)

Use something like this, "-geometry 1024x728 -depth 24"

Step 10: SD Card Resize

7.  Resize your SD card to use all its space. (Note, this should already be done by BerryBoot.  But other diskimages will limit your SD card to 2GB, regardless of its actual size).

Step 11: GIT

Picture of GIT

8. Git manager will allow you to pull code from git hubs (again, this should already be installed, but just in case).

Install the git manager: 

At Raspberry Pi prompt:  $sudo apt-get install  git 

The way to use it is like so,

At Raspberry Pi prompt:  $sudo git clone https://github.com/adafruit/Adafruit-Raspberry-Pi-Python-Code.git

Step 12: SMBus

9.  Install SMBus.  This is specifically for my setup, since I'll be using the I2C bus to communicate between the Pi and the Arduino.

At Raspberry Pi prompt:   $sudo apt-get install python-smbus

Step 13: Useful Robot Packages

10. Any other Python modules you might fancy.

Useful for keystroke, GUI, and other interfacing needs:

Pygame (should come with Raspbian). (sudo apt-get install pygame)

Lady Ada's Python codes for an array of I2C sensors:

Adafruit I2C library (git)

Access your Raspberry Pi from iDevice web based GUI:

PiUi (git)

Control serial devices:

pySerial (sudo apt-get install python3-serial)


Step 14: Arduino IDE on Pi

11. (optional) Install Arduino IDE on Raspberry Pi.  This will allow you to program the Arduino directly from your Pi--and if you follow my design, you'll be able to do so without ever leaving your desktop computer.  You can do this by opening the VNC Server, opening the Arduino IDE on the remote desktop, selecting the sketch you want to upload, and as long as your Arduino is connecting by way of USB, you can then upload your sketch from where you sit.  This allows for quick changes to Arduino code without switching wires around. There is a way to upload sketches by way of GPIO pins and this would make a cleaner design, sadly, haven't had time to implement it.

Step 15: WinSCP

Picture of WinSCP

12. Install WinSCP.  This will allow you to transfer files between your desktop and the Pi.  I find this helps with programming management.  I'm a messy filer.  If I file at all.

Step 16: Make an I2c Optoisolator

Picture of Make an I2c Optoisolator

13.  Take a deep breath.



14.  Follow these instructions for making my I2C optoisolator board.

Step 17: I2c Between Pi and Arduino

Picture of I2c Between Pi and Arduino

Again, there are many commercial boards that will serve the same function.  Also, you can do the same with a USB cable, serial pins to GPIO, or RF connection--basically any way that lets the Arduino and Pi talk at a reasonable speed.  The speed restraint will of course depend on your need.  I doubt many methods will be apt for running a responsive quadrocopter.  But in my case, my Pi is the central nervous system and the Arduino is the autonomous nervous system.   The Pi will send directives, but it's up to the Arduino to manifest them through responsive actuators.  And I chose this optoisolator because I didn't want an voltage restraint on my actuators or fear of frying my Pi.

Once you have the board setup, you can run:

$sudo i2cdetect -y -a 1

This should bring up a list of active I2C registers.  You should find your Arduino at whatever address you set in your Arduino code.

Step 18: I2c

Picture of I2c

Now, I've read this fellow's article on how Raspberry Pi I2C pins are actually 5v tolerant.  (Note, this is only for I2C pins, due to their pull-up resistors.)

Step 19: Tie It Up

So in theory, you can skip the optoisolator all together. But that's you, I'll stick with my optoisolation.

15. Download my code--or someone cooler's.

UPDATE: 8-12-13: User Buckleybw has let me know the code I put together is unstable. It'll run for 7-8 minutes before giving an error on Pi (Python) side. Poor guy had to troubleshoot it; this has been confirmed by another builder. As soon as time permits I'll troubleshoot the i2c code. Of course, this can all be done over a serial connection :)

Note, my code is really just the base for a robot. Right now, my it is nothing more than a very, very complex radio controller for a RC car. But someday, I'll make a real robot :)

16. Tweak and gut the code as you see fit.

17. Ask questions: Pretty much everyone on this site is smarter than me, they'll know the answer.


Some other stuff I've done with this platform--

Battery Powered USB Hub
OpenCV on the Pi
(The bot)

Comments

GreenCrackar (author)2017-06-04

I am planning to make something similar myself. However, I am confised as to how you are powering the pi and arduino. Please could you clarify?

xiculan (author)2015-06-21

hello, is there the code for controling the bot by command line? or how do yo do?

thanks

ruhliar (author)2014-09-10

And how to uninstall the arduino software?

immaturespartan (author)2014-05-01

Is the idea just to make a more powerful platform for robots?

Ladvien (author)immaturespartan2014-05-01

Pretty much. It's a bit of a step-up from an Arduino UNO by its lonesome.

buckleybw (author)2013-07-18

Thanks so much for this great get started tutorial! In fact I've followed most of your instructions in a first project of my own and I wanted to let you know I acknowledged your great work. See my project blog. Thanks!

http://pinkypibot.blogspot.com/

Ladvien (author)buckleybw2013-07-19

You're too kind. I apologize these instructions aren't clear, I'm a muddled thinker. I've read through your build, and I have to say, it is documented very well. Could I encourage you to visit letsmakerobots.com and post your build there :)? Those guys (and gal) are awesome

buckleybw (author)Ladvien2013-07-19

Thanks. I'll do that. I have an account but haven't quite figured it out.

About This Instructable

147,233views

166favorites

License:

Bio: I'm a homeless outreach worker in Fort Worth, Texas. I hack away on electronics as a way to deal with the stress; a type ... More »
More by Ladvien:IPhone to Arduino Using Bluetooth 4.0  --UUEncoding in CHEX File to Array in C
Add instructable to: