DEV Community

Cover image for Blueberry Pi -- How I Setup My Raspberry Pi as a Robot Base
Thomas Brittain
Thomas Brittain

Posted on • Originally published at ladvien.com

Blueberry Pi -- How I Setup My Raspberry Pi as a Robot Base

This article is specific: How I personally would setup my Raspberry Pi to act as robot base. But, I'll be clear, this is one of nth possible setups. A chessboard has 64 squares but those working the board allow for innumerable possibilities.

That aside, here we go:

Get Berryboot

Berryboot will allow you to download several Raspberry Pi images.

Now extract the zip files to a blank SD card.

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

Setup RPi

Setup RPi with Raspbian Wheezy (first option).

Setup your WiFi

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.

Setup your PuTTY

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.

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

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

Setup VNCServer

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.

Setup VNC Client

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
Enter fullscreen mode Exit fullscreen mode

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'll enter your Pi address, but port should be 1 (if I remember the video instructions correctly).

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

Resize SD Card

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).

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
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

SMBus

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
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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

Adafruit I2C library

Access your Raspberry Pi from iDevice web based GUI:

PiUi

Control serial devices:

pySerial

sudo apt-get install python3-pyserial
Enter fullscreen mode Exit fullscreen mode

Install Arduino IDE (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. Also, I think Kariloy is looking for a way to upload sketches by way of GPIO pins. This would make a cleaner design.

Install WinSCP

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.

I2C Galvanicisolator

Follow these instructions for making my I2C galvanicisolator board.

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
Enter fullscreen mode Exit fullscreen mode

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

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.)

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

Grab the Code

Download my code--or someone cooler's.

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

Yell

Just yell at me if anything is off. Or I may assist.

Top comments (0)