How to control a lot of servo motors using ESP32 board with PWM servo motor driver

How to control a lot of servo motors using ESP32 board with PWM servo motor driver

Hello and welcome back. In this project, we will learn how to control a lot of servo motors using the ESP32 board with a PWM servo motor driver. Also, I have used the Blynk cloud for that. Therefore, servo motors can be controlled from anywhere in the world through the Internet.

In this project, I have used the four servo motors as an example. But you can control 16 servo motors with one PWM servo motor driver board. I think this knowledge is most important for making robotic arms, making model airplanes, and so on. It depends on your skills. Also, I created the Blynk mobile and web dashboard for this project.

(adsbygoogle = window.adsbygoogle || []).push({});
  • If you want to do this with the ESP8266 board, 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, connect the breadboards together. And then, place the ESP32 board on the breadboard.

(adsbygoogle = window.adsbygoogle || []).push({});

Step 3

Thirdly, connect the PWM servo motor driver to the ESP32 board. For that, use the circuit diagram below.

How to control a lot of servo motors using ESP32 board with PWM servo motor driver

Step 4

Next, connect the servo motors to the PWM servo motor driver board. And then, connect the ESP32 board to the computer.

Step 5

Ok, now let’s set up the Blynk web dashboard. Follow the below steps for that.

  • First, go to the Blynk website and create a new account on the Blynk cloud. Then, log into your account using your Gmail and password.
(adsbygoogle = window.adsbygoogle || []).push({});
  • Next, create a new template for this project. You can name it as you like. Select the device as ESP32.
  • And then, click the Detastreams tab and create four data streams. For that, use the following details.
  • Virtual Pin –> Name — servo one / PIN — V0 / MIN — 0 / MAX — 180
  • Virtual Pin –> Name — servo two / PIN — V1 / MIN — 0 / MAX — 180
  • Virtual Pin –> Name — servo three / PIN — V2 / MIN — 0 / MAX — 180
  • Virtual Pin –> Name — servo four / PIN — V3 / MIN — 0 / MAX — 180
  • Now, click the Web Dashboard tab and add four slider widgets to the dashboard.
  • Next, click the gear wheel icons one by one on the slider widgets. Then, select the data streams we created earlier. Finally, click the save button.
(adsbygoogle = window.adsbygoogle || []).push({});
  • Then, click the search icon and create a new device. For that select the template you created earlier.

OK, the Blynk web dashboard is ready for you.

Step 6

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

#define BLYNK_PRINT Serial
#include <Wire.h>
#include <Adafruit_PWMServoDriver.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>

Adafruit_PWMServoDriver srituhobby = Adafruit_PWMServoDriver(0x40);

#define servoMIN 150
#define servoMAX 600


// Enter your Auth token
char auth[] = "*************";

//Enter your WIFI SSID and password
char ssid[] = "***********";
char pass[] = "*************";

void setup() {
  Serial.begin(9600);
  srituhobby.begin();
  srituhobby.setPWMFreq(60);
  Blynk.begin(auth, ssid, pass, "blynk.cloud", 80);
}

BLYNK_WRITE(V0) {
  int value = param.asInt();
  value = map(value, 0, 180, servoMIN, servoMAX);
  srituhobby.setPWM(0, 0, value);
  delay(1);
}
BLYNK_WRITE(V1) {
  int value = param.asInt();
  value = map(value, 0, 180, servoMIN, servoMAX);
  srituhobby.setPWM(1, 0, value);
  delay(1);
}
BLYNK_WRITE(V2) {
  int value = param.asInt();
  value = map(value, 0, 180, servoMIN, servoMAX);
  srituhobby.setPWM(2, 0, value);
  delay(1);
}
BLYNK_WRITE(V3) {
  int value = param.asInt();
  value = map(value, 0, 180, servoMIN, servoMAX);
  srituhobby.setPWM(3, 0, value);
  delay(1);
}

void loop() {
  Blynk.run();
}
(adsbygoogle = window.adsbygoogle || []).push({});
  • Now, copy and paste the Blynk auth token. It’s available on the Blynk web dashboard.
  • Next, enter your WIFI SSID and password. Then, select the board and port.
  • Now, click the upload button. When the following message is displayed. Press and hold the boot button for two seconds.

Step 7

Now let’s set up the Blynk mobile dashboard. For that, follow the steps below.

  • First, download and install the Blynk app on your smartphone. And then, log in to your account using your email and password.
  • Next, click the template and add four slider widgets to the dashboard.
  • Now, customize these widgets as you like. Then, click one widget at a time and select the data streams you created on the Blynk web dashboard.

OK, the Blynk mobile dashboard is ready.

(adsbygoogle = window.adsbygoogle || []).push({});

Step 8

Finally, provide an external power supply to the circuit. Now you can control servo motors using Blynk mobile and web dashboards.

Ok, enjoy this project. The full video guide is below. So, see you in the next project or tutorial.

How to control a lot of servo motors using ESP32 board with PWM servo motor driver

Similar Posts

Leave a Reply

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