WiFi Controlled Robot Car Using Arduino And ESP8266

In the previous ESP8266 NodeMCU projects, we did a few WiFi-based projects like WiFi controlled home automation systems, temperature and humidity systems. We will develop our next project by taking the same concept, i.e. how to build and develop a WiFi controlled robot car using ESP8266 NodeMCU. As the name I say WiFi controlled robot car, I want to mean a robotic car that is controlled over a WiFi network.

Must Read WiFi Based Home Automation System Using Blynk

Project

If you are following Electro Gadget regularly, you remember that we have built various robots using Arduino like Line Follower Robot, Obstacle Avoiding Robot, Bluetooth Controlled Robot Car, etc.

WiFi Controlled Robot Car Using Arduino And ESP8266
WiFi Controlled Robot Car Using Arduino And ESP8266

The following two projects i.e. Line follower Robot and Obstacle Avoiding Robot do not have any manual control of it. That is there will be no additional inputs from the user apart from a programming of the microprocessor.

But in the case of Bluetooth Controlled Robot Car, the processing system wait for the user for appropriate input. This input can be either direction of movement or holding an object at a certain point.

In this project, I have built a simple robot that can be controlled over a WiFi network. When the user inputs for the required direction of the movement of the Robot are provided through the WiFi.

Principle Behind WiFi Controlled Robot Car

The concept of the WiFi Controlled Robot Car is so simple.

The ESP8266 NodeMCU Module works as a network hub for connecting to the WiFi network and acting as a server. Coming to the client, a simple webpage is created and the browser which opens this web page acts as a client.

Whenever you do any activity on the webpage, the corresponding information will be transmitted to the server (ESP8266 NodeMCU). Therefore it controls the motors of the WiFi controlled robot car.

Circuit Diagram

WiFi Controlled Robot Car Using Arduino And ESP8266 Circuit Diagram
WiFi Controlled Robot Car Using Arduino And ESP8266 Circuit Diagram

Components Required

  • ESP8266 NodeMCU WiFi Module
  • L298N Motor Driver
  • 4x Geared Motor
  • 4x Wheel
  • Chassis
  • Wires
  • 12V battery

Circuit Connection of WiFi Controlled Robot Car

The first important thing is that to programming the ESP8266 NodeMCU. It is responsible for configuring through serial communication and also controlling the L298N motor driver module.

We are using ESP8266 NodeMCU here instead of Arduino. So the complexity of the circuit connection and coding is waived a little.

First, the inputs of the L298N motor driver module i.e. IN1, IN2, IN3 and IN4 are connected to digital pins D1, D2, D3 and D4 of the ESP8266 NodeMCU. And the enable pins ENA and ENB are connected to the D0 and D5 respectively.

Coming to the robot chassis, it has contained four geared motors. So, we need to connect the right two motors in parallel and connect them to the OUT1 and OUT2 terminals of the motor driver. Similarly, connect the left two motors to OUT3 and OUT4.

PCB Design

For removing messy wiring and give a clean look, I designed a PCB prototype for this project. It is also helpful for troubleshooting that runs great without any errors. To design this PCB board, I used EasyEDA as it is too easy to use. For ordering PCB for this, I personally prefer PCBWay.

Gerber file for WiFi Controlled Robot Car Using ESP8266.

You can view the Gerber file from here Gerber File Viewer.

PCB View

WiFi Controlled Robot Car Using ESP8266 PCB View
2D view

Order PCB From PCBWay

This project is sponsored by PCBWay.com. PCBs are required everywhere in the electronics industry. So it not only needs to be good enough but also have to serve the purpose for which they are needed without costing exorbitant amounts. PCBway offers all your needs come true. PCBWay is one of the largest PCB (Printed Circuit Board) manufacturing companies in china. It offers PCB prototype, PCB Assembly, SMD Stencil, and Flexible PCB.

They ship to more than 170 countries worldwide and process more than 2100 PCB orders a day. It feels like PCBWay gives an excellent price and customer service factor in one single serving. I personally ordered PCBs from PCBWay for my projects for just 5 dollars. I’ve used other PCB manufacturers too, but PCBWay has been offering the most reliable and consistent that I have tried. What is also spectacular about PCBWay to me, as a maker and customer, is their service. From their friendly support staff to their intuitive, user-friendly website features, it all counts towards what makes PCBWay an ideal company and brand for any electronics hobbyists.

Standard quality for any product needs to be maintained using some parameters. PCBWay gives that opportunity by quality control in designing and manufacturing. At first, they ensure accuracy, clarity, validity of the PCB files that we sent to them.

Then all the boards will go through the most stringent tests other than the basic visual check. They adopt most of the testing and inspecting equipment used in the industry, such as Flying Probe Tester, X-Ray Inspection Machine, Automated Optical Inspection (AOI) Machine. They are having 50+ new engineers on the daily basis around the world using PCBs for their work, who trust for their reliable quality.

Features of PCBWay

PCB Prototyping & Manufacturing: PCBWay produces FR-4 and Aluminum boards and advanced PCBs like Rogers, HDI, Flexible and Rigid-Flex boards, at a very reasonable price. Just check this Instant Quote to order premium PCBs for your hobby projects.

PCB Assembly: It not only offers PCB Prototyping but also offers PCB Assembly service. You can order a full PCB board with attached components by uploading your file. SMT & THT assembly starts from only 30$ including free stencil and worldwide shipping. The components can be sourced and provided by PCBWay, or by clients themselves.

Open Source Community: It not only offers PCB Prototype & Assembly service but also gives opportunities to students for sponsorships. I think this is so great. They feature their projects on the website also.

3D Printing & CNC: It also produces Rapid Prototyping like 3D printing, CNC Machining, Sheet Metal Fabrication, and Injection Molding. The quality of the product is too premium and reliable. And also the best part is that you will receive your order within a minimum of 3 days.

Services: PCBWay offers great servicing of their products. It takes only 3 to 15 days according to courier service to deliver your products. Also, it has a live support facility. Whenever you have any problems, you can always reach a live customer service person to respond to your emails or messages. They have the “Return and Refund” principle, for every unusable board caused by PCBWay, they will rebuild and refund the order soon.

PCB Design Contest: The 4th PCBWay contest is finally here. This year, they have introduced mainly 2 themes of the entries: One is IoT, which will include home automation, wearable or other interesting projects and the other one is robotics, which could be combined with smart cars, drones or other automated projects. For enquiries about the rules and regulations and prize pools just check out this link PCBWay 4Th PCB Design Contest.

Guide for Ordering PCB From PCBWay

Preparing Software For WiFi Controlled Robot Car

Communication between devices and servers will be established when there is a proper dashboard present. For this project, we have used Blynk for controlling the WiFi robot.

To upload code to ESP8266 NodeMCU, we need Arduino IDE software.

First, open Arduino IDE software.

Go to File and select Preferences and paste the link “https://arduino.esp8266.com/stable/package_esp8266com_index.json” in Additional Board Manager URLs to add the ESP8266 board. Open Boards Manager from the Tools menu and type ESP8266 to install the ESP8266 platform. For programming the ESP8266 module, one unique identity is required from the Blynk software. That is Auth code. After connecting to a network this ID help to communicate the device with it. To connect to the local WiFi network requires WiFi SSID and password.

Before compiling and load the code to this module, we have to install the Adafruit Sensor Library, Blynk Library.

To add these libraries to Arduino IDE, go to Sketch – Include Library – Add .zip Library – locate and install files.

Preparing Dashboard For WiFi Controlled Robot Car

After that, open the official Blynk app and create an account for yourself. After creating a new project, you will get the Auth token via your email.

Copy this Auth token and paste it into the appropriate fields of the Arduino ESP8266 code. After that, upload the Arduino IDE code to the NodeMCU and wait for connecting with the device on the network.

The next page will show a blank space to add buttons for the system. Tap on the blank space and choose the button option and add this. Again click on this and choose a virtual pin and select desired pin which you include in your Arduino code. Then click OK and press back.

Continue with the same process with the others three. After that choose the slider button for speed control and choose their virtual pins. Finally, get back to the homepage and click on the play button on the upper right side. You can control then your devices through this Blynk app.

Working Principle of WiFi Controlled Robot Car

A simple project called WiFi Controlled Robot Car using ESP8266 NodeMCU is implemented here. Let me explain how this robot works.

First, upload the ESP8266 code after making the necessary connections and changes to the code. By opening the serial monitor of the Arduino IDE software, we can see the AT Commands that are being sent to the ESP8266 NodeMCU Module.

After connecting the ESP8266 module to WiFi, it will assign a static IP and also creates a server. Once the server is made, the ESP8266 module is waiting for connecting with a client.

Now, if you open the android application which we have downloaded, we can find a simple layout that consists of five buttons with names FORWARD, REVERSE, RIGHT, LEFT and SPEED.

By looking at these buttons, we can understand what each button does. Simply click on the button to perform that particular action. It is as simple as that.

Conclusion of WiFi Controlled Robot Car

A simple WiFi controlled robot car is made in this project where a robotic car is controlled using a mobile application over a WiFi network.

Anyone can make this project with advanced features by integrating a camera and accessing the live feed on the application.

ESP8266 NodeMCU Code

#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>
 
//Motor PINs
#define ENA D0
#define IN1 D1
#define IN2 D2
#define IN3 D3
#define IN4 D4
#define ENB D5
 
bool forward = 0;
bool backward = 0;
bool left = 0;
bool right = 0;
int Speed;
char auth[] = ""; //Enter your Blynk auth token
char ssid[] = ""; //Enter your WIFI Name
char pass[] = ""; //Enter your WIFI Passowrd
 
 
void setup() {
  Serial.begin(9600);
  pinMode(ENA, OUTPUT);
  pinMode(IN1, OUTPUT);
  pinMode(IN2, OUTPUT);
  pinMode(IN3, OUTPUT);
  pinMode(IN4, OUTPUT);
  pinMode(ENB, OUTPUT);
 
  Blynk.begin(auth, ssid, pass);
}
 
BLYNK_WRITE(V0) {
  forward = param.asInt();
}
 
BLYNK_WRITE(V1) {
  backward = param.asInt();
}
 
BLYNK_WRITE(V2) {
  left = param.asInt();
}
 
BLYNK_WRITE(V3) {
  right = param.asInt();
}
 
BLYNK_WRITE(V4) {
  Speed = param.asInt();
}
 
void smartcar() {
  if (forward == 1) {
    carforward();
    Serial.println("carforward");
  } else if (backward == 1) {
    carbackward();
    Serial.println("carbackward");
  } else if (left == 1) {
    carturnleft();
    Serial.println("carfleft");
  } else if (right == 1) {
    carturnright();
    Serial.println("carright");
  } else if (forward == 0 && backward == 0 && left == 0 && right == 0) {
    carStop();
    Serial.println("carstop");
  }
}
void loop() {
  Blynk.run();
  smartcar();
}
 
void carforward() {
  analogWrite(ENA, Speed);
  analogWrite(ENB, Speed);
  digitalWrite(IN1, LOW);
  digitalWrite(IN2, HIGH);
  digitalWrite(IN3, HIGH);
  digitalWrite(IN4, LOW);
}
void carbackward() {
  analogWrite(ENA, Speed);
  analogWrite(ENB, Speed);
  digitalWrite(IN1, HIGH);
  digitalWrite(IN2, LOW);
  digitalWrite(IN3, LOW);
  digitalWrite(IN4, HIGH);
}
void carturnleft() {
  analogWrite(ENA, Speed);
  analogWrite(ENB, Speed);
  digitalWrite(IN1, HIGH);
  digitalWrite(IN2, LOW);
  digitalWrite(IN3, HIGH);
  digitalWrite(IN4, LOW);
}
void carturnright() {
  analogWrite(ENA, Speed);
  analogWrite(ENB, Speed);
  digitalWrite(IN1, LOW);
  digitalWrite(IN2, HIGH);
  digitalWrite(IN3, LOW);
  digitalWrite(IN4, HIGH);
}
void carStop() {
  digitalWrite(IN1, LOW);
  digitalWrite(IN2, LOW);
  digitalWrite(IN3, LOW);
  digitalWrite(IN4, LOW);
}

3 thoughts on “WiFi Controlled Robot Car Using Arduino And ESP8266”

  1. Does this project actually work “properly’?????? There is no video-clip showing the working performance of this Robotic Car ! ! ! Looks like it could be performing with random errors just like when there are Bugs in the code (paying HiWi: taking wrong turns, stopping suddenly etc).

    The reason I am asking this question is because the Node-MCU unit is inserted in some material which seems “Antistatic” foam hence all the pins would be connected together with very low resistances.

    NOTE: Antistatic materials are used to store and transport CMOS electronic chips for not getting damaged from static charges because of its conducting properties.. You learn this in the 1st year of your Electronics Degree at any university in Australia and USA.

    Reply

Leave a Comment