erropix / ESP32_AnalogWrite

Provides an analogWrite polyfill for ESP32 using the LEDC functions
MIT License
159 stars 36 forks source link

Not outputting correct voltage #10

Open adamelli opened 3 years ago

adamelli commented 3 years ago
#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?

adamelli commented 3 years ago

So pins 34, 35, 36, 39 are input only. That does not explain why the other pins only output a maximum of 1.65 V...

JimDrewGH commented 2 years ago

If you are measuring PWM with a standard VOM this would be normal. The duty cycle will throw off a conventional VOM. Set a pin HIGH and measure the voltage. If it's still just 1.65V then that would be an issue.