WiFi Controlled Robot using ESP8266 and Arduino

Table of Contents

In the previous ESP8266 Projects, we have seen a few WiFi based projects like WiFi Controlled LED and WiFi Controlled Relay. Taking the same concept to a next level in this project, I will show you how to build and develop a WiFi Controlled Robot using ESP8266 and Arduino. When I say WiFi Controlled Robot, I mean a robotic car that is controlled over a WiFi Network.


If you are following ElectronicsHub for some time, you will remember that we have built a variety of robots like Line Follower Robot, Obstacle Avoiding Robot, Bluetooth Controlled Robotic Arm and RF Controlled Robot.

The first two robots i.e. Line follower Robot and Obstacle Avoiding Robot do not have any manual control of the robot i.e. there will be no additional inputs from the user apart from programming its main functionality.

WiFi Controlled Robot Image 1

But in case of the other two robots i.e. Bluetooth Controlled Robotic Arm and RF Controlled Robot, the robots wait for the user to provide appropriate input. This input can be either direction of movement or holding an object etc.

In this project, I have built a simple Robot (robotic car) that can be controlled over WiFi Network i.e. the user inputs for direction of the movement of the Robot are provided through the WiFi (with the help of a simple HTML Page).

Concept behind WiFi Controlled Robot

If you have followed our “WiFi Controlled LED using ESP8266 and Arduino” project, then you can easily understand the concept of the WiFi Controlled Robot.

The ESP8266 Module is responsible for connecting to the WiFi Network and also acting as a server. Coming to the client, a simple HTML page is created and the browser which opens this web page acts as a client.

When ever you click on the web page, corresponding information will be transmitted to the Server (ESP8266). This information is further received by Arduino and it controls the motors of the robot.

Circuit Diagram of WiFi Controlled Robot

The circuit diagram of the WiFi Controlled Robot using ESP8266 and Arduino is given in the image below.

WiFi Controlled Robot Circuit Diagram

NOTE: ESP8266 WiFi Module is loaded with AT Commands. The above circuit is designed keeping that in mind.

Components Required

  • ESP8266
  • L298N Motor Driver Module  [Buy Here]
  • Arduino UNO  [Buy Here]
  • Robot Chassis
  • 4 x 5V Geared Motors
  • Connecting Wires
  • Power supply (or battery)

Circuit Design

The first important thing to remember is that I will be programming the Arduino and it is responsible for configuring the ESP8266 Module through Serial Communication and also controlling the L298N Motor Driver Module.

So, the Digital Pins 2 and 3 of Arduino are configured as RX and TX using SoftwareSerial function. These pins are connected to the TX and RX pins of the ESP8266 Module.

Then, the Inputs of the L298N Motor Driver Module i.e. IN1, IN2, IN3 and IN4 are connected to Digital Pins 8, 9, 10 and 11 of Arduino UNO.

Coming to the robot chassis, it has 4 geared motors. So, I have connected the right two motors in parallel and connected them to OUT1 and OUT2 terminals of the Motor Driver. Similarly, the left two motors to OUT3 and OUT4.


There are two codes for the WiFi Controlled Robot project. One code is for the Arduino UNO and the other is an HTML Code for creating a Web Page.

Arduino Code

Following is the Arduino Code for the project. In this code, enter the SSID and Password of your WiFi network at appropriate places.


#include <SoftwareSerial.h>
/* Pins 8, 9, 10 and 11 of Arduino are connected to L298N Motor Driver Input pins i.e.
IN1, IN2, In3 and IN4 respectively*/
#define IN1 8
#define IN2 9
#define IN3 10
#define IN4 11
#define DEBUG true
#define RXPIN 2
#define TXPIN 3
SoftwareSerial esp8266Serial(RXPIN,TXPIN); //Pin 2 & 3 of Arduino as RX and TX. Connect TX and RX of ESP8266 respectively.
void setup()
pinMode(IN1, OUTPUT);
pinMode(IN2, OUTPUT);
pinMode(IN3, OUTPUT);
pinMode(IN4, OUTPUT);
digitalWrite(IN1, LOW);
digitalWrite(IN2, LOW);
digitalWrite(IN3, LOW);
digitalWrite(IN4, LOW);
esp8266Serial.begin(115200); //Baud rate for communicating with ESP8266. Your’s might be different.
esp8266Data(AT+RST\r\n, 5000, DEBUG); // Reset the ESP8266
esp8266Data(AT+CWMODE=1\r\n, 5000, DEBUG); //Set station mode Operation
/*Change the following command as per your requirement i.e. enter the
SSID and Password of your WiFi Network in the command.*/
esp8266Data(AT+CWJAP=\”SSID\”,\”PASSWORD\”\r\n, 5000, DEBUG);//Enter your WiFi network’s SSID and Password.
esp8266Data(AT+CIFSR\r\n, 5000, DEBUG);//You will get the IP Address of the ESP8266 from this command.
/* The following statement is to assign Static IP Address to ESP8266.
The syntax is AT+CIPSTA=<ip>,<gateway>,<netmask>.
This will assign a Static IP Address of (in my case)
to the ESP8266 Module. Change this value as per your requirements i.e. this IP address
shouldn’t conflict with any other device.
Also, the second and third parameters are Gateway and Net Mask values.
You can get these values from ipconfig command in command prompt*/
esp8266Data(AT+CIPSTA=\”\”,\”\”,\”\”\r\n, 3000, DEBUG); // Assign Static IP Address
esp8266Data(AT+CIFSR\r\n, 5000, DEBUG);//You will get the IP Address of the ESP8266 from this command.
esp8266Data(AT+CIPMUX=1\r\n, 5000, DEBUG);
esp8266Data(AT+CIPSERVER=1,80\r\n, 5000, DEBUG);
void loop()
if (esp8266Serial.available())
if (esp8266Serial.find(+IPD,))
String msg;
msg = esp8266Serial.readStringUntil( );
String command1 = msg.substring(0, 5);
String command2 = msg.substring(6);
if (DEBUG)
Serial.println(command1);//Must print “robot”
Serial.println(command2);//Must print “FWD” or “REV” or “LFT” or “RGT” or “STP”
if (command2 == FWD)
if (command2 == REV)
if (command2 == RGT)
if (command2 == LFT)
if (command2 == STP)
void forward()
digitalWrite(IN1, HIGH);
digitalWrite(IN2, LOW);
digitalWrite(IN3, HIGH);
digitalWrite(IN4, LOW);
void reverse()
digitalWrite(IN1, LOW);
digitalWrite(IN2, HIGH);
digitalWrite(IN3, LOW);
digitalWrite(IN4, HIGH);
void left()
digitalWrite(IN1, LOW);
digitalWrite(IN2, LOW);
digitalWrite(IN3, HIGH);
digitalWrite(IN4, LOW);
void right()
digitalWrite(IN1, HIGH);
digitalWrite(IN2, LOW);
digitalWrite(IN3, LOW);
digitalWrite(IN4, LOW);
void stoprobot()
digitalWrite(IN1, LOW);
digitalWrite(IN2, LOW);
digitalWrite(IN3, LOW);
digitalWrite(IN4, LOW);
String esp8266Data(String command, const int timeout, boolean debug)
String response = ;
long int time = millis();
while ( (time + timeout) > millis())
while (esp8266Serial.available())
char c = esp8266Serial.read();
response += c;
if (debug)
return response;


Also, there is a section in the code which is responsible for assigning a static IP Address to the ESP8266 Module. This IP Address (along with the default Gateway and Subnet Mask) must be changed as per your requirement.

It is very important that the Static IP Address you will be assigning should not be in conflict with any other device in your network i.e. no other device should possess the same IP Address.

So, scan for all the IP Addresses in your network and carefully assign the IP Address.


In order to create a control web page, you can use the following HTML Code along with a JavaScript file.


<title>WiFi Controlled Robot</title>
<h2> <i> WiFi Controlled Robot using Arduino and ESP8266 </i> </h2>
<h5> <i> by ElectronicsHub.org </i> </h5>
<button id=”FWDclass=”robot>FORWARD</button>
<button id=”REVclass=”robot>REVERSE</button>
<button id=”RGTclass=”robot>RIGHT</button>
<button id=”LFTclass=”robot>LEFT</button>
<button id=”STPclass=”robot>STOP</button>
<script src=”jquery.js></script>
<script type=”text/javascript>
var cmd = $(this).attr(‘id’);
$.get(“”, {robot:cmd});


Download the above code with .html extension and also download the jquery.js file. Place both these files in a single folder.


A simple project called WiFi Controlled Robot using ESP8266 and Arduino is implemented here. Let me explain its working.

Upload the Arduino code after making the necessary connections and changes to the code. If you open the serial monitor of the Arduino IDE, you can see the AT Commands that being sent to the ESP8266 Module.

WiFi Controlled Robot Serial Monitor

After the ESP Module is connected to WiFi, it will assign the static IP and also creates the server. Once the server is created, the ESP Module is waiting for connecting with a client.

Now, if you open the HTML Page which you have downloaded earlier, you can a simple layout that consists of five buttons with names FORWARD, REVERSE, RIGHT, LEFT and STOP.

WiFi Controlled Robot Web Page

By looking at these buttons, you might have understood what each button does. Simply clicking the button performs that particular action. It is as simple as that.


  • This WiFi Controlled Robot is controlled with the help of an HTML Web Page (which can be accessed using any web browser on a computer that is connected to the same WiFi Network as ESP8266).
  • There are many projects out there which have implemented a similar concept but using Apps like Blynk.
  • The reason for which I have not gone with that App is that I felt that you really do not know what is going on actually as everything is done by the library files.
  • So, if you want to know exactly what is going on with the project, then only you should try this. If not, you can simply implement the project using the Blynk App.
  • If you go through both the codes carefully, you can understand how the communication happens between the Browser and the ESP Module.

Conclusion and Applications

  • A simple WiFi Controlled Robot is implemented in this project where a robotic car is controlled using a web page over WiFi Network.
  • You can make this project with advanced features like integrating a camera and accessing the feed live on the browser.

Similar Articles & Blogs

Explore similar articles on various electronics and electrical topics – 

Logic NOT Function

The Logic NOT Function is simply a single input inverter that changes the input of a logic level “1” to an output of logic level “0” and

Learn More >>

Logic OR Function

The Logic OR Function function states that an output action will become TRUE if either one “OR” more events are TRUE, but the order at which they

Learn More >>

Logic AND Function

In 1854, George Boole performed an investigation into the “laws of thought” which were based around a simplified version of the “group” or “set” theory, and from

Learn More >>

Binary Coded Decimal

As we have seen in this Binary Numbers section of tutorials, there are many different binary codes used in digital and electronic circuits, each with

Learn More >>