N-Channel vs P-Channel MOSFET for Sensor Control on Arduino UNO

Hello!

I'm powering a 5V, 40mA (max) sensor from an Arduino UNO R4. The sensor is connected to the 5V rail, ground and an analog input pin on the Arduino.

I'm looking to use a MOSFET to switch the sensor on and off using a digital output from the Arduino. I'm unsure whether to use a high-side P-channel or low-side N-channel MOSFET.

From what i've read, N-channel MOSFETs are generally more efficient since they tend to have a lower Rds(on). However, if i put the MOSFET on the low-side, the sensor's ground will be "floating" when off. Couldn't this lead to "phantom powering" of the sensor through the analog input pin, putting the sensor into a weird partial-power state? Will there be any unwanted current flow via the analog input pin when the sensor is supposed to be off?

Is it generally better to keep the sensor permanently connected to ground, so to use a high-side P-channel MOSFET, or is there a safe way to use a low-side N-channel MOSFET without having this "phantom powering" occur?

Also i'm not entirely sure if this "phantom powering" actually exists or how it really works so any help or explanation would be greatly appreciated! :sweat_smile:

@adam400 , welcome to the forum!

It would probably help if we knew what the sensor is?

Is the objective here to reduce power consumption? It seems to me that if you don't want data from a sensor, you just don't read or ignore the input pin?

It's never great idea to cut gnd from sensor connected to arduino. Worst scenario would be if at any moment sensor has 5V and arduino doesn't.
If N is your only option, add 10k resistor between sensor and analog pin.
What's the purpose of this setup?

The general rule is to power a module/sensor on the high side. However, for simple devices like leds, relay coils etc. these are often better switched on the low side .
If the module voltage is higher than the Arduino pin voltage (say a 3v3 ardunio switching a 5v module) then an N and P channel mosfet together in a high side switch configuration can be used.

Thank you :slight_smile:

The sensor is DFRobot Gravity: Analog Turbidity Sensor (SEN0189)

The goal is to reduce power consumption so to turn the sensor off when a reading isn't needed. I'm under the impression if the sensor is just connected as is, it will continuously draw power from the arduino even when the analog pin isn't actively taking a reading, so a MOSFET can decrease this wasted power

The idea is to decrease the power wasted by the sensor when a reading isn't actively needed, so to only draw power when needed. Is the reason that is ideal to not cut ground to do with the "phantom powering" idea?

Thanks

I don't know official description of "phantom powering" but I suspect it means when you power arduino through the sensor (worst case I mentioned). There are other issues as well, so avoid gnd cut.

The phantom powering can occur through the pin protection diodes of the Arduino in the case that the Arduino is not powered in the normal manner but a device connected to one of its pins is powered on.

That's what I wrote above..

  • A common and recommended way to switch positive power is to use a high-side P-channel MOSFET.

  • You can also use a miniature relay too :thinking:

40mA is not huge and many cheap high-side P-channel MOSFET will do. Just read its datasheet. In this situation, I ask the AI: Hi, HDYD, I'm looking for a cheap P-channel MOSFET to power a 5V 50mA circuit, what would you suggest me to use?

AO3401 is so cheap and versatile... among so many others

1 Like

If you power down the sensor, then power back up, will the sensor have to be reinitialized (rebooted)?
Post a link to the sensor's datasheet AND your code.

The "phantom powering" i am referring to is unwanted powering of the sensor, the Arduino will always be on in this case. So i am wondering that if the sensor's ground is floating, will the sensor still be in a partial power-on state via current flow between the 5V rail connection and analog input pin both on the Arduino?

https://wiki.dfrobot.com/Turbidity_sensor_SKU__SEN0189

No, the sensor just resumes outputting an analog voltage once it is being powered again.

https://wiki.dfrobot.com/Turbidity_sensor_SKU__SEN0189

Yes, there would still be current path through arduino pin protection diodes. And it's not considered safe. If that's your only option, add 10k resistor.

Why do you want to save 0.2-W of power? Battery?

In my experience, and with industrial turbidity sensors, it's better to keep them running all the time. Even under ideal conditions, I would discard readings for say 15-seconds after powering up.

Out of interest, what are you trying to measure the turbidity of? Depending on the medium, there are plenty of other hurdles to cross.

If you disconnect the sensor's ground pin from ground, all its pins, including the ground pin, will float up to, or near, Vcc. (You can test this with your meter.) Then if the output pin is connected to a low pin on the Uno, current will flow.

The converse is true if instead you disconnect the Vcc pin from Vcc. Current will flow into the output pin (which will be at or near ground) from a high pin (INPUT_PULLUP) on the Uno.

The low-side switch can cause a problem when for any reason power is lost on the Arduino, but is still there on the sensor. Current will flow from the sensor through the protection diode on the Uno's pin, to Vcc, which, if power is off, will be at or near ground. Potentially large amounts of current can flow, or the Uno can power up. So typically the sensor's power would be switched on the high side, so if the Uno's power fails, both devices will be at ground (assuming the Uno controls the switch).

Edit: I should have been clear that the circuit should require that the Uno bring an output high to turn on the high-side switch. This would require two stages, with the Uno output driving an NPN, which in turn switches the high-side P-channel mosfet's gate. A low-side switch only requires one stage - the N-channel mosfet - so it's a simpler circuit.

Yes.

A sensor that is powered from VCC of the processor can never phantom-power the MCU.
That only can happen when the sensor is on a different supply.

Sometimes you must cut positive supply, sometimes it's safer to cut ground.
It all depends on the sensor, which you left us in the dark about.
Leo..

I was wondering if the MCU would phantom-power the sensor, not the other way around. The sensor is the DFRobot Gravity: Turbidity Sensor. Would it be better to cut positive supply or ground?

https://wiki.dfrobot.com/Turbidity_sensor_SKU__SEN0189

Thanks :)