How to make a 2WD WiFi and Bluetooth Controlled Smart Car using ESP32 | IoT & Bluetooth car

Hello and welcome back! In this project, we will learn how to make a WiFi-controlled and Bluetooth-controlled car using an ESP32 board. For WiFi control, I have used the Blynk app, and for Bluetooth control, I have used the SriTu Hobby app. This allows the car to be controlled in two different ways. Also, using the Bluetooth remote, you can control the car gesture controls, or even use voice commands. For the car body, I used a 2WD car kit, which already includes a chassis, motors, and wheels. So, we don’t need to add those separately. To control the motors, I used an L298N motor driver. I think this project is great for school projects or just for fun experiments. If you want to make this project with an Arduino instead, please use this link.
Ok, let’s do this project step by step. The required components are given below.
- 2WD smart car kit — Our store / Amazon
- ESP32 DEVKIT V1 board — Our store / Amazon
- L298N motor driver x 1 — Our Store / Amazon
- Jumper wires — Our Store / Amazon
- ESP32 Board Adapter — Our store / Amazon
- Li-ion battery holder — Our store / Amazon
- Li-ion battery x 2 — Amazon
Disclosure: These Amazon links are Affiliate links. As an Amazon Associate, I earn from qualifying purchases.
Step 1
Firstly, identify these components.











Step 2
Next, mount the gear motors onto the chassis, then pass the wires through the designated holes.





Step 3
Next, install the caster wheel to the back of the chassis, then connect the wheels to the motors.





Step 4
Next, mount the motor driver onto the chassis, then connect the motor wires to its terminals.






Step 5
Now, connect the ESP32 board to the adapter and mount it onto the chassis. If you don’t have an adapter, you can use a breadboard instead.




Step 6
Afterward, connect the motor driver board to the ESP32 board using the circuit diagram below as a reference.



Step 7
Now, install the battery holder and connect the power wires to the motor driver following the circuit diagram above.




Step 8
OK, now let’s set up Blynk Cloud for WiFi control. Follow the steps below to complete the setup.
- First, go to the Blynk website and create a new account if you’re a new member. If you already have an account, simply log in. Then, create a new template for this project.




- Next, create 5 Virtual Pins for this project. Use the following data for that.
- Virtual PIN -> Name – speed / PIN – V0 / MIN – 0 / MAX – 255
- Virtual PIN -> Name – forward / PIN – V1 / MIN – 0 / MAX – 1
- Virtual PIN -> Name – backward / PIN – V2 / MIN – 0 / MAX – 1
- Virtual PIN -> Name – left / PIN – V3 / MIN – 0 / MAX – 1
- Virtual PIN -> Name – right / PIN – V4 / MIN – 0 / MAX – 1







- Now, click the Web Dashboard tab and create a control dashboard for the car. For that, I used one slider widget and four button widgets. You can customize them as you like.

- After that, click the gear icon on each widget one by one and select the Datastream for the widget. Then, click the save button.







- Next, click the Device tab and select the template we created earlier. Then, you will see the Blynk auth token.




Step 9
Afterward, connect the ESP32 board to the computer. Then, copy and paste the following code into the Arduino IDE. Make sure to include the Blynk library in the Arduino IDE before uploading the code.

#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>
// Define the motor pins using GPIO numbers
#define ENA 2
#define IN1 4
#define IN2 5
#define IN3 18
#define IN4 19
#define ENB 21
BlynkTimer timer;
bool forward = 0;
bool backward = 0;
bool left = 0;
bool right = 0;
bool lights = 0;
int Speed = 0;
// Enter your Auth token
char auth[] = "*************************";
// Enter your WIFI SSID and password
char ssid[] = "*****************";
char pass[] = "*****************";
void setup() {
Serial.begin(115200);
Blynk.begin(auth, ssid, pass, "blynk.cloud", 80);
// Set motor pins as outputs
pinMode(ENA, OUTPUT);
pinMode(IN1, OUTPUT);
pinMode(IN2, OUTPUT);
pinMode(IN3, OUTPUT);
pinMode(IN4, OUTPUT);
pinMode(ENB, OUTPUT);
}
BLYNK_WRITE(V0) {
Speed = param.asInt();
}
BLYNK_WRITE(V1) {
forward = param.asInt();
}
BLYNK_WRITE(V2) {
backward = param.asInt();
}
BLYNK_WRITE(V3) {
left = param.asInt();
}
BLYNK_WRITE(V4) {
right = param.asInt();
}
void WIFIcar() {
if (forward == 1) {
carForward();
Serial.println("Car moving forward");
} else if (backward == 1) {
carBackward();
Serial.println("Car moving backward");
} else if (left == 1) {
carLeft();
Serial.println("Car turning left");
} else if (right == 1) {
carRight();
Serial.println("Car turning right");
} else {
carStop();
Serial.println("Car stopped");
}
}
void loop() {
Blynk.run(); // Run Blynk library
WIFIcar();
}
/************** Motor movement functions *****************/
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 carLeft() {
analogWrite(ENA, Speed);
analogWrite(ENB, Speed);
digitalWrite(IN1, HIGH);
digitalWrite(IN2, LOW);
digitalWrite(IN3, HIGH);
digitalWrite(IN4, LOW);
}
void carRight() {
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);
}
- After that, enter the Blynk auth token and WiFi details. You can use either your mobile hotspot or your WiFi name and password for the connection.


- Now, select the correct board and port in the Arduino IDE. After that, click the Upload button to upload the code to the ESP32 board.



Step 10
Now, let’s set up the Blynk mobile app. Follow the steps below to complete the setup.
- First, download the Blynk app from the App Store or Play Store. Then, log in to your account, and you will see the template you created during the web setup.
- After that, click the Widget Configuration button and then tap the “+” icon to add widgets.

- Then, add one slider widget and four button widgets to the dashboard and customize them as you like.

- Now, click on each widget one by one and select the Datastream we created in the web dashboard. You can also customize the colors, size, and text as you like.



Step 11
Next, disconnect the USB cable and insert the batteries into the battery holder. Now, you can control the car using the Blynk web or mobile dashboard that we created earlier. Just make sure to enable your internet connection during this step.


Step 12
Now, remove the batteries and reconnect the ESP32 board to the computer to upload the Bluetooth control code. Then, copy and paste the following code into the Arduino IDE.

- Program — Download
//Include the library file
#include "BluetoothSerial.h"
BluetoothSerial SerialBT;
#define ENA 2
#define IN1 4
#define IN2 5
#define IN3 18
#define IN4 19
#define ENB 21
int Speed = 4095; //0-4095
void setup() {
Serial.begin(115200);
SerialBT.begin("SriTu Hobby"); //Bluetooth device name
Serial.println("The device started, now you can pair it with bluetooth!");
pinMode(ENA, OUTPUT);
pinMode(IN1, OUTPUT);
pinMode(IN2, OUTPUT);
pinMode(IN3, OUTPUT);
pinMode(IN4, OUTPUT);
pinMode(ENB, OUTPUT);
}
void loop() {
if (SerialBT.available()) {
//String value = SerialBT.readString();
char value = SerialBT.read();
Serial.println(value);
if (value == 'U') {
carForward();
} else if (value == 'D') {
carBackward();
} else if (value == 'L') {
carLeft();
} else if (value == 'R') {
carRight();
} else {
carStop();
}
}
}
/************** Motor movement functions *****************/
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 carLeft() {
analogWrite(ENA, Speed);
analogWrite(ENB, Speed);
digitalWrite(IN1, HIGH);
digitalWrite(IN2, LOW);
digitalWrite(IN3, HIGH);
digitalWrite(IN4, LOW);
}
void carRight() {
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);
}
- Now, select the correct board and port in the Arduino IDE. After that, click the Upload button to upload the code to the ESP32 board.



Step 13
Next, disconnect the USB cable and insert the batteries into the battery holder. Then, download the SriTu Hobby app from the Play Store.


- Next, open the controllers in the SriTu Hobby app and select the Bluetooth car remote. Then, scan for available devices, find your ESP32, and click on it to connect. Make sure to enable Bluetooth and grant location permission during this step.
- Now, you can control the car using the Bluetooth remote!
- Enjoy this project! The full video guide is provided below. We hope to see you in the next project.




Troubleshooting tips
- Check the power source.
- Check the Blynk Auth Token.
- Select the correct board and port.
- Check the WIFI details.
- Check the jumper wire connections.
- Check the app updates.
- Check the motor connections.
How to make a 2WD WiFi and Bluetooth Controlled Smart Car using ESP32 | IoT & Bluetooth car