Low side switch not working as expected with ESP8266

Thread Starter

TomasCrespo

Joined Oct 8, 2023
9
Hi! I have a simple circuit with a D1 Wemos mini pro reading two sensors through RS485, publishing into a MQTT broker and sleeping for 20 minutes.

All this was working but with one big problem. Sensors were powered up all time, so they ate my battery.

So what I have done is design a low side switch to decide when sensors will be on and when will be off. I have used a MOSFET BS170 with Vgs(th)max of 3.v connected to a digital output of D1 mini pro (GPIO14). I used two resistors, one to protect the GPIO port (470 Ohm) and one to pull down the transistor and avoid float (10K Ohm). This is the schematic and connections:

schematic_bs170.jpg

As you can see when I put HIGH GPIO14 I power up a RS485 module and a steep up booster (from ~3.7 to 5v) which powers the sensors. The consumption is about 100mA.

But the thing is this is not working very well. When I activate GPIO 14 the voltage of all the circuit is not stable and it increase from 3.7v to 4.3v and is not stable.

Do I have done something wrong?

Lots of thanks
 

geekoftheweek

Joined Oct 6, 2013
1,429
I'm no expert, but I would find a way to do a high side switch to your boost converter. The Vgs(max) means that is the maximum voltage you need on the gate for the FET to start conducting. If I'm reading the graphs correctly you need around 10V at the gate to totally turn it on.

Even with your relatively low current I would suspect it's causing a mismatch in the ground (-) levels of your circuits which will cause strange things to happen if not destroy components trying to even the planes through pins not designed for it.
 

crutschow

Joined Mar 14, 2008
38,503
What do you suggest me to try to design an schematic?
Look at a schematic of a bridge rectifier circuit and draw yours in a similar fashion.
Look up references on the proper way to draw schematics.
It's not sufficient to just put components in random locations and orientations, and then connect them with wires; there needs to be a logical and smooth flow of signals.
 

BobTPH

Joined Jun 5, 2013
11,515
What are the two other lines into the sensor (green and yellow)? If one is a digital signal going to an input on the sensor, and it is set low, it might well be providing a ground path through a protection diode to the sensor.
 

Thread Starter

TomasCrespo

Joined Oct 8, 2023
9
The Vgs(max) means that is the maximum voltage you need on the gate for the FET to start conducting. If I'm reading the graphs correctly you need around 10V at the gate to totally turn it on.
Ummm... I didn't watch the graphs. I thought that Vgs(th) max of 3v meant that it will be totally open with 3.3v

Even with your relatively low current I would suspect it's causing a mismatch in the ground (-) levels of your circuits which will cause strange things to happen if not destroy components trying to even the planes through pins not designed for it.
That's exactly what is happen. Is something like unstable gnd.

Lot of thanks. I thought in a high side switch, but this switch looked so simple that I thought a low side were enough. I am waiting to receive some IRLB8721. Perhaps low side will work with them, but I am also thinking in preparing an high side switch
 

Thread Starter

TomasCrespo

Joined Oct 8, 2023
9
What are the two other lines into the sensor (green and yellow)? If one is a digital signal going to an input on the sensor, and it is set low, it might well be providing a ground path through a protection diode to the sensor.
That looks interesting.
These (green and yellow) are data communication lines of modbus serial protocol (A and B). However I have measure voltage between GND and one of them and I get about 2.4v what looks weird for me. I will tray the low side switch without connecting this data lines.

If these are a "ground path", how could I avoid it?
 

Thread Starter

TomasCrespo

Joined Oct 8, 2023
9
I would find a way to do a high side switch
Given that the voltage of the load I want to control (3.3V, from D1 mini pro 3.3v pin) is the same as the voltage of the control signal (3.3v, from a GPIO)... could I build an high side switch with only a P-channel MOSFET, without a driver?
 

geekoftheweek

Joined Oct 6, 2013
1,429
Given that the voltage of the load I want to control (3.3V, from D1 mini pro 3.3v pin) is the same as the voltage of the control signal (3.3v, from a GPIO)... could I build an high side switch with only a P-channel MOSFET, without a driver?
It may be possible, but it may take a surface mount FET to do the job. I did a quick look and the only one I saw in a through hole mount in the voltage range you need was rather expensive. You may have better luck.

What I would do is have a pull up resistor between the battery and the gate to turn it off and then use your current N FET to pull the gate low to turn it on. In the event your battery goes above 3.3V if you only have 3.3V at the gate it may start conducting. You'll have to do some looking to see if you can find something suitable.

Another option would be to use an optocoupler as a high side switch. I really haven't played with them much in this arrangement as I have always used them as low side switches, but it is possible. It seems on the few that I have tried it seems to take a bit more current to "turn them on" as a high side switch.

Probably the easiest route would be a PNP transistor as a high side switch. If you are only powering it for a few seconds a couple times an hour you shouldn't loose much charge through the base resistor.
 

geekoftheweek

Joined Oct 6, 2013
1,429
I thought in a high side switch, but this switch looked so simple that I thought a low side were enough.
I would be very hesitant of using a low side switch on a power supply myself. Once again I am not an expert, but the diagrams of switch mode power supplies I have looked at still have a connection between input and output that is not broken in any way and current will flow through them. Disconnecting the ground (-) will only stop the regulator part of the power supply. If you were only connecting say a light, relay, or a stand alone device it would be good. Since you have connections to other devices that are connected to ground at a different point and operational current will find a way to flow through the power supply.
 

Thread Starter

TomasCrespo

Joined Oct 8, 2023
9
Since you have connections to other devices that are connected to ground at a different point and operational current will find a way to flow through the power supply.
Great explanation, thank you very much.
 

Thread Starter

TomasCrespo

Joined Oct 8, 2023
9
What I would do is have a pull up resistor between the battery and the gate to turn it off and then use your current N FET to pull the gate low to turn it on
An high side switch with a N-FET ?? I haven't seen that never. I will investigate.

This is what I understand as an high side switch, with a P-Channel MOSFET, with control signal and load at same voltage:
high-side-FET_same_voltage_3.3v.jpg
 

geekoftheweek

Joined Oct 6, 2013
1,429
Your diagram is what I was referring to, but didn't take the time to draw it out. Instead of connecting the GPIO to the PFET I was referring to connecting the GPIO to the NFET and using it to pull down the PFET gate. If all voltages are the same then it wouldn't matter and connecting the GPIO directly to the PFET would work also.

In all reality even if your battery is at say 4.2V (as you have shown as a high range) and you only have 3.3V at the gate it's probably not going to conduct anyways since there is not enough of a difference so I might have been overthinking things a bit.
 

Thread Starter

TomasCrespo

Joined Oct 8, 2023
9
I have done some new tests today. I have removed all not essential, so now the circuit is:
* the battery
* the D1 mini pro
* the booster
* he sensors

Nothing more, not even the RS485 module.

The booster is powered up from the 3.3v regulated output of the D1 mini pro.

All works perfectly and I have an stable voltage if I not use the low side switch.

But If I use the Lo voltage switch:
* stable voltage if I connect the booster but not connecting the sensors to the booster
" unstable voltage when low side switch mosfet is activated if the sensors are connected to the booster
 

geekoftheweek

Joined Oct 6, 2013
1,429
Have you tried to measure if there is a voltage difference between your source and drain on your FET? My original thought of it not conducting fully should show up as a measurable difference between the two when everything is connect.
 

Thread Starter

TomasCrespo

Joined Oct 8, 2023
9
Hi again,

I have replaced the BS170 N-Channel MOSFET with a IRLB8721PBF N-Channel MOSFET and now the low side switch is working perfectly. So I have tested again with two differents BS170, but with it the voltage of the circuit fluctuates when gate is high. With the IRLB8721PBF the voltage remains stable, so I am going to use this MOSFET.

Anyway I would understand why?!

Lots of thanks for your help and effort
 
Top