Awhile back this post asked about providing 3-4 seconds of power to an NodeMCU subsequenst to a loss of its primary power supply.

Prior Post

I have a similar need except I only need a split second of power. I tried using a 1000uf capacitor but that did not work. Is a supercapacitor reasonable to try.


I attached a diagram of the set up. I am not an EE and apologize if the diagram is not proper form.

The context of the application is a model train getting 18V power from the railroad track. The 18V is stepped down to 5V with a regulator and used to supply the NodeMCU at Vin. The NodeMCU is used to control the train. When the train passes over a track switch it can interrupt the power for a split second, enough to shutdown the NodeMCU.

I do not want to use a battery to cover the interruption and hoping I can simply insert a capacitor.

One other question. Assuming the super capacitor works, if the regulator was supplying say 9 volts, would the immediate drop the 5.5 V of the capacitor be a problem. Te NodeMCU has a a regulator on board and I am thinking it could handle this. Again, the disruption is perhaps 1/10th - 2/10ths of second.

enter image description here

Thank you for your replies.

I am using a Rohm linear voltage regulator. BA50DDoT

I will give the 1000uf a try in front of the regulator.

I will also try the code suggestions.

I did some more digging on power consumption.

for those interested, this video is informative. The second half show the NodeMCU.

Your replies greatly increased my understanding of the power issues.

Thank you all.

YouTube on ESP Power Consumption

  • \$\begingroup\$ So, if the train was travelling really slowly over a track switch, what would you do to make it work? IMHO you should use a diode and hold-up capacitor before the regulator. \$\endgroup\$
    – Andy aka
    Apr 11, 2020 at 13:52
  • \$\begingroup\$ Which super capacitor are you wanting to use? What VIN voltage are you running the MCU at? \$\endgroup\$
    – Ron Beyer
    Apr 11, 2020 at 13:52
  • \$\begingroup\$ If possible I'd appaly the cap at the step down convert's input, so at tje 18V. This way it stores much more energy and you will still have the 5V regulated... \$\endgroup\$
    – Sim Son
    Apr 11, 2020 at 15:56

1 Answer 1


I've tried to find supply current draw for nodemcu, seems like it draws 35mA while operating and 300mA while using WiFi.

Add the voltage regulator idle current, about 5-10mA if it's a 7805. Let's say 40mA total with WiFi off.

Your suggested ultracapacitor has 65 ohms ESR (equivalent series resistance) so it would cause a quite high voltage drop : 40mA * 65 ohms = 2.6V drop, not acceptable on a 5V supply. This type of cap with high ESR is designed to backup SRAMs which draw microamps. It won't work in your case.

Reminder: \$ \frac{dv}{dt} = \frac{i}{C} \$

With a 1000µF cap and 40mA current, dv/dt = 40 V/s.

So a 1000µF 25V capacitor placed BEFORE the voltage regulator will go from 18V down to 8V in about 0.25 seconds. It will work as a backup for 0.25s which should be enough for the short power interruption when the model train rides over a track switch. I've used 8V as a lower limit, it depends on the regulator, maybe it'll work down to 6V. If it is a switching regulator, it will be more efficient so it will last longer.

When using a cap as backup power supply you always want to put it before a voltage regulator, so the voltage on it is allowed to ramp down. If the voltage is not allowed to vary then only a tiny part of the charge stored inside the cap can be used, and a battery is usually a better solution.

Note that you should add a diode on the 18V line to make sure the cap does not discharge into the motor.

Now if the chip is transmitting over WiFi it will use a lot more current, so the capacitor will have to be a lot larger. You should add an interrupt in your code which detects power loss and immediately puts the micro in low power mode, or at least stops any wifi transmission.

In fact, if you put it in sleep mode fast enough when power is lost, maybe a much smaller cap value will do. That depends on how much of the rest of the circuit you can put in sleep mode, for example if there are LEDs or a motor driver, these will have to be turned off when power is lost to save energy, then turned back on when power is restored.

  • 1
    \$\begingroup\$ I'd like to add that we're all assuming that OP is using something like an LM7805, but are all hoping that he's actually using something smarter – a switch-mode power supply would drastically increase battery life, and also reduce the size of the battery-side capacitor! \$\endgroup\$ Apr 11, 2020 at 15:26
  • 1
    \$\begingroup\$ True! Although, if it's a mains-powered model train, microcontroller power use will probably be small compared to motor power... \$\endgroup\$
    – bobflux
    Apr 11, 2020 at 15:42

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.