-->
Page 2 of 7

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

PostPosted: Wed Mar 15, 2017 2:44 pm
by sean_intez
[quote="Barnabybear"]Hi, by default I didn't think pullups were enabled.
[code]
pinMode(13, INPUT); // set as input - no pullup.
pinMode(13, INPUT_PULLUP); // set as input - with pullup.
[/code][/quote]
They are enabled on startup by default on some pins.

I was hoping to find a way to modify the registers and disable the pullups when uploading the firmware.

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

PostPosted: Wed Mar 15, 2017 3:14 pm
by rudy
sean_intez wrote: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.


The ESP8266 starts with the output pulled high because of the internal pull up resistor. And if the ESP can't start for any reason the transistor is never turned on. The PNP never turns on, the NPN never gets turned on, the Relay never gets turned on. So no power will be switched on to the output.

If the code runs and the output is turned on, and then the CPU crashes for some reason, the output can be left on. But this is also the case when using a NPN transistor. It is the same. The only problem with using PNP transistors is that it takes more components to accomplish the same job.

As I said, the circuit I included was the best I could find on the web. I would include an external pull up resistor to ensure the PNP transistor never turns on even if the ESP's output was disabled. (no pull up, not configured for output)

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

PostPosted: Wed Mar 15, 2017 3:41 pm
by martinayotte
Why not relying on the fact that PullUp can secure the OFF state instead and bringing GPIO to LOW to turn ON the relay ?
Here is the simple circuit, although my personal preference would change the NPN for another MOSFET with PullUp :

Image

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

PostPosted: Wed Mar 15, 2017 3:45 pm
by Barnabybear
sean_intez wrote:
I was hoping to find a way to modify the registers and disable the pullups when uploading the firmware.


The register is @ 0x60000808 bit 7, but I'm not sure that any changes will last through a reset.
https://esp8266.ru/esp8266-pin-register-strapping/
Have you thought about putting the relay between Vcc and GPIO13. Set GPIO high at the start of the code and invert the output?