i'm trying to control my sensors power supply to reduce the current consumption of my project. i'm using ATmega328p that collect information from different sensors (digital and analog sensor) and send it using an xbee.For the xbee part i'm using the sleep mode so i don't think i have a problem with that but for the analog sensor it has its own electronic board that consume 10mA which is too much for an IOT project and even for the digital sensor that consume 1.5 mA it's not acceptable to run all the time consuming 11.5 mA for nothing, that's why i want to control the sensor's power to turn it on only when i need it and switch it off in sleep mode. the problem is, i don't know what device i need to use for something like this. i already know the ULN2003 and L293d but those h-bridges are for motors and using transistor or MOSFET may consume more current.I was thinking if it's enough to power the sensor on using one IO pin as an output since it needs only 3.3v-5.5v and 10mA for the analog sensor and 1.5mA for the digital sensor, but connecting 4 sensors to 4 pins may reduce the output voltage for all of them and i won't be able to turn them on. I'm looking for an advice to how control my sensors to reduce the power consumption. Thank you.

  • 3
    \$\begingroup\$ Please provide links to the manufacturer's datasheets for all of the sensors you are planning to use. Also, we need to see a schematic of how everything, including the ATmega and power supply, is connected together. \$\endgroup\$ – Elliot Alderson Mar 27 '19 at 17:44
  • 4
    \$\begingroup\$ We don't expect every post to be perfect, but posts with correct spelling, punctuation, and grammar are easier to read. They also tend to get read and upvoted more frequently. (Proper capitalisation includes sentences, part numbers, brand names, SI unit symbols - V and A, etc.) Remember, you can always go back at any time and edit your post to improve it. This is site policy. See Write to the best of your ability on the site's help pages. \$\endgroup\$ – Transistor Mar 27 '19 at 17:57
  • \$\begingroup\$ sorry for misspelling and about the manufacture's datasheets and schematic. as i said, i'm looking for the right device to use for my project so they are no schematic and about the sensors as i mentioned before one of them consume 10mA and the other one consume 1.5mA and both uses around 3.3V to 5.5V and i'm using an ATmega328p as my MCU and maybe i will change that. i can provide you some links but they will not help you. i already told you the important things about what i'm using. thank you. \$\endgroup\$ – shadow Mar 27 '19 at 19:44
  • \$\begingroup\$ Paragraphs break up walls of text. \$\endgroup\$ – Chu Mar 27 '19 at 21:57

Use a logic-level N-MOSFET to do this. This will require almost no additional power and is very simple to implement.

This is called a low-side switch. You interrupt the common/ground line of the sensor, insert an N-MOSFET. Like this:


simulate this circuit – Schematic created using CircuitLab

Make sure you use a logic level MOSFET. A high signal from the I/O will power up the device, a low signal will turn it off.

| improve this answer | |
  • \$\begingroup\$ thank you for your help. i have a question, form your point of view, which component is suitable for my application, using mosfet or BJT. and i do like to know why choosing that one from the other. and about MOSFETs do you have any recommend?. \$\endgroup\$ – shadow Mar 27 '19 at 19:11
  • 1
    \$\begingroup\$ You want an N type MOSFET because it will act like a switch and a BJT will drop too much voltage. Choose one that can handle the current, has gate threshold and Rds-on as low as possible. \$\endgroup\$ – evildemonic Mar 27 '19 at 19:31
  • \$\begingroup\$ Another advantage of the MOSFET over the BJT is you will not consume current to operate it. The MOSFET just needs voltage on its gate to operate and does not draw current the whole time you are using it. \$\endgroup\$ – evildemonic Mar 27 '19 at 19:42
  • \$\begingroup\$ so helpfull, thank you so much. \$\endgroup\$ – shadow Mar 27 '19 at 19:45

Powering your sensors through IO pins could be feasable but you should watch the ATMega's pin voltage drop against the minimum supply voltage for each sensor. At 1.5 mA you'd be fine, but 10 mA would cause a ~0.3 V drop according to Atmel's datasheets and your analog sensors may not like that. Everything is "could" or "may" without knowing the specific sensors. Remember that internally the microcontroller will be using transistors for sourcing/sinking it's IOs and those may not be very efficient for larger-ish currents.

So maybe you could choose your own MOSFET for switching the sensors' supply. It would certainly consume more current than nothing at all but this increase should be much less than your sensors full time current draw. Try to get a low RDS(on) one and it would waste very little energy.

Also remember that powering on the sensors could take some wake up time, during which they could consume more current than they normally do.

| improve this answer | |
  • \$\begingroup\$ thank you for making things clear. i have read about mosfet and transistor and the difference between them, comparing the current consumption for both of them, they said BJT consume less power unlike the JFET because the FET gate act as a capacitor that need to be charged when the base of the transistor just need some current for the activation. and that makes me think that the best choice is using a BJT. but what i'm seeing in many projects that people are using MOSFETs (using them for high current applications which is not my case). but i think i'm wrong about this, or just confusing!!? \$\endgroup\$ – shadow Mar 27 '19 at 18:51
  • \$\begingroup\$ inside the ATMEGA they are MOSFETs driving the pins there will be some voltage drop because the MOSFETs are microscopic. \$\endgroup\$ – Jasen Mar 28 '19 at 9:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.