WiFi Based Remote Control Car(Robotics Project)
The Bluetooth-controlled robot project focuses on developing a robot that can be controlled through a mobile application using the Blynk platform. This integration allows for remote control via a WiFi connection, enabling users to send commands to the robot and monitor its status in real-time. The project leverages components like the ESP32, motor drivers, DC motors, and an LCD for status display. This project aims to enhance understanding of WiFi-based communication, motor control, and mobile app interfacing with microcontrollers.
Project : 7
Wi-Fi Controlled Robot Mobile App
Introduction
The Bluetooth-controlled robot project focuses on developing
a robot that can be controlled through a mobile application using the Blynk
platform. This integration allows for remote control via a WiFi connection,
enabling users to send commands to the robot and monitor its status in
real-time. The project leverages components like the ESP32, motor drivers, DC
motors, and an LCD for status display. This project aims to enhance
understanding of WiFi-based communication, motor control, and mobile app
interfacing with microcontrollers.
Components Required
- ESP32:
A powerful microcontroller with built-in WiFi and Bluetooth capabilities.
- HC-05
Bluetooth Module: Facilitates Bluetooth communication between the
mobile device and the Arduino.
- L298N
Motor Driver: Controls the speed and direction of the DC motors.
- DC
Motors: Provide movement for the robot, typically two or four motors
are used.
- Chassis:
The frame of the robot to which all components are attached.
- Wheels:
Attached to the DC motors for movement.
- Power
Supply: Typically a battery pack to power the ESP32 and motors.
- Connecting
Wires: For connecting all components.
- LiquidCrystal_I2C
Display: An optional component to display the status of the robot.
Pin Configuration
- Motor
Driver Pins:
- in1:
27
- in2:
26
- in3:
25
- in4:
33
Libraries Used
- BlynkSimpleEsp32.h:
For interfacing with the Blynk platform.
- Wire.h:
For I2C communication.
- WiFi.h:
For WiFi connectivity.
- LiquidCrystal_I2C.h:
For interfacing with the LCD display.
Circuit Diagram:
Code:
//Copy the blynk credential from your acoount device and
paset it here
#define BLYNK_TEMPLATE_ID "TMPL670BbO1Nl"
#define BLYNK_TEMPLATE_NAME "Data Monitoring"
#define BLYNK_AUTH_TOKEN
"4Q5w-qYfY3jO82qXBaL3O0E3irLFfDwb"
#define BLYNK_PRINT Serial
#include <BlynkSimpleEsp32.h>
#include <Wire.h>
#include <WiFi.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);
#define in1 27
#define in2 26
#define in3 25
#define in4 33
char auth[] = BLYNK_AUTH_TOKEN;
char ssid[] = "nepatronix_2.4"; //Enter your WIFI SSID name
char pass[] = "CLB269DA03"; //Enter your WIFI password
BlynkTimer timer;
// Get the button value
BLYNK_WRITE(V0) {
bool Value =
param.asInt();
if (Value == 1) {
// If 1 receive then turn ON
forward();
display(1, 0,
"FORWARD");
} else {// Else
turn OFF
stop();
display(1, 0,
"STOP");
}
}
// Get the button value
BLYNK_WRITE(V1) {
bool Value = param.asInt();
if (Value == 1) {
// If 1 receive then turn ON
backward();
display(1, 0,
"BACKWARD");
} else {// Else
turn OFF
stop();
display(1, 0,
"STOP");
}
}
// Get the button value
BLYNK_WRITE(V2) {
bool Value =
param.asInt();
if (Value == 1) {
// If 1 receive then turn ON
right();
display(1, 0,
"RIGHT");
} else {// Else
turn OFF
stop();
display(1, 0,
"STOP");
}
}
// Get the button value
BLYNK_WRITE(V3) {
bool Value =
param.asInt();
if (Value == 1) {
// If 1 receive then turn ON
left();
display(1, 0,
"LEFT");
} else {// Else
turn OFF
stop();
display(1, 0,
"STOP");
}
}
void setup() {
Serial.begin(115200);
Wire.begin();
lcd.init();
lcd.clear();
lcd.backlight();
lcd.setCursor(1,
0);
lcd.print("**NEPATRONIX**");
delay(2000);
lcd.clear();
Blynk.begin(auth,
ssid, pass); //Connecting to Blynk Server with ssid and password
delay(500);
Serial.println(WiFi.localIP());
pinMode(in1,
OUTPUT);
pinMode(in2, OUTPUT);
pinMode(in3,
OUTPUT);
pinMode(in4,
OUTPUT);
}
void loop() {
Blynk.run();
//run the blynk function in loop
timer.run();
}
void display(int col, int row, String msg) {
lcd.clear();
lcd.setCursor(col, row);
lcd.print(msg);
}
void forward() {
digitalWrite(in1,
LOW);
digitalWrite(in2,
HIGH);
digitalWrite(in3,
LOW);
digitalWrite(in4,
HIGH);
}
void backward() {
digitalWrite(in1,
HIGH);
digitalWrite(in2,
LOW);
digitalWrite(in3,
HIGH);
digitalWrite(in4,
LOW);
}
void right() {
digitalWrite(in1,
HIGH);
digitalWrite(in2,
LOW);
digitalWrite(in3,
LOW);
digitalWrite(in4,
HIGH);
}
void left() {
digitalWrite(in1,
LOW);
digitalWrite(in2,
HIGH);
digitalWrite(in3,
HIGH);
digitalWrite(in4,
LOW);
}
void stop() {
digitalWrite(in1,
LOW);
digitalWrite(in2,
LOW);
digitalWrite(in3,
LOW);
digitalWrite(in4,
LOW);
}
Working
- Initialization:
- The
ESP32 initializes the serial communication at a baud rate of 115200.
- The
I2C LCD display is initialized, and a welcome message is displayed.
- The
ESP32 connects to the Blynk server using the provided credentials (auth
token, WiFi SSID, and password).
- The
motor driver pins are configured as outputs.
- Main
Loop:
- The
program runs the Blynk and timer functions continuously.
- The Blynk
platform listens for button presses on the mobile app and sends
corresponding commands to the robot.
- Control
Functions:
- Forward:
Sets motor driver pins to move the robot forward.
- Backward:
Sets motor driver pins to move the robot backward.
- Right:
Sets motor driver pins to turn the robot right.
- Left:
Sets motor driver pins to turn the robot left.
- Stop:
Sets motor driver pins to stop the robot.
- The
current action is displayed on the LCD.
Testing
- Setup:
Assemble the robot and connect all components as per the pin
configuration.
- Power
Up: Turn on the power supply and ensure the ESP32 and motors are
receiving power.
- WiFi
Connection: Ensure the ESP32 is connected to the specified WiFi
network.
- Blynk
App: Configure the Blynk app with the provided template ID and auth
token.
- Commands:
Test each command ('F', 'B', 'R', 'L', 'S') and verify the robot's
response.
- Display:
Check the LCD to ensure it displays the correct status messages.
Conclusion
This Bluetooth-controlled robot project successfully
demonstrates how to integrate WiFi communication with robotics using the ESP32
and the Blynk platform. The project provides practical experience in
controlling a robot via a mobile application, enhancing understanding of
WiFi-based communication, motor control, and interfacing microcontrollers with
external devices. This hands-on project serves as a foundation for more
advanced robotic and IoT applications.