ESP32 AnalogWrite library output voltage

I am using the ESP32_AnalogWrite library in order to use a type of analogWrite.

#include <Arduino.h>
#include <analogWrite.h>

int brightStep = 1;
int brightness = 0;
uint8_t ledR = 34;
uint8_t ledG = 35;
uint8_t ledB = 32;
uint8_t ledW = 33;

void setup()
{

  // Set resolution for a specific pin
  analogWriteResolution(ledR, 12);
  analogWriteResolution(ledG, 12);
  analogWriteResolution(ledB, 12);
  analogWriteResolution(ledW, 12);

  analogWrite(ledR, 255);
  analogWrite(ledG, 255);  
  analogWrite(ledB, 255);
  analogWrite(ledW, 255);
 
}

void loop() {}

This outputs
ledR = 0 = GPIO34
ledG = 0 = GPIO35
ledB = 1.6 V = GPIO32
ledW = 1.6 V = GPIO33

Why?

Basic ESP32 stuff.

The ESP32 has 2 32 BIT ports.

portA, pins 0 to 31.

portB pins 32+.

portB, pins 32+, is especially designed as an INPUT ONLY port, see ESP32 API documentation API Reference - ESP32 - — ESP-IDF Programming Guide latest documentation. The reason is that portB is tuned for Analog reads; reads as in inputs.

Thus, trying to make portB into an output port, pins 32+, is possible.

Just like, you can program portA to read analog voltages but expect issues like WDT, Guru Meditation, and core dump errors. Yes, the pin matrix can be programmed to have portA read analog but...

Oh, get and install the "ESP EXCEPTION DECODER", it will come in handy for when you get those core dumps.

So long story short, pins 34, 35, 36, 39 are input only:

Although, why is it not going to 3.3 V?

adamelli:
So long story short, pins 34, 35, 36, 39 are input only:

ESP32 Pinout Reference: Which GPIO pins should you use? | Random Nerd Tutorials

Yes.

Thanks.

Why is it not going to 3.3 V though?

adamelli:
So long story short, pins 34, 35, 36, 39 are input only:

ESP32 Pinout Reference: Which GPIO pins should you use? | Random Nerd Tutorials

Although, why is it not going to 3.3 V?

Those pins are not, as they are programmed for inputs, enabled. Also, ask yourself why does a input only pin tuned for analog reads not output anything of use?

Idahowalker:
Those pins are not, as they are programmed for inputs, enabled. Also, ask yourself why does a input only pin tuned for analog reads not output anything of use?

I don't follow. The other two pins are 32 and 33. They only output 1.6 V.

analogWrite(ledB, 255);
analogWrite(ledW, 255);

Their pinMode needs to be put to output?

Even if pinMode is put in, the reading is still 1.6 V on all four pins.

#include <Arduino.h>
#include <analogWrite.h>

int brightStep = 1;
int brightness = 0;
uint8_t ledR = 32;
uint8_t ledG = 33;
uint8_t ledB = 25;
uint8_t ledW = 26;

void setup()
{
  pinMode(ledR, OUTPUT);
  pinMode(ledG, OUTPUT);
  pinMode(ledB, OUTPUT);
  pinMode(ledW, OUTPUT);

  // Set resolution for a specific pin
  analogWriteResolution(ledR, 12);
  analogWriteResolution(ledG, 12);
  analogWriteResolution(ledB, 12);
  analogWriteResolution(ledW, 12);

  analogWrite(ledR, 255);
  analogWrite(ledG, 255);  
  analogWrite(ledB, 255);
  analogWrite(ledW, 255);
 
}

void loop(){}

It is what it is.