# Switching power to a sensor

I want to control the power supply of a sensor with a microcontroller, so I can turn it off when it isn't being used. My goal is to minimize power consumption on a battery-powered device.

Both the microcontroller and sensor are running on 3.3 V.

Can I use a single MOSFET directly driven by the controller? Or is there a better method?

atmega328p micro controller and GY 61 accelerometer sensor are used.

• How is the sensor wired to the rest of the circuitry? It can make a huge difference. For example, if you add the switch in the ground leg and an input to the sensor is pulled low, that might leak power into the sensor and activate it -- possibly even overloading the output connected to the sensor input. – David Schwartz Feb 22 '17 at 12:10
• How much current is your sensor pulling? If it's significantly lower than the max current from an I/O pin (and the I/O pin can drive to 3.3V), one option is to directly connect the power lines of the sensor to an I/O pin on the micro. – CHendrix Feb 22 '17 at 12:37

Probably- one method would be to use a P-channel MOSFET as a high-side switch to control the 'sensor' power. You might have to add a pull-down or otherwise ensure that the output of the 'sensor' was close to 0V with no power- if it is allowed to float around the MCU power consumption might increase.

There are many inexpensive logic-level MOSFETs that will work fine from -3.3V gate voltage with guaranteed very low Rds(on) and reasonable guaranteed leakage.

simulate this circuit – Schematic created using CircuitLab

You may have to ensure that the 'sensor' supply has some series impedance or that the MOSFET does not switch too rapidly if the 'sensor' has large bypass capacitance- otherwise it could glitch the MCU power when it turns on and cause problems.

• Thanks for your reply sephro. I will try this after that i will confirm you. – vishnu m c Feb 22 '17 at 7:39
• Can you suggest a P-channel MOSFET? Sir, Spehro Pefhany – vishnu m c Feb 22 '17 at 7:48
• You can also use a NMOS to switch ground, which has the same effect. To get a part you'll need to provide more info about current consumption and times – Christian Feb 22 '17 at 11:46
• A capacitor between the gate and drain pins on M1 will give you a soft-start if the sensor inrush current is a problem. – Andrew Feb 22 '17 at 12:09
• See if one of the Alpha and Omega (manufacturer) SOT-23 P-channel MOSFETs will work for you. AOxxxx. – Spehro Pefhany Feb 22 '17 at 13:52

You may have a simpler option. If the sensor's maximum current requirement is low enough, you can use a digital output (from your microcontroller) to power the sensor directly.

Check the following things:

• The microcontroller's digital output, when set high, may not reach all the way to 3.3 V. Look for $V_{OH}$ in the datasheet. Make sure that the this voltage is acceptable for your sensor.
• The microcontroller has a maximum output current for digital outputs. It this greater than the sensor's current draw?

If you update your question with the part numbers of your microcontroller and sensor, we can give you specific examples.

• i am using Atmega328p controller. I think output voltage at I/O pin is 2.3V – vishnu m c Feb 22 '17 at 15:29
• @vishnumc Thank you. What is your sensor, please? – bitsmack Feb 22 '17 at 17:09
• sensor used is GY 61 accelerometer – vishnu m c Feb 23 '17 at 8:00

You did not specify sensor type or its power consumption, but here are some options:

1. You can use a dedicated power switch chip, for example: TI load switches. They can also come with overcurrent protection, so if your sensor is dangling on a cable outside and you short power to ground it will not disable your device.

2. You can use a separate LDO with an ENABLE pin to disable power delivered to the sensor (for example MIC5205).

3. If the sensor is consuming very little power (below <10mA - check your MCU pin specification) you can just power it directly from a GPIO when needed (CHEAPEST).

I'll add a cheap ghetto solution:

If your sensor draws a small current (like a few mA) you can use a good old-fashioned logic gate as a switch. Pick one with high drive strength, like 74AC or 74LVC.

Hell, you can even use an IO from your micro. Or a pin from an I2C IO extender if you have one in your design.

This is obviously not for every situation, but when applicable, it does allow you to switch several loads with a single chip, and it is cheap and compact.