- Wed Mar 15, 2017 3:14 pm
#63742
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)