I hve a very simple project where I have a ttp233 touch sensor which I'm using to control my relay module which inturn switches my fans on and off. The problem here is whenever there is a power loss the relay defaults to a low state and I have to touch the sensor again to turn on my fan. So I thought of using a battery to compensate ,so I want help regarding this. I want to have it in such a way that when the power is ther the relay and sensor should run on wall power and the battery also should be charged but when there is a power loss the battery should kick in and power the circuit with no delay so that my appliances stay on during power loss and when the power comes back on again the circuit should again go back to using wall power . Is there any way I can achieve this?