-->
Page 1 of 2

LED still glowing if Pin is Off

PostPosted: Mon Feb 27, 2017 1:59 am
by ThomasRichter
Hi Guys,

i have a problem with my new ESP8266 E12.
I only have simple circuits on the outputs with a resistor + LED on each pin (see below).
Whenever i switch on a LED it works just fine, but sometimes when i shut off the pin, the LED is not totally turned of, but it's slightly glowing, so there might still be some small current flowing threw the LED, but i don't know why.
Here is my code (Arduino):

Code: Select all#define PIN 13

void setup()
{
    pinMode(PIN, OUTPUT);
}

void loop()
{
   // Turn on LED
   analogWrite(PIN, 1023);
   // Hold state for 10sec
   delay(10*1000);
   // Turn off LED
   analogWrite(PIN, 0);   // ! LED still glowing slightly
   // Hold state for 10sec
   delay(10*1000);
}

Re: LED still glowing if Pin is Off

PostPosted: Tue Feb 28, 2017 4:04 am
by Barnabybear
Hi, does this do the same if you use digitalWrite?
Code: Select allvoid loop()
{
   // Turn on LED
   digitalWrite(PIN, HIGH);
   // Hold state for 10sec
   delay(10*1000);
   // Turn off LED
   digitalWrite(PIN, LOW);   // ! LED still glowing slightly
   // Hold state for 10sec
   delay(10*1000);
}


The other thing to try is putting the LED between 3.3V and the GPIO, this will invert your code but it will not light if there are pull up resistors used on your board.

Re: LED still glowing if Pin is Off

PostPosted: Tue Feb 28, 2017 7:29 am
by ThomasRichter
Barnabybear wrote:Hi, does this do the same if you use digitalWrite?
Code: Select allvoid loop()
{
   // Turn on LED
   digitalWrite(PIN, HIGH);
   // Hold state for 10sec
   delay(10*1000);
   // Turn off LED
   digitalWrite(PIN, LOW);   // ! LED still glowing slightly
   // Hold state for 10sec
   delay(10*1000);
}


The other thing to try is putting the LED between 3.3V and the GPIO, this will invert your code but it will not light if there are pull up resistors used on your board.


DigitalWrite had the same effect.
But i like your idea to connect the LED from 3V to digital pin. That might be an appropriate solution.
I'm gonna try it later.
Can i still remain pinMode as OUTPUT then?
Thanks anyway! :)

Re: LED still glowing if Pin is Off

PostPosted: Tue Feb 28, 2017 8:26 am
by rudy
PWM = 0 most likely does not produce a constant 0 output. I expect you are seeing the minimum output which could be one pulse time. This quirk is typical with hardware PWM, but I thought that the PWM on the ESP8266 was done in software so I would thing that case could be handled.