Introduction: How to Make a WIFI (Nodemcu) Car
Today we are going to make an esp8266 smart car. This WiFi remote control car runs with ESP8266 module (NodeMCU).This NodeMCU comes with MicroUSB port and also can be operated with 7-12Volt. You can also program it with Arduino IDE (software). So that's it, let's get started!
Step 1: COMPONENTS REQUIRED
ESP8266-12E Module ( NodeMCU)
L293D Motor Driver IC - 2 Nos
DC Gear Motor - 4 Nos
7805 regulator IC
Battery 7-12V
100uF/25V Capacitor - 4 Nos
100nF Ceramic Capacitor - 2 Nos
Female Header Pins
2 Pin Screw Connectors - 5 Nos
Wheel - 4 Nos
Switch
Step 2: TOOLS NEEDED
- Soldering Iron
- Soldering Wire
- Flux
Step 3: PCB
Therefore, case you want your own PCB, you can obtain through this link on PCBWay.com. You can also order good quality PCBS from PCBWay.com at low cost. In addition to the standard pcbs, we could also support advanced Pcbs, FPC/rigid -flex Pcbs, rapid-rpototyping and other related services that could meet your needs to the most extent.
PCB order steps on PCBWay:
- Visit the website: www.pcbway.com
- Click PCB Instant QuoteClick
- quick-order PCB Upload the gerber file by clicking "+Add Gerber File" and wait until the gerber file is finished
- uploading Set the PCB specifications as you wish, starting from the number of PCBs, the number of layers, thickness, color and others.
- After that, look at the left, it will display the estimated cost
- processing time and delivery service selected
- Click Save to cart
Step 4: ASSEMBLING COMPONENTS ON PCB
Connect the components to the PCB
We are using capacitors here to get proper output..
Step 5:
Insert L293D Motor Driver IC in to IC Socket. The L293D is a popular 16-Pin Motor Driver IC.A single L293D IC is capable of running two DC motors at the same time; also the direction of these two motors can be controlled independently. We are using two IC for four motors. The IC works on the principle of Half H-Bridge...
Step 6: UPLOAD CODE ON NodeMCU
- Connect NodeMCU on PC
- Open Arduino IDE (Software)
- Then Go To Tools>Board>ESP8266 Boards> NodeMCU 1.0 (ESP-12E Module)
- Select Correct Port
- Then Upload Code Below
Step 7: CODE
// NodeMCU Based WIFI Controlled Car//
#define ENA 14 // Enable/speed motors Right GPIO14(D5)
#define ENB 12 // Enable/speed motors Left GPIO12(D6)
#define IN_1 15 // L298N in1 motors Right GPIO15(D8)
#define IN_2 13 // L298N in2 motors Right GPIO13(D7)
#define IN_3 2 // L298N in3 motors Left GPIO2(D4)
#define IN_4 0 // L298N in4 motors Left GPIO0(D3)
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
String command; //String to store app command state.
int speedCar = 800; // 400 - 1023.
int speed_Coeff = 3;
const char* ssid = "NodeMCU Car";
ESP8266WebServer server(80);
void setup() {
pinMode(ENA, OUTPUT);
pinMode(ENB, OUTPUT);
pinMode(IN_1, OUTPUT);
pinMode(IN_2, OUTPUT);
pinMode(IN_3, OUTPUT);
pinMode(IN_4, OUTPUT);
Serial.begin(115200);
// Connecting WiFi
WiFi.mode(WIFI_AP);
WiFi.softAP(ssid);
IPAddress myIP = WiFi.softAPIP();
Serial.print("AP IP address: ");
Serial.println(myIP);
// Starting WEB-server
server.on ( "/", HTTP_handleRoot );
server.onNotFound ( HTTP_handleRoot );
server.begin();
}
void goAhead(){
digitalWrite(IN_1, LOW);
digitalWrite(IN_2, HIGH);
analogWrite(ENA, speedCar);
digitalWrite(IN_3, LOW);
digitalWrite(IN_4, HIGH);
analogWrite(ENB, speedCar);
}
void goBack(){
digitalWrite(IN_1, HIGH);
digitalWrite(IN_2, LOW);
analogWrite(ENA, speedCar);
digitalWrite(IN_3, HIGH);
digitalWrite(IN_4, LOW);
analogWrite(ENB, speedCar);
}
void goRight(){
digitalWrite(IN_1, HIGH);
digitalWrite(IN_2, LOW);
analogWrite(ENA, speedCar);
digitalWrite(IN_3, LOW);
digitalWrite(IN_4, HIGH);
analogWrite(ENB, speedCar);
}
void goLeft(){
digitalWrite(IN_1, LOW);
digitalWrite(IN_2, HIGH);
analogWrite(ENA, speedCar);
digitalWrite(IN_3, HIGH);
digitalWrite(IN_4, LOW);
analogWrite(ENB, speedCar);
}
void goAheadRight(){
digitalWrite(IN_1, HIGH);
digitalWrite(IN_2, LOW);
analogWrite(ENA, speedCar/speed_Coeff);
digitalWrite(IN_3, LOW);
digitalWrite(IN_4, HIGH);
analogWrite(ENB, speedCar);
}
void goAheadLeft(){
digitalWrite(IN_1, LOW);
digitalWrite(IN_2, HIGH);
analogWrite(ENA, speedCar);
digitalWrite(IN_3, HIGH);
digitalWrite(IN_4, LOW);
analogWrite(ENB, speedCar/speed_Coeff);
}
void goBackRight(){
digitalWrite(IN_1, LOW);
digitalWrite(IN_2, HIGH);
analogWrite(ENA, speedCar/speed_Coeff);
digitalWrite(IN_3, HIGH);
digitalWrite(IN_4, LOW);
analogWrite(ENB, speedCar);
}
void goBackLeft(){
digitalWrite(IN_1, HIGH);
digitalWrite(IN_2, LOW);
analogWrite(ENA, speedCar);
digitalWrite(IN_3, LOW);
digitalWrite(IN_4, HIGH);
analogWrite(ENB, speedCar/speed_Coeff);
}
void stopRobot(){
digitalWrite(IN_1, LOW);
digitalWrite(IN_2, LOW);
analogWrite(ENA, speedCar);
digitalWrite(IN_3, LOW);
digitalWrite(IN_4, LOW);
analogWrite(ENB, speedCar);
}
void loop() {
server.handleClient();
command = server.arg("State");
if (command == "F") goAhead();
else if (command == "B") goBack();
else if (command == "L") goLeft();
else if (command == "R") goRight();
else if (command == "I") goAheadRight();
else if (command == "G") goAheadLeft();
else if (command == "J") goBackRight();
else if (command == "H") goBackLeft();
else if (command == "0") speedCar = 400;
else if (command == "1") speedCar = 470;
else if (command == "2") speedCar = 540;
else if (command == "3") speedCar = 610;
else if (command == "4") speedCar = 680;
else if (command == "5") speedCar = 750;
else if (command == "6") speedCar = 820;
else if (command == "7") speedCar = 890;
else if (command == "8") speedCar = 960;
else if (command == "9") speedCar = 1023;
else if (command == "S") stopRobot();
}
void HTTP_handleRoot(void) {
if( server.hasArg("State") ){
Serial.println(server.arg("State"));
}
server.send ( 200, "text/html", "" );
delay(1);
}Attachments
Step 8: SCHEMATIC DIAGRAM
Step 9:
After uploading the code, set NodeMCU to PCB. With this, our PCB work is completed...
Step 10: CHASSIS
Here, I have made CHASSIS using acrylic sheet .If you need it, you can buy the CHASSIS kit from the online store...What I have done here is cut the acrylic sheet to 14CM x 8 CM size and set the 4 gear motor on the 4 side. There is a battery in the middle of the 2 acrylic sheets and a switch to turn it on and off .All gear motor wires have been taken out.
Step 11: PLACE THE PCB ON TOP OF THE ACRYLIC SHEET
You can see it here, PCB board is set on an acrylic sheet using 4 screw..
Step 12: WIRING
Then set all the wires of the gear motor in the 2 pin connector on the PCB .The PCB has a total of five 2 pin connectors, One of them is the battery input and the rest is the output of the gear motor..
Step 13: TURN ON THE SUPPLY WITH THE SWITCH
Step 14: APP INSTALLATION
- Download ESP8266 WIFI ROBOT CAR
- Open wifi
- Search and connect Nodemcu Car
- Open ESP8266 WIFI ROBOT CAR






