How to make a WIFI control Truck with RoboHeart electronic kit

Hello and welcome back. In this project, we will learn how to make a WIFI control Truck with RoboHeart electronic kit. This kit mainly includes the Toy truck and RoboHeart development board.

What’s this board?

It is designed using the ESP32 microcontroller and includes various other features. Ex-: Motor drivers. You can use this board as a normal ESP32 (WROOM32) board and there are several RoboHeart libraries for the convenience of using this, so you can download them through the link below. Also, we can use a single-cell lipo battery or USB cable (Type C) to power up this board.

Since this board has WiFi and Bluetooth, it can be controlled through both these methods. But in this project, I used WIFI technology. Therefore, we can control this truck using the Blynk app. Also, I’m sharing my personal experience with the RoboHeart development board. Through this, we can do different types of projects and it depending on your knowledge and requirement. We will make different types of projects in the next articles using this board.

  • More details on the ROBOHEART website – Read me

Ok, let’s do it step by step. The required components are given below.

Step 1

Firstly, get this truck and remove the top using a screwdriver. Now, we can see the RoboHeart development board.

Step 2

Secondly, remove the battery compartment and put the single-cell lipo battery. And then, connect it again.

Step 3

Thirdly, connect this board to the computer and switch on this truck.

Step 4

Now, let’s set up the Blynk web dashboard. For that, follow the instructions below.

  • First, go to the Blynk website and create a new account using your Gmail address. And then, log in to your account and create a new template for this project. I have created it as a “WIFI Truck”. Next, select the hardware type ESP32.

  • Next, create five datastreams using the details below.
  • Virtual Pin —- Name -> Forward / PIN –> V0 / MIN -> 0 / MAX -> 1
  • Virtual Pin —- Name -> Backward / PIN –> V1 / MIN -> 0 / MAX -> 1
  • Virtual Pin —- Name -> Left / PIN –> V2 / MIN -> 0 / MAX -> 1
  • Virtual Pin —- Name -> Right / PIN –> V3 / MIN -> 0 / MAX -> 1
  • Virtual Pin —- Name -> Speed / PIN –> V4 / MIN -> 0 / MAX -> 255

  • Now, click the WebDashboard tab and create a dashboard for controlling this tank. For that, I used one slider widget and four button widgets.

  • Next, click the one-by-one gear wheel icons on the widgets and select the datastreams we created earlier.

  • And then, click the save and apply button. Next, click the search icon button and create a new device for this project. For that, select the template we created above.

OK, the Blynk web dashboard is ready for you.

Step 5

Now, let’s create the program for this project. It’s as follows.

  • Full details of this project — Download

#include <RoboHeart.h>
#define BLYNK_PRINT Serial
#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>

RoboHeart heart = RoboHeart(Serial);

bool Carforward = 0;
bool Carbackward = 0;
bool Carleft = 0;
bool Carright = 0;
int Speed;

// Enter your Auth token
char auth[] = "";
//Enter your WIFI SSID and password
char ssid[] = "";
char pass[] = "";

void setup() {
  // Set up the RoboHeart
  heart.begin();
  Blynk.begin(auth, ssid, pass, "blynk.cloud", 80);

}

BLYNK_WRITE(V0) {
  Carforward = param.asInt();
}

BLYNK_WRITE(V1) {
  Carbackward = param.asInt();
}

BLYNK_WRITE(V2) {
  Carleft = param.asInt();
}

BLYNK_WRITE(V3) {
  Carright = param.asInt();
}

BLYNK_WRITE(V4) {
  Speed = param.asInt();
}

void loop() {
  Blynk.run();
  smartcarTurn();
  smartcarMove();
  heart.beat();
}

void smartcarTurn() {
  if (Carleft == 1) {
    left();
    } else if (Carright == 1) {
    right();
  } else if (Carleft == 0 && Carright == 0) {
    motorBStop();
  }
}

void smartcarMove() {
  if (Carforward == 1) {
    forward();
  } else if (Carbackward == 1) {
    backward();
  } else if (Carforward == 0 && Carbackward == 0) {
    motorCStop();
  }
}

void forward() {
  heart.motorC.forward(Speed);
  delay(5);
  heart.motorC.coast();
}

void backward() {
  heart.motorC.reverse(Speed);
  delay(5);
  heart.motorC.coast();
}

void left() {
  heart.motorB.reverse(255);
  delay(10);
  heart.motorB.coast();
}

void right() {
  heart.motorB.forward(255);
  delay(10);
  heart.motorB.coast();
}

void motorBStop() {
  heart.motorB.brake();
}

void motorCStop() {
  heart.motorC.brake();
}

  • Next, copy and paste the Blynk auth token into the program. It’s in the Blynk web dashboard.

  • And then, enter your WIFI SSID and password. Next, select board and port.

  • Finally, click the upload button and hold the boot button for 2 or 3 seconds while the program uploads.

Step 6

Now, remove the USB cable and reconnect the top of the truck.

Step 7

Now, let’s create the Blynk mobile dashboard. For that, follow the instructions below.

  • First, download and install the Blynk app from the Play store or app store. Then, log into your account and click on the template we created on the web dashboard. Then, add one slider widget and four button widgets to the dashboard.

  • Next, click the one-by-one widgets and select the data streams we created in the web dashboard.

Ok, the Blynk mobile dashboard is ready for you.

Now, you can control this truck using your computer or smartphone. The full video guide is below. So, see you in the next project or tutorial.

How to make a WIFI control Truck with RoboHeart electronic kit

Leave a Comment

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

Shopping Cart