Introduction: Wifi Controlled Robot Using Raspberry Pi
This tutorial will show you to develop a python based wireless robot which can be controlled from anywhere around the world using Wifi.
About Raspberry Pi
This tiny computer is a precious tool for students, artists, and of course hobbyists and hackers. With features for developing things in different areas, it is not a surprise to have hundreds of thousands if not millions of users.
Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.
Step 1: Gather Parts
This fruit-named computer is a precious tool for students, artists, and of course hobbyists and hackers. With features for developing things in different areas, it is not a surprise to have hundreds of thousands if not millions of users.
L298N Motor Driver Board
The L298N H-bridge module can be used with motors that have a voltage of between 5 and 35V DC. With the module used in this tutorial, there is also an onboard 5V regulator, so if your supply voltage is up to 12V you can also source 5V from the board.
Lithium Polymer Battery
A 11.1V lithium Polymer Battery to Power the whole Robot.
Voltage Regulator Circuit
Any Circuit that can down convert 11.1 V of battery to 5 V (for Raspberry Pi).
2 x DC Geared Motion.
Geared DC motors can be defined as an extension of DC motor. A geared DC Motor has a gear assembly attached to the motor. The speed of motor is counted in terms of rotations of the shaft per minute and is termed as RPM .The gear assembly helps in increasing the torque and reducing the speed. Using the correct combination of gears in a gear motor, its speed can be reduced to any desirable figure. This concept where gears reduce the speed of the vehicle but increase its torque is known as gear reduction. This Insight will explore all the minor and major details that make the gear head and hence the working of geared DC motor.
Buy One or Built One
2 x Dummy Wheels
Raspberry Pi Camera - Optional
Step 2: What Is What
Pi and Python
Python is a wonderful and powerful programming language that's easy to use (easy to read and write) and with Raspberry Pi lets you connect your project to the real world.Python syntax is very clean, with an emphasis on readability and uses standard English keywords.
Physical computing is one of the most engaging activities, and it’s at the heart of most projects we see in the community. From flashing lights to IoT smart homes, the Pi’s GPIO pins make programming objects in the real world accessible to everybody.
The H Bridge
An H bridge is an electronic circuit that enables a voltage to be applied across a load in either direction. These circuits are often used in robotics and other applications to allow DC motors to run forwards or backwards.
Most DC-to-AC converters (power inverters), most AC/AC converters, the DC-to-DC push–pull converter, most motor controllers, and many other kinds of power electronics use H bridges. In particular, a bipolar stepper motor is almost invariably driven by a motor controller containing two H bridges.
A DC motor has two terminals. When we apply a potential difference across the two, It will rotate in one direction. If we reverse the polarity, It will rotate in anticlockwise direction. To reverse a DC motor, you need to be able to reverse the direction of the current in the motor. The easiest way to do this is using an H-bridge circuit. There are many different models and brands of H-Bridge. This tutorial uses one of the most basic, a Texas Instruments L293NE.
Step 3: Build the Bot
Here, I will Give you a Basic Idea on How to setup things.The rest is up to you. Everything is limited by your imagination only.
Setup a Chasis
Build a chasis, whichever design you like, that have enough space to carry our Raspberry Pi, Motor Driver Board, Regulator Circuit and the Lithium Polymer Battery. You can use either Foam Board Base or Aluminum Base.
The Power input for Raspberry Pi and working for l298n Internal circuit is 5V and the voltage needed for driving the motor is 11 V ( up to 32 V). And so we have to make sure that the voltage we are providing the Raspberry pi is not more than 5.5 V. Otherwise it may burn the Board.
In this project I will be using wifi connection to control this robot. In raspberry pi You can use any OS that supports Python GPIO library. I am Using Kali Linux. But for beginners, I recommend Raspbian OS.
Once you install everything, you have to setup network connection. .In Raspberry Pi 3 there is a n inbuilt Broadcom Wifi Adapter. If you are using previous versions, you will have to connect an external USB Wifi Adapter. Connect the Pi to you Network. It is better to provide a static IP address for the Pi.
Next you will have to enable and setup SSH on your pi.Test your connection by connecting to your Raspberry Pi from another Device.
Make sure that the GPIO library is installed and Run a Simple Code to Test like Blinking LED
import RPi.GPIO as GPIO <br>GPIO.setmode(GPIO.BOARD) <br>GPIO.setup(7, GPIO.OUT) <br>GPIO.output(7,True)<em><br></em>
Once this is done, proceed to next step.
Step 4: Get Set...
Write a script to capture keystroke. I used pythons curses library to do the same. Using that we can easily control the bot from the terminal itself.
Next thing to do is Driving the motor. Each L293N IC can Drive two motors independently. Configure 4 pins (or 6 pins if enable pins are counted) as Output Pins. Give appropriate output signals to the Motor Driver board and make make sure that the enable pins of the driver board is active high. Otherwise it wont work.
Set Up a Camera (Optional)
For controlling the bot remotely You may have to use a camera to drive it. Camera modules for raspberry pi are available online. Or you could use a USB camera. Buy one and set it up. Install motion and start live streaming through browser.
Step 5: Go..
Once Everything is setup, combine all the scripts in a single python file. I will update my code here. Try to write everything as functions. Its much easier to call the functions than to write everything once again, when the code grows.
Now, for a fresh start, power off your pi. Assemble everything on the chassis, tighten all the connection, connect your pi and Power on the Bot.
Connect it via SSH and run the script and there you GO..