How to make a Bluetooth control tank using ESP32 DEVKIT V1 board

How to make a Bluetooth control tank using ESP32 DEVKIT V1 board

Hello and welcome back. In this project, we will learn how to make a Bluetooth control tank using the ESP32 DEVKIT V1 board. For that, I used the ESP32 board with built-in Bluetooth and the SriTu Hobby Bluetooth controller. To control the motors, we’re using the L298N motor driver board. I also chose a pre-assembled tank for this project, which you can purchase through this link. But, you can do this without this tank. It depends on your skill level.

  • If you want to visit more ESP32-based projects, please use this link.

OK let’s do this project step by step. The required components are given below.

Disclosure: These Amazon links are Affiliate links. As an Amazon Associate, I earn from qualifying purchases.

Step 1

Firstly, identify these components.

Step 2

Secondly, cut two foam board pieces for the motor driver board and ESP32 board adapter. Then, paste these pieces on these components.

Step 3

Thirdly, install the motor driver board on the tank. Then, connect the motors to it.

Step 4

Next, connect the ESP32 board to the adapter. Then, install it on the tank.

Step 5

After that, connect the motor driver board to the ESP32 board. For that, use the circuit diagram below.

How to make a Bluetooth control tank using ESP32 DEVKIT V1 board

Step 6

Next, install the battery holder back side of this tank and connect it to the motor driver.

Step 7

Now, connect this tank to the computer. Then, copy and paste the following program to the Arduino IDE.

How to make a Bluetooth control tank using ESP32 DEVKIT V1 board
//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') {
      Forward();
    } else if (value == 'D') {
      Backward();
    } else if (value == 'L') {
      Left();
    } else if (value == 'R') {
      Right();
    } else {
      Stop();
    }
  }
}

void Forward() {
  analogWrite(ENA, Speed);
  analogWrite(ENB, Speed);
  digitalWrite(IN1, HIGH);
  digitalWrite(IN2, LOW);
  digitalWrite(IN3, HIGH);
  digitalWrite(IN4, LOW);
}
void Backward() {
  analogWrite(ENA, Speed);
  analogWrite(ENB, Speed);
  digitalWrite(IN1, LOW);
  digitalWrite(IN2, HIGH);
  digitalWrite(IN3, LOW);
  digitalWrite(IN4, HIGH);
}
void Stop() {
  digitalWrite(IN1, LOW);
  digitalWrite(IN2, LOW);
  digitalWrite(IN3, LOW);
  digitalWrite(IN4, LOW);
}
void Left() {
  analogWrite(ENA, Speed);
  analogWrite(ENB, Speed);
  digitalWrite(IN1, HIGH);
  digitalWrite(IN2, LOW);
  digitalWrite(IN3, LOW);
  digitalWrite(IN4, HIGH);
}
void Right() {
  analogWrite(ENA, Speed);
  analogWrite(ENB, Speed);
  digitalWrite(IN1, LOW);
  digitalWrite(IN2, HIGH);
  digitalWrite(IN3, HIGH);
  digitalWrite(IN4, LOW);
}
  • Next, select the board and port. After, click the upload button.

Step 8

Now, remove the USB cable and put the batteries into the battery holder.

How to make a Bluetooth control tank using ESP32 DEVKIT V1 board

Step 9

Next, let’s set up the Bluetooth controller. For that, I used our SriTu Hobby app.

  • First, download and install it from the Play Store.
  • Then, open this app and click on the control tab. After that, select your remote control.
  • Now, click the gear wheel button and click the “Connect to device” button. Then, you can select your device. In this case, you have to enable location and location permission.
  • If you complete all the steps, the app will connect and you will see the green indicator.

Now, you can test this project. The full video guide is below. So, we hope to see you in the next project.

Troubleshooting

  • Check jumper wires.
  • Check motor wire connections.
  • Check the motor driver board.
  • Update the SriTu Hobby app.
How to make a Bluetooth control tank using ESP32 DEVKIT V1 board

How to make a Bluetooth control tank using ESP32 DEVKIT V1 board

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *