How to make a WIFI controlled car using Nodemcu and Blynk app – Step by step instructions
WIFI controlled car using Nodemcu
Hello guys, welcome back. In this tutorial, we are going to talk about how to make a WIFI-controlled car using Nodemcu. Nodemcu ESP8266 board and Blynk application are mainly used for this. Also, this can be easily controlled by your smartphone. We have described to you step-by-step how to do this through this tutorial.
Process of this WIFI controlled car
- Nodemcu ESP8266 x 1 — Amazon / Our Store
- L298N motor driver x 1 — Amazon / Our Store
- Gear motor x 4 — Amazon /Our Store
- Robot wheel x 4 — Amazon / Our Store
- Battery holder x 1 — Amazon/ Our Store
- Li-ion battery x 2 — Amazon / Banggood
- Jumper wires — Amazon / Our Store
- Breadboard x 1 — Amazon / Our Store
- Foamboard piece — Amazon / Banggood
Step 1
Nodemcu ESP8266
L298N motor driver
Gear motor
Robot wheel
Battery holder
Li-ion battery
Jumper wires
Breadboard
Foamboard piece
Step 2
Step 3
Step 4
Step 5
Step 6
Step 7
- First, run the Blynk app on your smartphone. Then, click the “New project” button and enter the project name as you like. After, select the device and connection type. Finally, click the “Confirm” button.
- OK, now we add to the widget interface. To do this, click the “+” button and add four “Styled buttons”. After, arrange them as follows.
- Now, let’s set up these buttons. First, click the up button and enter the button name as you like. After, change the PIN value to “virtual V0”. Change the edge type to “PILL” mode.
- Second, click the down button and enter the button name as you like. After, change the PIN value to “virtual V1”. Change the edge type to “PILL” mode.
- Third, click the left button and enter the button name as you like. After, change the PIN value to “virtual V2”. Change the edge type to “PILL” mode.
- Last, click the right button and enter the button name as you like. After, change the PIN value to “virtual V3”. Change the edge type to “PILL” mode.
- Then, we can see the buttons as follows.
- Then, click again the “+” button and add a slider widget. After, click this widget and named it as you like. Change the PIN to “virtual V4”.
- Lastly, arrange these buttons as follows.
Step 8
/*Nodemcu ESP8266 WIFI control car.
* This code created by sritu hobby team.
* https://srituhobby.com
*/
#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 application 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);
}
Code explanation
- If the forward variable value is 1, the smart car moves forward.
- If the backward variable value is 1, the smart car moves backward.
- If the left variable value is 1, the smart car moves left.
- If the right variable value is 1, the smart car moves right.
Step 9
Step 10
Step 11
How to make a WIFI controlled car using Nodemcu and Blynk app – Step by step instructions
minimum how many volt battery is required to run this project
9v batteries are good for this project
Sir When i used the code it showing error that the D0 is not in the scope
It is your error. Check again your program.
DO was not declared in this scope. How to fix this problem sir?
I checked my program. Please check your program and upload it
thanks a lot , for this amazing tutorial & helping with code !!!!!!!!
Your welcome.
i am getting error , urlk was not declared in this scope
how to fix this error. pls help me bro
Please check again that program and try again.
i made same circuit but motor shows no activity
Please check your gear motors
Our blynk always disconnected when we press the widget. please help me
Please check your WIFI connection details
c:\Users\Dhruthi\Documents\Arduino\libraries\Blynk\src/Blynk/BlynkApi.h:39:6: error: #error “Please specify your BLYNK_TEMPLATE_ID and BLYNK_TEMPLATE_NAME”
39 | #error “Please specify your BLYNK_TEMPLATE_ID and BLYNK_TEMPLATE_NAME”
| ^~~~~
exit status 1
Compilation error: exit status 1
this is the error i am receiving
Check your Blynk Auth token and WIFI details.
I am looking to use this on a WiFi network where I have a username and password to access WiFi. How could I add this to the code below?
char auth[] = “”; //Enter your Blynk application auth token
char ssid[] = “”; //Enter your WIFI name
char pass[] = “”; //Enter your WIFI password
Please visit our basic tutorial