Having problems trying to get a high side switch to work 3V switching on 5V

Thread Starter

jcun4128

Joined Apr 5, 2021
17
The context of my project is I am using an ESP-01 as a "smaller" circuit that is deep-sleep capable, running off a coin cell. It turns on a larger MCU with its own battery pack and runs at a higher voltage. Both work together regarding data transmission.

The first time I made this thing, it was using a MOSFET switch design that was apparently a low-side type. I observed that the two devices would get out of sync and my larger MCU(Seeeduino) would get into a bad state where it's stuck(LEDs blinking, won't boot completely). So someone suggested I try a high side switch. I have purchased a lot of random parts and I found this guide on Hackaday about high side switching/bought the MOSFET but due to the 3V to 5V it won't work/I believe I need the transistor in front of the MOSFET to turn it on. I don't know maybe I didn't do something right, the high-side switching with a single NDP6020 should have worked even with my setup because it's just pulling down to ground by the ESP-01 GPIO pin.

I found a diagram from the baldengineer website and tried to make it however I think I combined the circuits on accident thinking the pictures were both the same thing. But the left one is using an N-channel type MOSFET apparently(not sure how you tell, I tried IRFZ44N) where as the right side is using PNP(I was trying to use the NDP6020 there).

Anyway I'm thinking there is something I'm missing that's trivial but I'm blind to it as this is not my field/first time I've worked with MOSFETs.

I'm going to keep trying but I'd appreciate any pointers.

Parts that I have:
transistors: 2n3906 PNP, 2n2222 NPN,

fets: IRF9640PBF P-channel, IRFZ44N N-channel, NDP6020 P-channel, IRL7833 N-channel, 2N7000 N-channel

What I've tried with the high-side so far (sorry not a great picture)

20210402_224801.jpg
 
Last edited:

Thread Starter

jcun4128

Joined Apr 5, 2021
17
Yeah I think the P-channel only high-side switch below didn't work for me because the 5V V-in would have been connected to the GATE (3V GPIO ESP-01) and the ESP-01 has protection I think up to 3.6V.

vin.JPG
(clip from Hackaday high-side switch video)
 

Thread Starter

jcun4128

Joined Apr 5, 2021
17
Thank you very much for this circuit. I will try and make it with my hopefully compatible parts and will test it over the course of the day as it is intended to stay on for at least a month. It will probably be a code issue after this if I have any problems.

I don't know how detrimental it is to use 1K resistors, I have 2K (could parallel wire worst case or look harder in my parts bin).
 

Thread Starter

jcun4128

Joined Apr 5, 2021
17
This is great! It seems to be working fine, I was confused by the load because the bald engineer diagram had a similar thing and to me having a device eg. fan being in a positive line... how could that work, seems like you're just shorting something out.

But In my DMM screenshot below I was able to pull power through the load as per the diagram above, regarding the drain line.

My switching voltage is not high it's 2.8V or so from a 3V source and it seems to be working well.

Thanks a lot for this, I've been stuck on this for a while.

Will try this out over a day see how it goes regarding the bad power state of the secondary circuit due to the constant on/off/on/off cycling every 10 seconds (for testing power consumption, will be just once a day).

working-circuit.png

working-dmm.JPG
 

Attachments

Thread Starter

jcun4128

Joined Apr 5, 2021
17
This solves the point of this post, my secondary circuit/MCU seems to stay on though I think it's stealing power through the Tx/Rx lines or some other issue. Will have to look into that.
 

AlbertHall

Joined Jun 4, 2014
12,346
Yes, you will need to set any inputs to the secondary to zero as well otherwise those lines will power it via the protection diodes.
 

Thread Starter

jcun4128

Joined Apr 5, 2021
17
> set any inputs to the secondary to zero

Sorry but I don't understand what you mean by that? Do you mean use a pull down resistor to GND? In my current setup the communication is one way although it would be nice to have it both ways just in case. In this case the secondary sends data back up to the primary/smaller switch circuit.

This is interesting, if the Rx on secondary is connected, the primary (ESP-01) won't boot. Tried to pull it down too as I think "input" is Rx in this case on the secondary.

Anyway this could be beyond scope of this thread I can get help elsewhere if needed.
 

AlbertHall

Joined Jun 4, 2014
12,346
When the MCU power is switched off is there anything connected to the MCU which has voltage on it?
What communication system are you using?
For instance I2C voltage levels are high when the bus is idle.
 

Thread Starter

jcun4128

Joined Apr 5, 2021
17
I actually have a few problems to iron out, namely the GPIO2 pin I'm using now for my trigger I think I will have to switch to GPIO0, as when it's connected to the Transistor/MOSFET switching power circuit (what would you call this?) ESP-01 fails to boot.

So right now when I boot the ESP-01 I just disconnect the GPIO2 pin until it starts. I can tell that it's booted because of the power supply draw (stuck/not booted is 28mA and about 70mA is running) and the LED flashes.

Regarding the TX/RX pins the symptoms I've observerd:

Having both TX/RX disconnected on secondary, it works fine. Every 10 seconds turns on/turns off as I have programmed it(3.3V GPIO on/off).

Plugging in the RX pin on secondary, makes the secondary try to stay on/not enough power so gets in a bad state.

Plugging in TX pin on secondary it makes the secondary not start, can't explain that one.

Visual of my wiring below.
my-setup.png
 

Thread Starter

jcun4128

Joined Apr 5, 2021
17
Ahh sorry about that just serial, Serial.print. I am using print I believe because it has more "accuracy" regarding the characters making it to the other side. Although right now I'm just sending "integers" eg. 0-1024 (analog steps). Printing data from secondary to primary to be read by WiFi/HTTP server, all of this stuff works.

I think I saw it mentioned about boot up serial messages could be related once everything is wired.

The whole point of this is the secondary is reading/powering up to 10 analog sensors (one at a time). I'm not saying it's an ideal design just what I landed on with my project/parts I had and design/project requirements eg. lasting a month or longer.
 
Last edited:

AlbertHall

Joined Jun 4, 2014
12,346
The usual resting level for UART lines is logic high so that fits the problem. Is it possible to invert the signal polarity at both ends of the link?
That way when no data is being sent the signals will both be low.
 

Thread Starter

jcun4128

Joined Apr 5, 2021
17
Are you saying I should update my program so that the TX/RX lines are defaulted to low on both sides on startup?
And then I guess when the main loop runs turn the lines back on?
Also thanks for your help, this is beyond the scope of getting the circuit to work that was a big hurdle for me.
 

Thread Starter

jcun4128

Joined Apr 5, 2021
17
Okay I will try the low startup. I'm not sure about the invert polarity approach it seems like I'll need extra parts. Although I have the parts (same 2N2222 transistors) or some hardware TTL inverter thing.

This is unfortunate, seems like I should have not gone down this route.
 

AlbertHall

Joined Jun 4, 2014
12,346
You may be able to invert the signals in software. I don't know these two systems, but PIC processors have a polarity invert setting.
 

Thread Starter

jcun4128

Joined Apr 5, 2021
17
Yeah... I don't think this will work in the end. The GPIO0/2 are pulled down by the 10K resistor connected to ground. Even setting them to high doesn't seem to help. Not to mention the Tx/Rx problems... I think I will have to choose an all in one ESP board and then hopefully it has deep sleep like the ESP-01.

I'm still going to use the electronic switch regarding turning power supplies on and off to stuff. Lucky for me I have ESP-07/12 so I will look into those boards regarding deep sleep capability.

Anyway thanks again getting this switch down was huge.
 
Top