Page 1 of 1

GPIO0 PWM Peak to Peak Voltage

Posted: Mon Jul 21, 2025 7:23 pm
by jgrunschel
I have some ESP-WROOM-32 modules and I noticed that the PWM voltage on GPIO0 does not actually go to 0V. PWM on other pins behaves as expected. Here is a pinout of the ESP modules:
WROOM Mini D1 Pinout.png
WROOM Mini D1 Pinout.png (253.5 KiB) Viewed 141 times

I attached the negative oscilloscope probe to the ground pin on the outside row of the right side GPIO header. The positive probe was attached to GPIO0.
OScope.JPG
OScope.JPG (8.35 MiB) Viewed 141 times

And here is the oscilloscope result:
OScopeScreen.JPG
OScopeScreen.JPG (238.28 KiB) Viewed 141 times

Lastly, here is the code I'm using to generate the PWM. I'm using the Arduino IDE serial interface to adjust the PWM on two different pins (Channel 1 - GPIO2 & Channel 2 - GPIO0):

Code: Select all

const byte numChars = 6;
char receivedChars[numChars];
char pwm[4];

const byte ch1pwm = 2;
const byte ch2pwm = 0;

boolean newData = false;
byte recSize = 0;

void setup() {
  // set up pins
  pinMode(ch1pwm, OUTPUT);
  pinMode(ch2pwm, OUTPUT);
  
  // begin serial
  Serial.begin(115200);
}

void loop() {
  static byte ndx = 0;
  char endMarker = '\n';
  char rc;
  
  while (Serial.available() > 0 && !newData) {
    rc = Serial.read();

    if (rc != endMarker) {
      receivedChars[ndx] = rc;
      ndx++;
      if (ndx >= numChars) {
        ndx = numChars - 1;
      }
    }
    else {
        receivedChars[ndx] = '\0'; // terminate the string
        recSize = ndx - 1;
        ndx = 0;
        newData = true;
    }
  }

  if (newData) {
    newData = false;

    if (recSize > 1) {
      strncpy(pwm, receivedChars + 1, recSize - 1);
      pwm[recSize - 1] = '\0';

      if (receivedChars[0] == '1') {
        Serial.print("Channel 1: ");
        Serial.println(pwm);
        analogWrite(ch1pwm, atoi(pwm));
      }

      if (receivedChars[0] == '2') {
        Serial.print("Channel 2: ");
        Serial.println(pwm);
        analogWrite(ch2pwm, atoi(pwm));
      }
    }
  }
}

I think I can only attach three files, so I will reply with the oscilloscope result of Channel 1 (GPIO2) to show that it is normal.

Re: GPIO0 PWM Peak to Peak Voltage

Posted: Mon Jul 21, 2025 7:24 pm
by jgrunschel
Here is the oscilloscope result for Channel 1 (GPIO2):
GPIO2.JPG
GPIO2.JPG (81.03 KiB) Viewed 140 times

Re: GPIO0 PWM Peak to Peak Voltage

Posted: Tue Jul 22, 2025 7:31 am
by MicroController
GPIO0 is a strapping pin and connected to the "auto programming" circuit and the USB-serial chip. This can interfere with any other signals you want to use it for. Better not use GPIO0 on a board with this circuit.

Re: GPIO0 PWM Peak to Peak Voltage

Posted: Tue Jul 22, 2025 3:34 pm
by jgrunschel
Ah, noted. Thank you!