Powering a stepper and charging a battery from mains

I want to make a mod of a popular IKEA PS 2014 lamp, which uses a stepper (28-BYJ48) to open and close the lamp. The issue I have is that I have only one mains connection (two wires) running to the lamp. As switching off the lamp cuts the only power source available there, the closing of the lamp would need to be powered from a battery charged while the lamp is lit. Opening would be done when the power is on.

I am somewhat confused how to make a circuit that would allow me to charge the battery (from 220V) and power the mechanism at the same time, but switch to battery power when the mains power is cut. Is that possible?

First you need to know what the circuit of the lamp is. Begin your project by drawing a schematic for the lamp, including the mains connection.

Why can't you just run your board of a rechargeable battery and connect the charger to the battery? You will need two batteries though, one for your board and another for your motor...

This level of question suggests the obvious.
Get someone that is safe with mains to set it up for you.

I know you’re ok, but your niece or nephew, neighbour or cat isn’t = hazard

For that the battery would need to support passthrough feature (charging while supplying power), which they rarely do. There are some options available, but they are too big and expensive. I am trying to find something small enough to suit my purpose.

You can use a wired-or circuit to power your device from the source with the higher voltage and trickle charge the battery at the same time.


The suggest a 1 meg resistor for the trickle charge.

Thank you for the diagram!

I have done some more searching and it seems that there are several commercial products which serve a similar purpose, typically they are used as UPS e.g. for Raspberry Pi. I think I will just go with one of those, as they are both small and inexpensive.

Not necessarily. That feature can be provided by the battery or the charger.