Surveillance robot using raspberrry -pi

December 26, 2015

Capturegow2

problem statement:
control a bot using wifi from ur laptop or phone by adding features like live streaming and audio player or horn.
components:
Raspberry pi

power banks -2,
speaker,
camera (usb type),
relay board,
chassis,
wheels,
200rpm motors,
sufficient batterysupply,
arduino ,
accelerometer,
rf transmitter and reciever.

sur

WORKING:
The bot can be operated in two ways:
1)using accelerometer:
we detect the motion or orientation of hands and hence run the bot by transmitting it to raspberry pi.
2)using laptop:
by simply entering the commands from our laptop.

1)using accelerometer:
⦁ we calibrate the accelerometer values for a standard position, and then write a program to determine left,right,front,back,stable values .
⦁ we compare the present values and compare it with the determined values to know the positon of hand and sending proper output to raspberry pi.
⦁ The stable position is determined by an enable pin,and two pin to determine the motion of bot.
⦁ RF circuit is used to send the values to raspberry pi wirelessly.
⦁ A python code is run at the raspberry pi SBC(single board computer), to take the values from rf reciever and hence give the values of output to relay board which is connected to motors.
⦁ The relay board enables us to connect the power supply to the motors.
⦁ The arduino programming which enables us to determine the position of the hand is
//start of the program
void setup(){
Serial.begin(9600);
pinMode(7,OUTPUT);
pinMode(2,OUTPUT);
pinMode(12,OUTPUT);
}
void loop(){
delay(500);
int a=analogRead(A0);
int b=analogRead(A1);
if(((a>=330)&&(a<=345))&&((b>=330)&&(b<=345))){
digitalWrite(12,LOW);
Serial.println(“stop”);
}
else if(b<310){
digitalWrite(12,HIGH);
digitalWrite(7,HIGH);
digitalWrite(2,HIGH);
Serial.println(“front”);
}
else if(b>370){
digitalWrite(12,HIGH);
digitalWrite(2,LOW);
digitalWrite(7,LOW);
Serial.println(“back”);
}
else if(a>370){
digitalWrite(12,HIGH);
digitalWrite(2,LOW);
digitalWrite(7,HIGH);
Serial.println(“left”);
}
else if(a<300){
digitalWrite(12,HIGH);
digitalWrite(7,LOW);
digitalWrite(2,HIGH);
Serial.println(“right”);
}//end of the program
hence the pin number 12 is used as enable pin.
⦁ The program in python langauge format is as the following:
//start of the program
import time
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
GPIO.setup(0,GPIO.IN)
GPIO.setup(1,GPIO.IN)
GPIO.setup(4,GPIO.IN)
GPIO.setup(14,GPIO.OUT)
GPIO.setup(15,GPIO.OUT)
GPIO.setup(18,GPIO.OUT)
GPIO.setup(17,GPIO.OUT)
while True:
time.sleep(0.5):
b=GPIO.input(0):
c=GPIO.input(1):
d=GPIO.input(4):
if (b==1)
GPIO.output(14,False)
GPIO.output(15,False)
GPIO.output(18,False)
GPIO.output(17,False)
print(“stop”)
elif (c==1 and d==1)
GPIO.output(14,True)
GPIO.output(15,False)
GPIO.output(17,False)
GPIO.output(18,False)
print(“straight)
elif (c==0 and d==1)
GPIO.output(14,False)
GPIO.output(15,True)
GPIO.output(17,False)
GPIO.output(18,False)
print(“left”)
elif (c==1 and d==0)
GPIO.output(14,False)
GPIO.output(15,False)
GPIO.output(17,False)
GPIO.output(18,True)
print(“right”)
elif (c==0 and d==0)
GPIO.output(14,False)
GPIO.output(15,False)
GPIO.output(18,False)
GPIO.output(17,True)
print(“back”)
//end of the program
⦁ The output pins are connected to relay boards to connect the power supply to motors.
To play music or horn using speakers:
⦁ The speakers are connected to power supply from a powerbank
⦁ The audiojack is connected to the audio output (yellow) in the raspberry pi.
⦁ The audio file which need to be played or music song must be stored in the raspberry pi in mp3 format file.
⦁ The file must be in the same directory as remaining codes to enable easy access of the audio
⦁ The following code is run from different laptop or device in lxterminal to play the audio file:
“omxplayer -o local example.mp3”
The above code will play the audio file at a particular time.

 

To get live streaming/video streaming:
⦁ The raspberry pi is updated and upgraded using the following codes :
” sudo apt get update
sudo apt get upgrade
sudo apt get install motion”
⦁ The above codes will take some time for the first time,but afterwards we need not run the above code
⦁ The following code simply gives the live streaming taken by usb-port camera,
“sudo service motion start”
⦁ The live streaming can be obtained from any mozilla firefox browser for the following ip address
⦁ for example if ip adress is 192.168.43.106 then for video streaming we can simply write the code:
“192.168.43.106:8081”
⦁ The live streaming can be configured in the following address port:
“192.168.43.106:8080”.

 

To control the bot through your device(laptop/phone):
⦁ connect your phone to host hotspot
⦁ open a new file and paste the following code to run the bot with keys 8-front,4-left,6-right,5-stop,2-back
“//start of the program
import time
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
GPIO.setup(0,GPIO.IN)
GPIO.setup(1,GPIO.IN)
GPIO.setup(4,GPIO.IN)
GPIO.setup(14,GPIO.OUT)
GPIO.setup(15,GPIO.OUT)
GPIO.setup(18,GPIO.OUT)
GPIO.setup(17,GPIO.OUT)
while True:
time.sleep(0.5):
a=input():
if (a==5)
GPIO.output(14,False)
GPIO.output(15,False)
GPIO.output(18,False)
GPIO.output(17,False)
print(“stop”)
elif (a==2)
GPIO.output(14,True)
GPIO.output(15,False)
GPIO.output(17,False)
GPIO.output(18,False)
print(“straight)
elif (a== 4)
GPIO.output(14,False)
GPIO.output(15,True)
GPIO.output(17,False)
GPIO.output(18,False)
print(“left”)
elif (a==6)
GPIO.output(14,False)
GPIO.output(15,False)
GPIO.output(17,False)
GPIO.output(18,True)
print(“right”)
elif (a==8)
GPIO.output(14,False)
GPIO.output(15,False)
GPIO.output(17,True)
GPIO.output(18,False)
print(“back”)
//end of the program