GPIO0 PWM Peak to Peak Voltage

jgrunschel
Posts: 4
Joined: Mon Jul 21, 2025 4:33 pm

GPIO0 PWM Peak to Peak Voltage

Postby jgrunschel » Mon Jul 21, 2025 7:23 pm

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 140 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 140 times

And here is the oscilloscope result:
OScopeScreen.JPG
OScopeScreen.JPG (238.28 KiB) Viewed 140 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.

jgrunschel
Posts: 4
Joined: Mon Jul 21, 2025 4:33 pm

Re: GPIO0 PWM Peak to Peak Voltage

Postby jgrunschel » Mon Jul 21, 2025 7:24 pm

Here is the oscilloscope result for Channel 1 (GPIO2):
GPIO2.JPG
GPIO2.JPG (81.03 KiB) Viewed 139 times

MicroController
Posts: 2672
Joined: Mon Oct 17, 2022 7:38 pm
Location: Europe, Germany

Re: GPIO0 PWM Peak to Peak Voltage

Postby MicroController » Tue Jul 22, 2025 7:31 am

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.

jgrunschel
Posts: 4
Joined: Mon Jul 21, 2025 4:33 pm

Re: GPIO0 PWM Peak to Peak Voltage

Postby jgrunschel » Tue Jul 22, 2025 3:34 pm

Ah, noted. Thank you!

Who is online

Users browsing this forum: Bing [Bot], ChatGPT-User, Qwantbot, Semrush [Bot] and 2 guests