# Calculating charge current of a bypass capacitor, choosing series resistance

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:

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?
• 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. Jun 8 at 14:48
• Thank you - I have improved my question. Jun 8 at 15:03
• 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. Jun 8 at 15:08
• 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. Jun 8 at 15:11
• @Hearth That answers my question - I should use a MOSFET to switch the sensors. Did I at least calculate the charge current correctly? Jun 8 at 15:13

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.

• 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. 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

• 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. Jun 8 at 15:30
• 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. Jun 8 at 15:43
• Okay I see now, Pin1 charges via 220Ohm limiting the current, then Pin2 "defeats" the voltage drop - right? Jun 8 at 18:21
• @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. Jun 8 at 18:48