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