# Powering micro controller using n-channel mosfet and tpl5111

I am trying to create home made battery saver circuit to powering on my microcontroller (nodemcu v2),

I am following http://www.ti.com/product/TPL5111/datasheet/detailed_description, and created the connection on breadboard,

TPL is connected as follows

1. Pin -1 V+ - to power rail (5v or normal Li-Ion battery 4.2v)
2. Pin -2 GND - common GND
3. Pin -3 DELAY - 20Kohm to Ground (~20 sec of up time)
4. Pin -4 EN - GND (Since i want this to be one shot and not as timer)via push button and other leg of push button to V+.
5. Pin -5 DRV - Gate to my MOSFET (FQP30N06 N-Channel enhancement)
6. Pin -6 DONE - Done pin to MicroController D2/2 (depends on esp8266 type)

On MOSFET side

1. GATE is connected to Pin 5 above, so every time i push the button TPL asserts DRV pin high which should enable the mosfet
2. MC USB pin connected to V+
3. MC Ground is connected Drain of Mosfet
4. Source of Mosfet is connected to Common GND
5. GATE and DRAIN are connected using 5K ohm resistor

Following are my doubts

1. Even when TPL DRV is low my external LED to MC on pin 13 is lit and voltage is < 0.5 volts, should microcontroller be OFF completely?
2. My intention is to attach Reed Switch instead of push button to TPL so every time i open the door it should turn on mosfet via tpl and microcontroller should do the job and send the DONE to turn off
3. Sending DONE via microcontroller doesnt turn off the TPL, but thats not something bothering me at this stage but still would like to know

I will upload my circuit from breadboard but i need to put labels on it.

Below is simple code which turn on LED on Pin 13/D7

    #include "AdafruitIO_WiFi.h"
#define HUZZAH
#ifdef HUZZAH
#define DONEPIN   2 // TPL5100 Done signal
#define LEDPIN    13
#else
#define DONEPIN   D2 // TPL5100 Done signal
#define LEDPIN    D7
#endif
#define DEBUG true
#define BAUD_RATE    115200

const char* ssid = "wifi";
#define AIO_KEY  "mykey"

void logMessage(String message, boolean noCRLF=false){
#ifdef DEBUG
if (Serial){
if (noCRLF){
Serial.print(message);
}else{
Serial.println(message);
}
}
#endif
}

bool sendData = false;
io.connect();
int retry = 0;
// wait for a connection
while(io.status() < AIO_CONNECTED || retry < 10) {
logMessage(".");
retry++;
delay(500);
}
if (io.status() < AIO_CONNECTED){
sendData = false;
}
// we are connected
logMessage("Adafruit connected:" + sendData ? "true" : "false");
logMessage(io.statusText());
}

/*
* send DONE signla to TPL5100 to shut the power off
*/
void sendDone(){
digitalWrite(DONEPIN, HIGH);
delay(1);
digitalWrite(DONEPIN, LOW);
delay(1);
}

void setup() {
delay(10);
Serial.begin(BAUD_RATE);
Serial.println("Measuring Temp on DS18B20 \n");
delay(10);
pinMode(DONEPIN, OUTPUT);
pinMode(LEDPIN, OUTPUT);
digitalWrite(DONEPIN, LOW);
}

void loop() {
io.run();
digitalWrite(LEDPIN, HIGH);
logMessage("I was here", true);
delay(3000);
digitalWrite(LEDPIN, LOW);
while(true){
sendDone();
}
}


simulate this circuit – Schematic created using CircuitLab

• Can you use the built-in schematic editor to make your text description of your circuit into a schematic? – ThreePhaseEel Nov 22 '17 at 4:01
• Apologies, had no idea there is awesome schematic editor – Gaurav18ca Nov 23 '17 at 3:45
• According to your schematic, when SW1 closes, it puts a direct short-circuit across the power supply. This is not sensible, so please check & fix the schematic (this is assuming that your real hardware is connected differently, without a direct short across the supply through SW1, and so the error is in the schematic only). – SamGibson Nov 23 '17 at 12:34

In addition to the helpful suggestion from Jim Fischer, I see another possible cause of your problem.

### High-side vs. Low-side switching

Even when TPL DRV is low my external LED to MC on pin 13 is lit and voltage is < 0.5 volts, should microcontroller be OFF completely?

Notice from the TPL5111 datasheet that the "Typical Application" example is not controlling a low-side switch - it is controlling a high-side switch. You might wonder why that matters...

Look at this diagram from its HTML datasheet:

Figure1: Example TPL5111 schematic from its datasheet

In that example, there is no chance of leakage from the MCU GPIO pin, nor via the I2C pull-up resistors shown in that example, when the power is switched off using the high-side power switch.

However, looking at your schematic, since you are switching on the low-side, there are "hidden" current paths from the power rail via the MCU D2 pin and the 1MΩ resistor to ground, and via the MCU D3 pin and the LED to ground:

Figure 2: Present version of schematic from the question

These types of "hidden" current paths, via GPIO pins, can be enough to (partially) power-on an MCU. This is quite a common problem when using low-side switching, as you need to consider every possible path to ground from each device, when its main ground connection (e.g. Vss) is disconnected.

You can test this hypothesis on your design:

• Disconnect the MCU D2 GPIO pin, so that it is not connected to the 1MΩ pull-down resistor or the TPL5111 DONE pin..
• Change the LED connection, so that it is between the MCU D3 pin and Vdd (i.e. the positive power rail) instead of between the D3 pin and ground. You then need to change your code, since driving that MCU pin High will switch the LED off, and driving the pin Low will switch the LED on.
• Disconnect any other GPIO pins which are used, but which are not shown on the schematic.
• Also, shouldn't you use a resistor for that LED, no matter how you connect it?

Then check again whether your MCU still lights the LED, when its GND pin is disconnected by the TPL5111 & MOSFET.

A few more points:

• I have already mentioned in a comment that SW1 in your schematic seems wrong, as it would directly short the power supply when the switch is pressed. However I assume that is a mistake in the schematic and does not show the real connections which you have to SW1.

• Your chosen FQP30N06 MOSFET may not do a good job of switching-on your load. Notice that its $\small R_{DS(on)}$ is specified at $\small V_{GS} = 10\;\textrm{V}$ but you are switching it using a much lower voltage, so its $\small R_{DS(on)}$ will be higher than its "headline" specification of 40 mΩ.

• The TPL5111 is designed for switching a logic-level power signal, not a MOSFET gate. It is specified at 1 mA of drive and 50 pF load (absolute maximum 5 mA). Although I doubt this will be a problem with small MOSFETs (small values of gate capacitance), personally I would suggest to review the MOSFET specification and its suitability more closely (I have run out of time). Also use a 'scope to view that gate drive signal, to ensure it has sensible rise/fall times.

• Depending on your design constraints, component availability etc., you could consider inverting the TPL5111 DRVn signal using a small signal NPN BJT or N-channel MOSFET, and using that (now inverted i.e. active-low signal) to drive the gate of a suitable P-channel MOSFET, acting as a high-side driver. It all depends on the reason(s) why you decided to use a low-side switch in the first place.

• Thank you for elaborate details about my circuit issues, i am sort of newbie but took this kind of complex project in search for battery saver solution. I did not have those types of LDO in my inventory which has ENable pin to turn it on. Also, on your recommendation for low side switch i will implement those and see how it behaves and update here. Thank you for your help Sam and Jim. – Gaurav18ca Nov 23 '17 at 17:33
• @Gaurav18ca - Just FYI (since I don't believe you will be automatically notified of my edit) I have added another point to my answer, that you could use a P-channel MOSFET as a high-side driver, if you invert the TPL5111 DRVn output. This might not be possible for you (e.g. if you don't have the necessary components and don't have the time/money to buy any) but high-side switching may be worth considering, as it eliminates some of the issues with your existing design. – SamGibson Nov 24 '17 at 14:41
• I see your point and will come back to it, before that i made some suggestions last night especially removing done signal from mc to TPL / and LED is now on +ve rail and smaller leg to mc, and changed the code. – Gaurav18ca Nov 24 '17 at 15:04
• Also modified sketch, of course it not lit but voltage across mc usb/gnd is somewhere at 300mV. I will measure the current though. On using p-channel mosfet - (i do have some enhancements ones will see if i can make that work). Adafruit especially designed their tpl5110 boards driven by p-channel mosfet but both of them from adafruit is used for timing intervals (hard wired enable pin to +ve). I am starting see issues with my low-side switching (never heard that before yesterday!) and understanding it better. Thank you so much for insights. – Gaurav18ca Nov 24 '17 at 15:13

On MOSFET side > 5. GATE and DRAIN are connected using 5K ohm resistor

Why is this 5k resistor connected between the GATE and DRAIN? If I understand your circuit topology correctly (which is difficult without a schematic diagram, BTW), this 5k resistor connects the microcontroller's ("uC") GND pin into pin 5 on the TPL5111, and when pin 5 is logic LOW you'll have a small, continuous (~1mA) current path from +5VDC to GROUND:

+5 VDC
-> uC VDD (POWER)
uC GND ->
-> 5k resistor ->
-> TPL5111 pin5 (LOW)
TPL5111 GND ->
-> GND


I recommend you remove that 5k resistor and replace it with a 10k resistor between the MOSFET's gate and GROUND so as to "program" the MOSFET's default VGS voltage to zero volts (VGS=0V). I haven't read the TPL5111 data sheet, but there might be a short time during power-on reset (POR) when the TPL51111's DRVn pin (pin5) is floating or unstable, and the 10k "pull down" resistor on the MOSFET's gate will help ensure the MOSFET stays OFF during that time.

• Thank you, will try with 10K resistor between Gate and Drain, also attached my schematic now – Gaurav18ca Nov 23 '17 at 3:46
• No. Put the 10k resistor from gate to source (ground), not from gate to drain. Remove the gate to drain resistor. – Jim Fischer Nov 23 '17 at 3:55
• Added 10 K between Gate to Source (ground) but i still see small current to my mc – Gaurav18ca Nov 23 '17 at 4:22
• @Gaurav18ca - You say that you have added a 10k resistor between the MOSFET gate & source. But have you followed the recommendation from Jim to also remove the 5k resistor between its gate and drain? – SamGibson Nov 23 '17 at 12:39
• What numerical value is "small current"? – Jim Fischer Nov 23 '17 at 19:47