I have a very simple project where I have a ttp233 touch sensor which I'm using to control my relay module which in turn 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 (My house has an inverter so power outage is not the main issue but when there is a power loss my inverter takes about 2-3 sec to kick in and in this gap the relay returns to default of off state).
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 there 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 or any other way that my relay state remains where it is after a power cycle(The state of the relay is determined by the state of touch sensor so if there is a way to power my touch sensor during this brief power cycle please tell me.). Is there any way I can achieve this?