Introduction: Wi-Fi Controlled 4-Wheeled Robot
For this project, we will be developing a 4-Wheeled Robot using ESP8266 which will be controlled over a Wi-Fi Network. The robot can be controlled from an ordinary internet browser, using a HTML designed interface or also from an android mobile application. ESP8266 chip is a powerful & cheap microcontroller, which is not only easy to use but also comes with onboard Wi-Fi connectivity. This is just the perfect chip to control robots remotely from your computer or mobile device.
To incorporate this chip into our project we can use a variety of development boards based on this microcontroller.
1. Adafruit Feather Huzzah - It is made by Adafruit and has easily available instructions and support. It has li-po battery charger on the board itself, so it will come really handy in portable projects.
2. NodeMCU ESP8266 - The board is open source and has excellent documentation so it will be very easy to get started.
3. Sparkfun ESP8266 - It is like the Huzzah with the addition of a power switch and an external antenna for a longer Wi-Fi range.
4. Wemos D1 Mini - It is the smallest of all the boards but this doesn't have any effect on the performance.
For my project, I am using Wemos D1 Mini to make a Wi-Fi Controlled 4-Wheeled Robot. But you can use any ESP8266 development board and use the same Arduino code without any changes required. I have designed a PCB for this project but you can use a dot pcb board to implement the circuit or even design your own pcb.
And we will be using 4WD Robotic Chassis Kit as shown in the image above as it is ideal for DIY and is the most economical robot car kit with simple mechanical structure.
- Features of this kit:-
1. Comes with four separate BO plastic motors with gearbox it's good for maneuverability.
2. Large, sturdy acrylic chassis allows greats expandability for you to DIY.
3. Four wheel drive smart car chassis kit. Very easy to install, just add micro-controller (such as Arduino), and sensor modules to build a fully autonomous robot
Step 1: Component List
- Wemos D1 Mini [Quantity – 1]
- L293d Motor Driver IC [Quantity – 2]
- PCF8574 Port Expander IC [Quantity – 1]
- 12V Lithium Ion Battery [Quantity – 1]
- Wi-Fi Controlled Robot PCB [Quantity – 1]
- 4WD Robot Smart Car Chassis Kit [Quantity – 1]
Step 2: Brain of the Project - ESP8266 Development Board (Wemos D1 Mini)
Wemos D1 Mini is a mini Wi-Fi development board with 4MB flash based on ESP-8266 Chip.
- Has 11 digital input/output pins, all pins have interrupt/pwm/I2C/one-wire supported (except D0)
- Has 1 analog input (3.2V max input)
- Has a Micro USB connection for programming as well as a power supply.
This board as is based on ESP8266 hence is Arduino IDE compatible, therefore it can be programmed using Arduino or can also be programmed using Lua compiler. It also supports both serial and OTA programming.
We will be programming the Wemos D1 Mini using Arduino IDE. To program the board using the Arduino IDE following requirements needs to be met.
Requirement:-
- CH340G driver
- Install Latest Arduino IDE from the Arduino website.
- A micro usb cable for programming
After installing the driver and the arduino software you need to install “Arduino core for ESP8266 WiFi chip” inside the Arduino IDE so that we can program the ESP8266 chip from the Arduino environment. This ESP8266 Arduino core lets you write sketches using familiar Arduino functions and libraries, and run them directly on ESP8266, no external microcontroller required.
ESP8266 Arduino core comes with libraries to communicate over WiFi using TCP and UDP, set up HTTP, mDNS, SSDP, and DNS servers, do OTA updates, use a file system in flash memory, work with SD cards, servos, SPI and I2C peripherals.
Download the following document to get an idea about how to install the Esp8266 arduino core.
Attachments
Step 3: Motor Driver - L293d
The Motor Driver is an IC for motors that allows you to control the working speed and direction of two motors simultaneously.
L293d is designed to provide bidirectional drive currents at voltages from 5 V to 36 V. L293D can drive 2 DC motors simultaneously.
L293D is a 16 Pin Motor Driver IC. There are 4 INPUT pins, 4 OUTPUT pins and 2 ENABLE pin for each motor.
L293D Features:
- 600mA output current capability per channel
- Clock and Anti-clockwise direction control for individual channels.
Pin Description of L293d:
- Pin 1: When Enable1 is HIGH, Left part of IC will work, i.e motor connected with pin 3 and pin 6 will rotate.
- Pin 2: Input 1, when this pin is HIGH the current will flow though output 1.
- Pin 3: Output 1, this pin is connected with one terminal of motor.
- Pin 4/5: GND pins
- Pin 6: Output 2, this pin is connected with one terminal of motor.
- Pin 7: Input 2, when this pin is HIGH the current will flow though output 2.
- Pin 8: VCC2, this pin is used to give power supply to connected motors from 5V to 36V maximum depends on Motor connected.
- Pin 9: When Enable 2 is HIGH, Right part of IC will work, i.e motor connected with pin 11 and pin 14 will rotate.
- Pin 10: Input 4, when this pin is HIGH the current will flow though output 4.
- Pin 11: Output 4, this pin is connected with one terminal of motor.
- Pin 12/13: GND pins
- Pin 14: Output 3, this pin is connected with one terminal of motor.
- Pin 15: Input 3, when this pin is HIGH the current will flow though output 3.
- Pin 16: VCC1, for logic supply power to IC i.e 5V.
Thus, you can see you require 3 digital pins to control each motor (one pin for speed control and two pins for direction control). If one L293d controls two DC motors then we will require two L293d IC's to control four DC Motors. We are going to use plastic BO Motors for this project. Thus, you see we will require 12 digital pins to control all the four DC motors independently with both speed and direction control.
But if you see Wemos D1 mini has only 11 Digital I/O pins and 1 Analog pin. To solve this problem we are going to connect the four enable pins (two enable pins of first L293d and two enable pins of other L293d) to Wemos Digital pins directly while all the eight input pins (four of first L293d and four of other L293d) using PCF8574 (An I/O port expander) via I2C.
Step 4: PCF8574 - an I/O Port Expander
Wemos D1 Mini (i.e. ESP8266) has a shortage of input/output pins. We can increase the digital input/output pins using I/O expander IC like PCF8574, which is a 8 bit I/O expander.
One of the advantages of using PCF8574A I/O expander is that it uses I2C bus, which requires only two data lines, they are clock (SCK) and data (SDA). Therefore, with these two lines, you can control up to eight pins of the same chip. By changing the three address pins of each PCF8574 we can control overall 64 pins.
This 8-bit input/output (I/O) expander for the two-line bidirectional bus (I2C) is designed for 2.5V to 6V VCC operation. The PCF8574 device provides general-purpose remote I/O expansion for most microcontroller families by way of the I2C interface [serial clock (SCL), serial data (SDA)].
The device features an 8-bit quasi-bidirectional I/O port (P0–P7), including latched outputs with high- current drive capability for directly driving LEDs. Each quasi-bidirectional I/O can be used as an input or output without the use of a data-direction control signal. At power on, the I/Os are high.
See the below "PCF8574_With_L293d" pdf file for the connection diagram of PCF8574 with the two L293d IC's
Attachments
Step 5: Schematics
I have used Kicad for PCB designing.
Download the below schematic pdf to design your own pcb or implement it on a dot pcb board.
Attachments
Step 6: Code
Connect to the following Wi-Fi Access Point:-
// User Defined Network Credentials
const char* ssid = "WiFi_Robot";
const char* password = "Automate@111";
After connecting to the above access point go to below link in a web browser:-
You will get following message:-
"hello from Robot!"
It will cause the robot to move forward
It will cause the robot to move backward
It will cause the robot to move left
It will cause the robot to move right
It will cause the robot to stop
If you want you can also control the robot via the Android app made by Robo India.
{Search for "WiFi Robot Controller" android app on the playstore made by Robo India}
[Note: In any ways i am not connected with Robo India and this is not for advertisement, this is my personal project!]
Working Video of the Project:-