This project implements an advanced autonomous line-following robot using ESP32, an 8-channel sensor array, Bluetooth communication, and a PID control algorithm.
The robot continuously reads line sensor values, calculates the line position, determines the error from the center, and dynamically adjusts motor speeds using PID control for smooth and accurate navigation.
A Bluetooth interface allows real-time tuning of PID parameters without reprogramming the microcontroller, making it ideal for robotics competitions and research applications.
FeaturesAutonomous Line Following- Real-time line detection
- 8-channel sensor array
- Weighted position calculation
- Dynamic steering correction
- Proportional Control (Kp)
- Integral Control (Ki)
- Derivative Control (Kd)
Provides:
- Smooth turns
- Reduced oscillations
- Faster line recovery
- Stable navigation
- Wireless parameter adjustment
- Real-time PID tuning
- Remote start and stop control
- Independent left and right motor control
- PWM speed regulation
- Direction control support
Component
Quantity
ESP32 Development Board
1
TB6612FNG Motor Driver
1
IR Sensor Array (8 Channel)
1
DC Gear Motors
2
Li-ion Battery Pack
1
Chassis
1
System ArchitectureIR Sensor Array ↓ ESP32 ↓ Position Detection ↓ PID Controller ↓ Motor Driver ↓ DC Motors ↓ Robot Navigation
Bluetooth App ↓ ESP32 ↓ PID Parameter Update
Sensor ConfigurationSensor
GPIO
Sensor 1
GPIO32
Sensor 2
GPIO33
Sensor 3
GPIO34
Sensor 4
GPIO35
Sensor 5
GPIO25
Sensor 6
GPIO26
Sensor 7
GPIO27
Sensor 8
GPIO23
Motor Driver ConnectionsLeft MotorAIN1 → GPIO2
AIN2 → GPIO4
PWMA → GPIO13
Right MotorBIN1 → GPIO18
BIN2 → GPIO19
PWMB → GPIO14
StandbySTBY → GPIO5
Bluetooth ConfigurationDevice Name:
LineFollower
Connect using any Bluetooth terminal or custom Android application.
Working PrincipleSensor CalibrationAt startup:
- Reads all sensor values
- Calculates minimum values
- Calculates maximum values
- Generates calibration reference
This improves performance under different lighting conditions.
Position DetectionEach sensor contributes to a weighted average calculation:
Position = Weighted Sum / Total Sensor Value
Center Position = 3500
Error = Position − Center
PID ControllerError is processed using:
P = Current Error
I = Accumulated Error
D = Change in Error
PID Output:
PID = Kp × P + Ki × I + Kd × D
Motor speeds are adjusted accordingly.
Bluetooth CommandsSet KpCommand ID = 1
Set KiCommand ID = 3
Set KdCommand ID = 5
Start/Stop RobotCommand ID = 7
Software LibrariesRequired Libraries:
- BluetoothSerial
- ESP32 Arduino Core
Install ESP32 Board Package.
Step 2Upload firmware.
Step 3Power the robot.
Step 4Allow sensor calibration to complete.
Step 5Connect to Bluetooth device:
LineFollower
Step 6Tune PID values.
Step 7Start autonomous navigation.
Applications- Line Following Competitions
- Autonomous Navigation
- Industrial AGV Research
- Warehouse Robots
- Educational Robotics
- Embedded Control Systems
- PID Control Experiments
✔ Real-Time PID Tuning
✔ Bluetooth Controlled
✔ High Accuracy Tracking
✔ Sensor Auto Calibration
✔ Smooth Navigation
✔ Embedded Intelligence
✔ Competition Ready
Future Improvements- OLED Status Display
- Mobile PID Dashboard
- Data Logging
- AI-Based Path Prediction
- Maze Solving Algorithm
- Obstacle Avoidance
- WiFi Monitoring
- ROS Integration
✔ ESP32 Based
✔ Bluetooth Communication
✔ PID Controlled Navigation
✔ 8 Sensor Array
✔ Autonomous Robotics
✔ Embedded Systems
✔ Real-Time Control
✔ Competition Grade Design
AuthorHariharan Balakrishnan
B.E Electronics and Communication Engineering
Embedded Systems | Robotics | IoT | Edge AI | ESP32 | Zephyr RTOS






_t9PF3orMPd.png?auto=compress%2Cformat&w=40&h=40&fit=fillmax&bg=fff&dpr=2)




Comments