I'd like to switch power supply of two sensors, each of them with a bypass capacitor at their supply pin, with an ATmega328P MCU output pin with an absolute maximum rating of 40mA.

The sensors themselves together draw only about 230µA.

The capacitors are 100nF, the supply voltage is 4.8V max:

From the data sheet of the TMP36

Image source: Analog Devices TMP36 datasheet

To reduce charge current I'm adding a series resistor of 68Ω to the capacitor.

So I calculate for one sensor:

Charge energy/time: 1.15µJ/68μs
Power: 0.17W
Current: 35.2mA

For two sensors this would be about 70mA - well above the 40mA the MCU pin can switch.

Provided I calculated correctly, what would be the preferred solution?

  1. Increase series resistance to 150Ω to get a charge current of about 32mA. What is the consequence - just a slight delay until the bypass capacitors have their full effect?
  2. Use a MOSFET to switch power supply of the sensors and no series resistors at all?
  • 1
    \$\begingroup\$ Please don't use such large numbers of zeroes in your numbers; use SI prefixes. Are you sure the capacitors have 68 Ω ESR? That's very high, especially for such a small capacitance. Or do you mean they have an additional 68 Ω resistor in series with them? In that case, that's probably not a bypass capacitor; you wouldn't bypass with such a high resistance as it defeats the purpose of a bypass capacitor. Perhaps you should show a schematic of what you're talking about. \$\endgroup\$
    – Hearth
    Jun 8 at 14:48
  • \$\begingroup\$ Thank you - I have improved my question. \$\endgroup\$ Jun 8 at 15:03
  • 1
    \$\begingroup\$ Adding a series resistor to the capacitor will be counterproductive. The point of a bypass capacitor is to have a low impedance, as low as possible. With 68 Ω in series with it, it basically won't act as a bypass capacitor at all. \$\endgroup\$
    – Hearth
    Jun 8 at 15:08
  • 1
    \$\begingroup\$ Your MCU pins likely have current limiting (of course check this) that will allow the bypass caps to charge to the full supply voltage, at which point they will not draw much average current from the supply, so you shouldn't have an issue. The only issue may be start-up time of your sensors, but reducing the effectiveness of the bypass caps by adding series resistance isn't a good idea anyway. \$\endgroup\$
    – John D
    Jun 8 at 15:11
  • \$\begingroup\$ @Hearth That answers my question - I should use a MOSFET to switch the sensors. Did I at least calculate the charge current correctly? \$\endgroup\$ Jun 8 at 15:13

2 Answers 2


You have many options.

One is to have single current limiting resistor of 4.8V/40mA = 120 ohms for both sensors, each with their own 100nF bypass cap. The only downside is the small voltage drop but it's insignificant.

Even simpler, no reasistor at all.

The IO pin has approximately 35 ohms output impedance at 5V, even higher output impedanve at lower supply voltage.

If you only do the cap charging occasionally and not thousands of times per second, it might just be fine and won't heat up too much locally.

You can always pre-charge the capacitor by using the internal pull-up which is about 20k to 50k, sourcing about max 130uA of current.

  • \$\begingroup\$ I like your last option and tried it. On the scope I see that the pull-up charges to 1V within about 25ms, then voltage stays at 1V until pin is driven high. Is that okay, will the pin not be overloaded when it has to charge from 1-4.8V? The caps are actually 2.2uF + 100nF ceramic. \$\endgroup\$ Jun 8 at 17:42

Maybe you can precharge the bypass cap with pin1 and then switch to pin2 if you have enough I/O-s.


simulate this circuit – Schematic created using CircuitLab

  • \$\begingroup\$ Thanks for your suggestion, but I'm afraid I lack experience to really understand it. I probably just go for a MOSFET like the BSS84 as someone else here recommended. That will also save the two series resistors. \$\endgroup\$ Jun 8 at 15:30
  • 1
    \$\begingroup\$ I mean during sensor OFF the both MCU pins are Low. Once you decide to switch sensor ON just set Pin1 to High and Pin2 to high-Z. After 1ms the cap is charged so you can switch pin2 High without current spikes. Now the sensor is successfully switched ON. \$\endgroup\$ Jun 8 at 15:43
  • \$\begingroup\$ Okay I see now, Pin1 charges via 220Ohm limiting the current, then Pin2 "defeats" the voltage drop - right? \$\endgroup\$ Jun 8 at 18:21
  • \$\begingroup\$ @TorstenRömer You are right. Just think about if both pins are High, the overall serial resistance is a parallel combination of resistors. So choose a appropriate values of resistors. Or the 220ohm one let floating. \$\endgroup\$ Jun 8 at 18:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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