Let us build a robot that can be controlled using your mobile phone wirelessly over WiFi. Here, I will be using an App RootSaid – WiFi Command Center to send UDP commands to the listener (robot). The listener accepts the UDP packets and then use it to execute a set of instructions to drive the motor. Now lets get started.
Click on them to purchase from amazon
Step 1 – The Chasis
First thing to do is setting up the chasis. You can build it the way you like. It should have enough space to fix our Raspberry Pi, L293D Motor Driver and a good battery. In this project, I will be using a LiPo Battery. You can use foam board or light metal sheet for building the base. If you want you can purchase one from here.
Step 2 – Power Source
In this project, I will be using a 12V Lithium Polymer battery to power up the whole robot, that is the Raspberry Pi and L293D Motor Driver to drive the motors. We can provide 12 V directly to the motor driver Board as it have an inbuilt regulator to power the motor and Circuit separately. But powering raspberry pi with this 12 V battery will fry the Chips. So you will have to use a regulator to step down the 12V to 5V and supply it to Pi. You can Purchase your Lithium Polymer Battery From Here.
Step 3 – DC Motor Driving
In this project we will be using 2 DC motors. These DC motors are driven using a Dual H Bridge Motor Driver IC – L293D. More details on driving DC motors using L293D IC can be obtained here. If you are new to this, it is better to go through this proceeding to next step to get a better understanding of the project.
Get your Products – L293D Driver Board
Step 4 – The Raspberry Pi
Raspberry Pi is a lowcost single board computer which can be used for robotics, home automation etc.
Get your Raspberry Pi from Here
Download and burn an OS to a micro SD card and insert it into the raspberry Pi. In this project, I used Raspbian OS. You can download the OS by clicking the below link
Now power it up. Now fire up your terminal and create a password for the user ‘pi’ by executing the command
sudo passwd pi
Now perform and update and upgrade by running
sudo apt update -ysudo apt upgrade -y
Step 5 – The Network
Connect your Raspberry Pi to the network and make sure your raspberry Pi is getting an IP address. Connect your mobile phone to the same address and make sure there is proper connectivity between the mobile phone and the raspberry pi. You can confirm it by pinging your mobile phone from your Raspberry Pi bye executing the command
ping <ip address of mobile phone>
Take a note of the IP address of the raspberry Pi as we will be using it in the future.
Step 6 – Connections
Raspberry Pi should be provided with 5V and L293D Motor Driver with 12 V.
For this project we will be using 6 GPIO pins to control the robot. 33 and 11 for Motor 1, 13 and 15 for Motor 2 and 29 and 31 for Enable Pins. 29 and 31 should be always kept at Logic 1.
Step 7 – Setting Up the Listener
Now all you have to do is setup a listener on the Pi. Download the sketch from the link below and save it as a file named “controller.py”
Now run the script by executing the command
This will make the pi listen to port 5050 for incoming UDP packets.
Step 8 – Install RootSaid WiFi Command Center from Google PlayStore
RootSaid WiFi Command Center is an android app that can be used to control robots and home appliances over WiFi. All you have to do is connect your mobile phone to the network, enter the IP address and Port of the server (the robot) and control it using the arrow button. Click here to know more about this App.
Click Here to Download this app from Playstore.
Step 9 – Start
Now all you have to do is start the App, enter the IP address of the Pi and port it is listening to (5050).
Load the IP and Port using the link button and navigate to the Robot Controller Tab.
Now you can control the robot by simply pressing the forward, backward, left and right buttons.