Introduction: Yet Another Exploration Rover Web-controlled (with Raspberry Pi and Arduino. Android, Iphone, PC, MAC Compatible)

Here is another exploration rover, built in 1 hour or less, without the need for programming. Everthing you need is in the box! It gives you basis to build and improve your own rover.

RaspberryPi with wifi usb adapter, usb webcam, web server (apache + php), and a small GPIO manager (WiringPi).

Arduino to control motors and webcam steering servos.

Everything installed on a board (wood, cardboard, foamcard,...)

.

What you need :

- 1 arduino nano or compatible

- 1 sensor shield for arduino

- 2 RC servos

- 1 dual H-bridge

- 2 wheel kits (wheel + motor)

- 1 caster wheel

- 1 raspberry pi with raspbian installed on SD card

- 1 webcam

- 1 wifi usb adapter

- 1 power bank with 2 outputs

- 1 9 Volts battery

- Jumper wires

- Hot glue / Blue Tack / tape...

.

.

Setup the wifi

Plug the wifi usb adapter and configure wifi interface on the Raspberry Pi:

.
edit the /etc/network/interfaces file to add/modify wlan0 section:

sudo nano /etc/network/interfaces 
auto wlan0
allow-hotplug wlan0
iface wlan0 inet dhcp
wpa-ssid "YOUR-WIFI-NETWORK"
wpa-psk "YOUR-WIFI-PASSWORD"
sudo /etc/init.d/networking stop
sudo /etc/init.d/networking start

.

Now, you could remove your ethernet cable and check interfaces

ifconfig 

The result should be the same shown in the image (picture 2), with a different ip address

To get only the IP address:

hostname -I

.

.

Let's get it started...

For this tutorial, all the credit goes to The Free Electron:

https://www.instructables.com/member/TheFreeElectro...

Feel free to post your own pics, improvements or comments.

Step 1: Raspberry Pi Config (motion)

Set up the webcam with motion:

Connect to RPi :

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install nano
sudo apt-get install motion

Edit the motion file:

sudo nano  /etc/default/motion

change the line for :

<em>start_motion_daemon=yes</em>

Edit the config file:

sudo nano /etc/motion/motion.conf

and change or check following parameters:

<em>set "daemon on"</em>
<em>set "minimum_frame_time 3"</em>
<em>set "quality 80" </em>
<em>set "webcam_port 8081" </em>
<em>set "control_port 8080" </em>
<em>set "webcam_localhost off" </em>
<em>set "width 640" </em>
<em>set "height 480"</em>
sudo service motion restart

.

Now to check the picture displayed, open your browser at http://YOURIPADDRESS:8081

.

.

More information about motion:

http://www.lavrsen.dk/foswiki/bin/view/Motion/WebH...

Step 2: Raspberry Pi Config (WiringPi)

To install WiringPi , you need to install git-core first.

sudo apt-get install git-core

Then, get WiringPi files:

git clone git://git.drogon.net/wiringPi
cd wiringPi
./build

You can check the installation with:

gpio -v

gpio readall

The result will be similar to picture above.

.

More information at :

http://wiringpi.com

http://wiringpi.com/the-gpio-utility/

Step 3: Raspberry Pi Config (Apache Web Server + Php)

Install Apache and php5:

sudo apt-get install apache2 php5 libapache2-mod-php5

To check if apache is running, open your browser and go to http://YOURIPADDRESS

You should get the defualt page "It works" (picture 1).

To check php installation:

cd /var/www
sudo nano info.php

insert following lines

?>

Then open your browser and go to http://YOURIPADDRESS/info.php

You should get the php information page (picture 2).

.

Install the web interface to control your rover

Extract files from web.tar.gz to /var/www/

tar -xzvf web.tar.gz
sudo cp -r web/ /var/www/

.

in /var/www/index.php change line 31, replace 0.0.0.0 by your wlan0 ip address.

.

Give pi user access to web folder

sudo chown -R pi:www-data /var/www

sudo gpasswd -a pi www-data

.

Now open your browser at http://YOURIPADDRESS/index.php

You should have a result similar to cellphone's screenshot (picture 3)

Step 4: Upload File to Your Arduino

Upload this sketch to your arduino, or download YEAR-sketch.ino

#include
Servo Hservo;
Servo Vservo;
int Hstate = 90;
int Vstate = 90;
int in1 = A2;
int in2 = A3;
int in3 = A4;
int in4 = A5;
int camup = 6;
int camdown = 7;
int camleft = 8;
int camright = 9;
int p2;
int p3;
int p4;
int p5;
int p6;
int p7;
int p8;
int p9;
void setup() {
Hservo.attach(10);
Vservo.attach(11);
pinMode(A2, INPUT);
pinMode(A3, INPUT);
pinMode(A4, INPUT);
pinMode(A5, INPUT);
pinMode(6, INPUT);
pinMode(7, INPUT);
pinMode(8, INPUT);
pinMode(9, INPUT);
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
}
void loop() {
p2 = analogRead(A0);
p3 = analogRead(A1);
p4 = analogRead(A2);
p5 = analogRead(A3);
p6 = digitalRead(camup);
p7 = digitalRead(camdown);
p8 = digitalRead(camleft);
p9 = digitalRead(camright);
if ( p6 == LOW || p7 == LOW )
stop();
if ( p6 == HIGH || p7 == HIGH )
horizontal();
if ( p8 == HIGH || p9 == HIGH )
vertical();
if ( p2 > 512 )
forward();
if ( p3 > 512 )
backward();
if ( p4 > 512 )
left();
if ( p5 > 512)
right();
}
void horizontal()
{
if( p6 == HIGH && p7 == LOW )
{ Hstate = Hstate + 2; }
if( p6 == LOW && p7 == HIGH )
{ Hstate = Hstate - 2; }
if( p6 == HIGH && p7 == HIGH )
{ Hstate = 90; }
if (Hstate >= 180) Hstate = 180;
if (Hstate <= 0) Hstate = 0;
Hservo.write(Hstate);
delay(150);
}
void vertical()
{
if( p8 == HIGH && p9 == LOW )
{ Vstate = Vstate + 2; }
if( p8 == LOW && p9 == HIGH )
{ Vstate = Vstate - 2; }
if( p8 == HIGH && p9 == HIGH )
{ Vstate = 90; }
if (Vstate >= 180) Vstate = 180;
if (Vstate <= 0) Vstate = 0;
Vservo.write(Vstate);
delay(150);
}
void forward()
{
digitalWrite(2,HIGH);
digitalWrite(3,LOW);
digitalWrite(4,HIGH);
digitalWrite(5,LOW);
}
void backward()
{
digitalWrite(2,LOW);
digitalWrite(3,HIGH);
digitalWrite(4,LOW);
digitalWrite(5,HIGH);
}
void left()
{
digitalWrite(2,HIGH);
digitalWrite(3,LOW);
digitalWrite(4,LOW);
digitalWrite(5,HIGH);
}
void right()
{
digitalWrite(2,LOW);
digitalWrite(3,HIGH);
digitalWrite(4,HIGH);
digitalWrite(5,LOW);
}
void stop()
{
digitalWrite(2,LOW);
digitalWrite(3,LOW);
digitalWrite(4,LOW);
digitalWrite(5,LOW);
}

The servo library should be already installed

Step 5: Plug ... and Play!

- Set up rover wheels (and motors)

- Set up the servos and the webcam

- Connect H-bridge to motors

- Connect H-bridge to Arduino

- Connect Raspberry to Arduino

- Plug the webcam to Raspberry

- Connect the battery to H-bridge and Plug arduino and Rasperry to the Power bank.

.

If there is no burnt smell or flames coming out of the rover, you're good!

Comments

author
dimonbikon made it!(author)2017-03-13

You can tell me what I need to add in the code

I want to connect 1 more bridge

For two engines

And make 4 more buttons on the motors

Thank you.

author
dimonbikon made it!(author)2017-03-13

thanks for the answer

I use the bridge L298N 220 35v rvt

But it can not turn

Very bad turns

Turn very little power

author
dimonbikon made it!(author)2017-03-12

Everything is working

But do I have a question?

When turning, there is not enough power.

And goes back and forth well.

Tell me how to add power to the motors when turning.

What should I change in the code?

Or just editing the code can not do?

Thank you.

17270098_270941389997256_517882285_n.jpg17270630_270941483330580_77621907_n.jpg17274380_270941459997249_602023487_n.jpg
author
ChrisT43 made it!(author)2017-03-12

You should use H-bridge for your motors.

author
dimonbikon made it!(author)2016-03-21

You can answer?

Thank you!

author
dimonbikon made it!(author)2016-03-21

if I use a pie model B +

connection for Arduino exact same?

author
dimonbikon made it!(author)2016-03-21

A good project

And if i use Arduino Uno

the need to use Sensor Shield ?

or can not use?

author
DIY+Hacks+and+How+Tos made it!(author)2015-12-02

Great robot! Awesome stuff like this is exactly the kind of thing that we need to get kids excited about making.