-->
Page 1 of 7

How to disable internal pull up resistor before user code

PostPosted: Wed Mar 15, 2017 6:53 am
by sean_intez
Hi Folks

In my project I have connected a relay to GPIO13. I set gpio13 to low when I initialize the gpio. however, since that pin has internal pull up, the relay briefly operates when esp8266 starts.
I asked this question before and someone suggested me to use gpio 4 or 5 since they don't have internal pull up. He was right and I could solve the issue. However now in my new project I need to work with gpio13 and I am looking for a way to disable the pull up resistor permanently.

I tried to use external pull down resistor ranging from 12ohm to 30k but none of them worked.


I would greatly appreciate if someone helps me

Re: How to disable internal pull up resistor before user cod

PostPosted: Wed Mar 15, 2017 8:15 am
by rudy
As far as I know, you can't disable them.

The best option is to have a circuit that will turn on the relay with a port output low. High being off. And you can do this with a PNP transistor stage followed by a NPN stage to drive the relay. I looked on the internet for a schematic that shows this but I couldn't find a good one. The best I could come up with is the following.

Image

What you want is the emitter (arrow) of Q1 connected to the 3.3 volt supply of the ESP. Pin 1 of J1 is connected to the port pin with the internal pull up. The collector of Q1 (connected to R2 is used to provide the high for the NPN transistor (Q2) that is driving the relay.

The Q2 portion in the picture is a bit odd. You don't need D1 and RZ. I could put up a proper schematic when I get home tonight.

Re: How to disable internal pull up resistor before user cod

PostPosted: Wed Mar 15, 2017 12:45 pm
by Barnabybear
Hi, by default I didn't think pullups were enabled.
Code: Select allpinMode(13, INPUT); // set as input - no pullup.
pinMode(13, INPUT_PULLUP); // set as input - with pullup.

Re: How to disable internal pull up resistor before user cod

PostPosted: Wed Mar 15, 2017 2:39 pm
by sean_intez
rudy wrote:As far as I know, you can't disable them.

The best option is to have a circuit that will turn on the relay with a port output low. High being off. And you can do this with a PNP transistor stage followed by a NPN stage to drive the relay. I looked on the internet for a schematic that shows this but I couldn't find a good one. The best I could come up with is the following.

Image

What you want is the emitter (arrow) of Q1 connected to the 3.3 volt supply of the ESP. Pin 1 of J1 is connected to the port pin with the internal pull up. The collector of Q1 (connected to R2 is used to provide the high for the NPN transistor (Q2) that is driving the relay.

The Q2 portion in the picture is a bit odd. You don't need D1 and RZ. I could put up a proper schematic when I get home tonight.

Using PNP transistor instead of NPN was my other option but that also has its own disadvantages. If esp8266 fails for any reason and shuts down, the relay gets energized and activates the high voltage circuit which is very dangerous.