Mosfet as a power switch for low power consumption

Hi,
I want to use a set of components in order to isolate a few sensor's power from the micro controller's(esp32 in my case) power(3v battery).
For now I used a mosfet, which its gate is connected to GPIO12. I want it to disconnect the sensors from their power completely(maximum consumption of few micro amps).
Attached is my schematic, what happens now is that:
A) When gate is HIGH - The drain doesn't pass all the voltage to the source - I see only 2.3V(I want it to be as close to the drain as possible)
B) When gate is LOW - the source is 0.4V - why?
I am open to better suggestions of course
Thanks!

N channel MOSFETs are best used for low side switches. The load is between Vcc and the drain of the MOSFET. Source to ground.

The Rds(on) of the MOSFET is around 2Ω. Kind of on the high side for MOSFETs.

What is connected to the 3.3V_SW (show the rest of the circuit on the schematic).

The 10K resistor should be on the other side of the 330Ω resistor (from the output pin to ground).

This is a good source on using transistors as switches: Transistor as a Switch

Hi,
Thanks for the replies.
Attached 2 screen shots, of what I understood should be the schematic, and the connections that goes after 3.3V_SW.
If I understand correctly, GPIO=HIGH output will be 0 and the opposite, is there a simple way to make it the other way around(GPIO=HIGH->OUTPUT=HIGH)?
In order to stay at very low current the high side resistor(10k now) should be 10M+ correct?
Thanks


No, that's not the way. Now you're connecting 10k in series with your sensors and that's not going to work. You place the sensors (loads) in the place of the 10k resistor. The drain of the mosfet becomes a virtual ground as it turns on.

And that depends on if the sensors like having their grounds switched. Removing the ground while having the positive power still connected can lead to back powering the sensor, often to the determent of the sensors well being. May be better to use a high side switch using a P channel device to control power to the sensor.

What are the sensors? Do they really draw that much current when inactive? Do they have sleep or power down modes?

For a high-side switch you need a P-channel mosfet. Something like this:

Confused.
Why do you want to switch 3.3volt power to addressable LEDs that need 5volt to work.
Leo..

That is nonsense: the switched device cannot know if you use high side or low side switching.
Unless designed to allow partial power down back powering is always danger that must be considered. It depends on the communication bus what is better. But often low side switching is SAFER because idle signal is HIGH on many buses (I2C, SPI SS, UART).

I think I'll use high side switching because all the reasons above. Does it wastes less current than low side?
@groundFungus yes, the sensors take a lot of current in compare to what I need(for it to work on ~20uAh in sleep mode), I prefer disconnecting them this way than going in to sleep mode complication(which not all have).
@Wawa You're right, but works fine till now, and I have no interest in putting another component.
Thanks!

It won't make a real difference.

What reasons exactly? Your MOSFET is for low side switching and unless you share what sensors you are using it is dubious there is any advantage of high side switching.

I meant using high side switching with a P channel MOSFET as was suggested.
I use sensors that communicate with SPI(ADXL).