PWM issues on ESP32

I have an problem with controling a dc motor with the TB6612FNG driver, i dont’t get enough voltage from the pwm it.s around 1V. Can anyone help me with that? I tried so many things with chat gpt. I’m using ledcwrite. The PWM is on GPIO 5. Thanks for your time

Welcome!
Simple just use a voltage stretcher and set it at x5. The ones made at the North Pole are the best!

How to Get the Right Help Faster:

You can spend weeks spinning your wheels, or you might get lucky and solve your problem quickly. To avoid unnecessary delays, it’s crucial to provide an annotated schematic of your circuit as you have it wired, showing all connections, including power, ground, and power supplies.

Why Detailed Information Matters:

Annotated Schematics: These are essential because they show exactly how your circuit is set up. Without them, it's difficult for anyone to understand what you’ve done, which makes troubleshooting nearly impossible. Fritzing diagrams or unclear pictures are not enough.

Technical Information: Many modules look similar and may even have the same name, but they can function differently. This is why we always ask for links to detailed technical information—not just sales pages like those on Amazon, which often lack the specifics we need.

Post your Software Without that we do not have a clue as to how it is expected to operate.

Show All Connections: It’s important to include every connection, especially power and ground, in your schematic. Missing these details makes it hard to determine if a setup issue might be causing your problem.

My Process:

When I see a question, I spend a moment assessing it. If it’s missing critical information, I might ask for it. However, if it's repeatedly lacking important details, I may assume the questioner is not serious and move on to another query.

What You Need to Consider:

We don’t know your skill level or what resources you have available. If you’re missing key technical details or seem unprepared, it may indicate that you need to spend more time learning the basics before starting your project.

Providing the right information upfront will help you get the best possible assistance and avoid the frustration of running into dead ends. Let us help you by sharing what you have clearly and completely!

Try reading this: How to get the best out of this forum

2 Likes

How are you measuring the voltage ?

A post was split to a new topic: Issues connecting ESP-32 DevKit v1 to Arduino IDE

It is kinda strange. Must be 3.3v. Can you set DUTY to 100% and measure voltage again?

If you just measure DC voltage on a live PWM pin with 50% duty then it is very unlikely that you can get correct reading.

So, I have an RC Car project with ESP32 conected via Bluetooth to an app created with mit app inventor. It controls two dc motors with the tb6612fng driver the (red one) and an mg996 servomotor. I have external power source. The code works it conects to the bluetooth the comands are working but ii seems the dc motors don’t get enough power. I read something it can be a problem with the pwm comands from the cod, or the motor driver has some problems, few days ago worked. Eventually can you help me with a corect version for the cod controlling the motors, which sintax may i use? Thanks for you time once more

Hi, @lorand0208
Welcome to the forum.

Sorry but I had to edit your post to make it clear what you are saying.

https://forum.arduino.cc/t/how-to-get-the-best-out-of-this-forum

Can you please post a copy of your circuit, a picture of a hand drawn circuit in jpg, png?
Hand drawn and photographed is perfectly acceptable.
Please include ALL hardware, power supplies, component names and pin labels.

Can you please post your code?

Tom.... :smiley: :+1: :coffee: :australia:

#include "BluetoothSerial.h"
BluetoothSerial SerialBT;

// Pini driver motoare TB6612FNG
#define AIN1 18
#define AIN2 19
#define PWMA 5

#define BIN1 16
#define BIN2 17
#define PWMB 4

#define STBY 2

String comanda = "";
char ultimaComanda = 'S';

void setup() {
  Serial.begin(9600);
  SerialBT.begin("MasinutaRC");

  pinMode(AIN1, OUTPUT);
  pinMode(AIN2, OUTPUT);
  pinMode(BIN1, OUTPUT);
  pinMode(BIN2, OUTPUT);
  pinMode(STBY, OUTPUT);

  digitalWrite(STBY, HIGH);

  ledcSetup(0, 1000, 8);
  ledcAttachPin(PWMA, 0);

  ledcSetup(1, 1000, 8);
  ledcAttachPin(PWMB, 1);
}

void loop() {
  

  if (SerialBT.available()) {
    char c = SerialBT.read();
    comanda = String(c);
    ultimaComanda = S;

    if (comanda == "F") {
      forward();
    } else if (comanda == "B") {
      backwards();
    } else if (comanda == "S") {
      stop();
    }
  } else if (comanda == "B") {
      backwards();
    } 
    if (comanda == "S") {
      stop();
    }  
  }
}

// ====== FUNCȚII =======
void forward() {
  digitalWrite(AIN1, HIGH);
  digitalWrite(AIN2, LOW);
  digitalWrite(BIN1, HIGH);
  digitalWrite(BIN2, LOW);
  ledcWrite(0, 200);
  ledcWrite(1, 200);
}

void backwards() {
  digitalWrite(AIN1, LOW);
  digitalWrite(AIN2, HIGH);
  digitalWrite(BIN1, LOW);
  digitalWrite(BIN2, HIGH);
  ledcWrite(0, 200);
  ledcWrite(1, 200);
}

void stop() {
  digitalWrite(AIN1, LOW);
  digitalWrite(AIN2, LOW);
  digitalWrite(BIN1, LOW);
  digitalWrite(BIN2, LOW);
  ledcWrite(0, 0);
  ledcWrite(1, 0);
}

If this doesn't give 3.3V, you have something wrong with your Esp (or power supply).
ledcWrite(0, 255);

I will test a little bit later to see if just the gpio5 is broken, or the rest of the pins also...
The power supply seems to be ok. (Its two 18650 batteries with a V3 Charging Shield)

Hi, @lorand0208

If you wrote your code in stages, when did you lose control of the motors?

You should have some code during the development of you code that JUST tests the motors, no Bluetooth.

If not then please write some code that JUST controls one motor, no Bluetooth.

You need to do some basic trouble shooting, from the basics.

Tom.... :smiley: :+1: :coffee: :australia: