Introduction: "ArdiPi" Wireless Arduino and R-Pi Rover

"ArdiPi" The Wireless Arduino and Raspberry Pi Rover

By: Greg

So basically let me tell you how this project works. You simply have an Arduino (Uno or Leonardo) which you use to connect to two motors and control them. Then you have a RaspberryPi which is controlled by your iPhone, iPad or computer. The RaspberryPi sends data from your device to the Arduino telling it what to do. 

#################################################################


MY ASSUMPTION:                                         

----For this project I am assuming that you are somewhat familiar with RaspberryPi and Arduino.
-------------What I mean is that your RaspberryPi is already setup and ready to use (with ssh enabled) and you have a computer to connect to it with and that you have a wireless connection setup with your Pi and your router (this will enable you to control the whole rover)
----------------I am also assuming that you have coded before with Arduino's, so you will be able to understand much of what the code will do
------------Adafruit motor library installed on Arduino IDE to control motors
--------I also assume you have plenty of time on your hands (about one day)
----------------I also assume that you have assembled the chassis to mount everything on
#################################################################

Materials:

-Beginner Bot Chasis (to mount everything on) you can find it here ---->  http://www.robotshop.com/2wd-beginner-robot-chassis.html    
-An Arduino (UNO) WARNING: The Leonardo will NOT work for this project because it has different timers compared to the Uno which renders the motor shield useless!!
-Adafruit Motor Shield (that's what I used)
-Duct tape or electrical tape
-A Raspberry Pi
- A wifi dongle (for the pi)
- 3 battery packs (two 4battery packs, and one 5/6battery pack)
-Soldering iron (with solder)
- A button/switch (to control power going to the Pi)
-A Voltage meter (optional)
-2 motors
-Code for the Arduino (will be supplied by me)
-Python script to run Telnet communication to Serial communication (will be supplied by me)
-A computer running Putty or an iPhone running the eTelnet app (free app) (iPhone is optional if you have a computer)
-Batteries
-Wires (to wire everything up) I use the wires that have the little ends(their like little pins) on them to make life easy (we will be modding some of them, so buy at least 10 of the wires)
-HOT GLUE (this would be ideal because then you wouldn't have to use a bunch of tape like me to hold things down on the rover)
-DC adapter (to plug into Arduino)


Step 1: Get the Code

You wan't to begin by getting the code on your RaspberryPi and Arduino, so you don't have to deal with them later.

Below I have a zip file of the Arduino Code, and open it up for later use

I also have attached the Python script to used to handle the incoming Telnet connection to your Pi, it will transfer the code to Serial data for your Arduino to use. To put it on your Pi, you can get a USB and transfer the file over, or you can download it from your Pi browser or use the FileZIlla application and transfer files through ssh (really easy).

You will need to edit the Arduino code later on to suit your rover

Read the comments in the Arduino Code carefully to understand how to use it

The connect.py file below uses special commands that I will show you how to use in the later steps so that you can connect to your Arduino from your RaspberryPi

Step 2: Powering the Arduino

To start you are going to need to power your entire project, and to do this wirelessly you will have to use batteries. This is where the chassis mentioned in the parts list comes in handy. You see, it has 2 levels. We will use the bottom level to hold the battery packs (the two packs that hold 4 batteries).

This part will not require the use of the RaspberryPi because you are simply going to setup the motors and get them working.

The way the power will be distributed is by wiring up the two battery packs in series and then soldering the two ends left over to the DC adapter head that you will plug into your Arduino. In between the connection of the power to the Arduino you will need to connect a switch or button to stop the flow of power, so you can control when the Arduino turn's on and off. Yes, you are putting in 11V's to the Arduino, but it's max voltage input is 20V, so your alright. The voltage is to simply run the motors well. 

Below I have a simple schematic of how the setup will look. The two battery packs are really not supposed to have two batteries in each. In our case you will need four batteries in each battery pack.

In the photo below of my rover setup here is the wire lineup:

YELLOW: Connects the Positive and Negative leads of the two battery packs
BLACK: Connects the ground lead of one of the battery packs
RED: Connects the power of one of the battery packs
SWITCH: Controls current flow to power on Arduino
PLUG: To plug into the arduino

Step 3: Wiring the Arduino + Batteries + Motors

Next you will have to connect the motors to the Adafruit motor shield. I will say that all you have to do is unscrew the screws on the terminals for power and plug your motors into the ports labeled M1 and M2. These ports are the ones that will work to power the motor's properly. Try to keep the wires under the top level of the chassis to make the bot look neater on top and take up less space. 

When you screw on the first layer (the platform that will hold the Arduino and Pi) you will need to have all the wires from the batteries under the "hood" of the rover, you will have to conceal the wires alongside the batteries and make sure they don't tangle up with motors. But you also need to be sure to have the push button sticking out along with the power wire for the Arduino. 

After you put the plate over the batteries you will need to find a comfortable place for your Arduino to sit, because we want it to take up the least amount of space as possible. Once you find a good spot for it, wire in the motors.

MOTOR WIRING: When you wire the motors make sure you plug them into the correct ports of the motor shield. It is also recommended to hide the wiring under the top level of the rover to make everything look neat.

The photos below show you the wiring, make sure to follow how the connections are made in the motor shield pictured below.

Now, I noticed that the bottom deck of the rover left a lot of open space, so I decided to use black electrical tape to style the open area and protect it when the rover is in motion.

Step 4: Testing (playing) With the Arduino and Motors

So, once you have the batteries set and the motors plugged into the Arduino, you will now need to test (or as I consider "play") with the code and try to get the speeds and delays in the code just right for the rover. 

REMEMBER: Only change the values of items, and not wording because if not you might mess something up.

You should also be sure to make the program fit you, not you fit the program. If you like the code the way it is test it out by calling to some of the voids in the loop to make sure they work.

WARNING: Using the voids to tell the robot where to go, may cause different things to happen, like the robot crashing into walls or objects, make sure to have a kill switch (the one you soldered on before) so you don't break the chassis. 

To control movement you will need to send commands through the serial monitor.

Below is a video of me testing the movement of the rover:


WATCH IT!

Step 5: Make the Power Source for the RaspberryPi

Next, to power the Raspberry Pi you are going to need 4 batteries (~6V). To power the Pi I chose to get a 9V battery clip that holds 6 AA batteries. I took out two and ran a wire in their places to keep the power at a lower voltage so I don't fry the RaspberryPi. The convenience of this is that you can get a 9V battery clip and wire it to the RaspberryPi's GPIO power and ground pins.

Above are photos of how to wire it all and which pins to use for GRND and PWR.

Step 6: Setting Up the RaspberryPi Serial/Telnet Communication

To set up the transferring of Serial Data from the Pi to the Arduino will require you to open up a port for connection.

Remember when you ssh'd into your Pi and setup the wireless wifi connection? Well your going to need the ssh!

Start off by opening Putty, or the iTerminal app for iPhone and iPad. To connect to your Pi you will need to get it's IP address (I assume you have it). Start off by connecting to your Pi, (make sure your connecting through port 22 and logging in with Username: Pi and Pass: raspberry(unless you changed the password)) once you are connected through ssh you will need to type in the command below:

##########################################

sudo iptables -A INPUT -p tcp --dport 7777 -j ACCEPT

##########################################
What this command does, is it opens communication on port 7777 (you will use this for the telnet communication port port)

############
Make sure that your Arduino is now connected to your Pi (through USB cable)!!!!!!!!!!!
############

Next you will need to open up the connect.py file with this command: (Make sure you are in the directory of the connect.py file)

##########################################

python connect.py -p /dev/ttyACM0 -b 9600

##########################################
What this command will do is, it will connect to your Arduino and allow Telnet communication to it.
The "/dev/ttyACM0" is the Arduino (it's just telling the Pi which device to connect to)
The "-b 9600" is the baud rate


Next, you will need to open up Putty or eTelnet to communicate to the RaspberryPi through Telnet.
To do this type in your Pi's IP address and tell it to connect though port 7777. Put in the username and password stated above.

Once connected you should see: "ROVER by GREG!"  Telling you communication is ready and succesfull

INSTRUCTIONAL PHOTOS ABOVE:

I used the eTelnet app to control my rover with my iPad. It's easier than using a laptop!

Step 7: Your Done!!!!!!!!!!

Once you have established a connection and have the rover with all the components glued down (or taped down) you are ready for some fun!

Enjoy!

ArdiPi Rover 1.0

By: Greg

Arduino Contest

Participated in the
Arduino Contest

Remote Control Contest

Participated in the
Remote Control Contest

Battery Powered Contest

Participated in the
Battery Powered Contest