Satyavrat Wagle
Published © GPL3+

Hybrid Rover - Cloud Controlled Robot

Choose to control this robot from anywhere in the world using either a joystick or an accelerometer at the flick of a switch!

IntermediateFull instructions provided3 hours1,467
Hybrid Rover - Cloud Controlled Robot

Things used in this project

Hardware components

Raspberry Pi 1 Model B
Raspberry Pi 1 Model B
×1
BOOSTXL-EDUMKII Educational BoosterPack MK II
Texas Instruments BOOSTXL-EDUMKII Educational BoosterPack MK II
×1
8 volt battery
×1
Linear Regulator (7805)
Linear Regulator (7805)
×1
Dual H-Bridge motor drivers L293D
Texas Instruments Dual H-Bridge motor drivers L293D
×1
DC motor (generic)
×2
Adafruit USB WiFi (802.11b/g/n) Module with Antenna for Raspberry Pi
×1
Jumper wires (generic)
Jumper wires (generic)
×16

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)
Digital Multimeter

Story

Read more

Schematics

Raspberry Pi Interfaces

Use this document as reference for Raspberry Pi connections. Please note that the 9 volt battery can be anything from 8 volt to 12 volt.

Schematic #1

Code

raspi.py

Python
Upload this code to Raspberry Pi. Acts as listener and actuates motor driver according to received commands
import socket
import RPi.GPIO as GPIO
import time

GPIO.setmode(GPIO.BOARD)
GPIO.setup(12,GPIO.OUT)
GPIO.setup(16,GPIO.OUT)
GPIO.setup(18,GPIO.OUT)
GPIO.setup(22,GPIO.OUT)

TCP_IP = *Insert Raspberry Pi IP Address here*
TCP_PORT = 5005
BUFFER_SIZE = 25
s = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
s.bind((TCP_IP,TCP_PORT))

while 1:
    s.listen(2)
    conn,addr = s.accept()
    data = conn.recv(BUFFER_SIZE)
    recdata = str(data)
    recdata = int(data)
    if(recdata==2): #Right TT
    	GPIO.output(12,True)
    	GPIO.output(16,False)
    	GPIO.output(18,True)
    	GPIO.output(22,False)
    if(recdata==0): #Left TT
    	GPIO.output(12,False)
    	GPIO.output(16,True)
    	GPIO.output(18,False)
    	GPIO.output(22,True)
    if(recdata==6): #Reverse
    	GPIO.output(12,True)
    	GPIO.output(16,False)
    	GPIO.output(18,False)
    	GPIO.output(22,True)
    if(recdata==4): #Forward
    	GPIO.output(12,False)
    	GPIO.output(16,True)
    	GPIO.output(18,True)
    	GPIO.output(22,False)
    if(recdata==1): # Stop
    	GPIO.output(12,False)
    	GPIO.output(16,False)
    	GPIO.output(18,False)
    	GPIO.output(22,False)
    if(recdata==3): # Right
    	GPIO.output(12,False)
    	GPIO.output(16,True)
    	GPIO.output(18,False)
    	GPIO.output(22,False)
    if(recdata==5): # Left
    	GPIO.output(12,False)
    	GPIO.output(16,False)
    	GPIO.output(18,True)
    	GPIO.output(22,False)

edison.py

Python
Upload this code to the Edison. It will act as the dynamic control to send data to the Raspberry Pi
#! /usr/bin/env python

import mraa
import sys
import time
import socket

hor = mraa.Aio(0)
ver = mraa.Aio(1)
horax = mraa.Aio(2)
verax = mraa.Aio(3)
butt = mraa.Gpio(3)
snd = 1
TCP_IP = *Insert Raspberry Pi IP here*
TCP_PORT = 5005
BUFFER_SIZE = 1024

while True:
	buttval = butt.read()
	if(buttval == 0 ):
		accel()
	if(buttval == 1 ):
		manual()
	
	
def accel():
		s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
		s.connect((TCP_IP, TCP_PORT))
		horval = horax.read()
		verval = verax.read()
		if(verval>500):
			if(horval<100):
				snd = 3
			if(100<horval<500):
				snd = 4
			if(horval>500):
				snd = 5
		if(100<verval<500):
			if(horval<100):
				snd = 0
			if(100<horval<500):
				snd = 1
			if(horval>500):
				snd = 2
		if(verval<100):
			snd = 6
		bytes = str.encode(str(snd))
		print verval
		s.send(bytes)
		time.sleep(0.2)

def manual():
		s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
		s.connect((TCP_IP, TCP_PORT))
		horval = hor.read()
		verval = ver.read()
		if(verval>500):
			if(horval<100):
				snd = 3
			if(100<horval<500):
				snd = 4
			if(horval>500):
				snd = 5
		if(100<verval<500):
			if(horval<100):
				snd = 0
			if(100<horval<500):
				snd = 1
			if(horval>500):
				snd = 2
		if(verval<100):
			snd = 6
		bytes = str.encode(str(snd))
		print verval
		s.send(bytes)
		time.sleep(0.2)

Credits

Satyavrat Wagle

Satyavrat Wagle

6 projects • 63 followers
I have an active interest in IoT, Wireless Sensor Networks, Single Board Computing Implementations, Embedded Systems, and Robotics.

Comments