# Trying to power on/off esp8266 power with a 2n2222a NPN transistor

I am trying to save some power, using an Arduino and an ESP8266 (ESP12 ESP-14F version).

The 3.3v is provided thanks to an LD1117V33. I've placed a 2n2222a transistor between the LD1111V33 and the ground. When ESP is powered on through the transistor, AT commands don't work anymore (I am mesuring 3.2V between Collector and the ESP VCC). When I short Collector to Emitter, everything is fine.

Here is a log of AT exchange with the ESP. As you can see, the 2 first "AT" requests return something I can't read, then, all the other "AT" commands don't receive anything:

***** SEND *****
AT+CIOBAUD=9600[CRLF]
======= WIFI INIT START =======
***** SEND *****
AT[CRLF]
sllœ�sŒ!ãoŒ€lìpŒ|�ƒŸìp“Ÿ�“œæŒpŒpóoŸlooœccpŒ�!lãú
***** SEND *****
AT[CRLF]
kÿ
***** SEND *****
AT[CRLF]

***** SEND *****
AT[CRLF]


I read on the post below, that it is not possible to use the 2n2222a NPN transistor to do so. Could anyone give me some explanations? (I know, there is a deep sleep mode I could use, but I'm trying to learn from my mistakes).

For an Arduino and ESP8266, can I power up the ESP8266 from a set of 2n2222 transistors?

Here is how I wired it up (I removed the resistors to ESP RX, and CH_PD to simplify the picture).

• Can you draw a normal schematic? Feb 1, 2017 at 23:05
• Fritzing can produce real schematics. Get it to cough one up, and post that instead of the wiring diagram.
– JRE
Feb 1, 2017 at 23:13
• There's a 12E, a 12S, not sure about the 12 anymore. Do you have a link to the exact device and some manual describing your specific pinout for the device?
– jonk
Feb 1, 2017 at 23:17
• Tangential: the ESP8266 has a deep-sleep mode, which brings the power consumption down to 10uA. Consider using that instead of trying to disconnect power. Feb 1, 2017 at 23:55
• Sorry, I was wrong on the ESP version. It is an ESP-14F Feb 2, 2017 at 22:14

Thanks to mkeith & JRE, I finally got the solutions. There were 2 problems:

• voltage drops to 3.2 instead of 3.3 beacause of the NPN transistor. Using a PNP to give the LD1117V33 a real ground fixed it.

• serial messages were corrupted because the esp ignored the first message: it didn't have time to wake up between transistor activation, and the first serial message, which goal is to set up the baud speed! Adding a "delay(1000)" fixed the issue.

Thanks a lot!

• Glad you were able to solve the problem. But If I may, I suggest you use a MOSFET instead of a transistor. mainly because of significantly less powerloss and mosfets are able to switch higher current devices. Feb 7, 2017 at 15:23
• I found this affordable P-Channel MOSFET (AO3413): aosmd.com/res/data_sheets/AO3413.pdf I think this should do the work... could you please confirm? So you know how to estimate the power loss? Thanks! Feb 8, 2017 at 9:28
• While choosing a MOSFET, you need to focus on 4 main things. i.e drain to source voltage (The amount of voltage that can pass though the MOSFET without damaging it) , gate to source voltage( voltage required to activate the MOSFET) , continuous drain current(The amount of current that can pass through without damagin it) and power dissipation(the amount of power loss dissipated in the form of heat). Feb 9, 2017 at 10:41
• power dissipation is directly proportional to drain to source resistance(Rds)... The MOSFET you've chose has has relatively large Rds ranging from 80-130 mOhm depending on the voltage. All of these parameters can ofcourse be referred from the datasheet. Instead AO3413 I suggest you use IRFz44n which is an n-channel MOSFET and is much more common, hence easy to find. Feb 9, 2017 at 10:42
• If I use a n-channel mosfet, I guess There will be the same voltage drop than with a npn transistor, isn't it (the voltage regulator needs to be connected to a real ground)? Feb 9, 2017 at 16:46

Possibility 1, Transistor is on Maybe the transistor is on. Check voltage between base and emitter. Should be close to zero. If it is above 0.3 or so, it may be turning on a bit.

Possibility 2, transistor is fried Maybe the transistor is defective and provides a conductive path from collector to emitter regardless of base voltage and current.

Possibility 3, ground current has alternate path Maybe one of those yellow wires is at GND potential and is providing an alternate pathway to GND for the regulator current. For example, if any of them is an output driven low, this could happen. You really want them to be in a high impedance state. It is OK to pull them high weakly, or even drive them high after the 2n2222 is off.

Note: it may be easier to use a small PMOS transistor to switch the positive side of the regulator. That is what I would do for sure. Then when you want to turn off power to the board, in addition to turning off the PMOS (by driving the gate high) you also need to make sure all other IO lines to the board are low.

• Thanks for this analyze. I tried several transistors to ensure it is not fried, I will mesure the voltage when the signal is off. I think the problem is with those yellow wires (SoftwareSerial). Maybe some diodes would solve the problem? Feb 2, 2017 at 9:12
• Let's confirm the cause first. Feb 2, 2017 at 17:48
• The voltage between base and emitter is 0.78V, so what do you mean by "it may be turning on a bit"? Feb 2, 2017 at 21:41
• I realize I wasn't clear in my question. I can power off the ESP, this is not a problem. The problem is when I power it on, the AT commands don't work fine. when I short Emitter to Collector, everything is OK. Feb 2, 2017 at 22:36
• In that case, replace it with an N-channel FET such as BSS138. This is an entirely different question, by the way. Feb 3, 2017 at 5:21