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?

  • So as I'm understanding, the fans won't be powered by the battery and you just want to preserve the state of the relay for when the power turns on again? That would be easier done by saving the state in a persistent memory like EEPROM. You can write the data when the touch sensor triggers and read it back at startup (in setup()) and set the relay accordingly. – chrisl May 23 at 5:24
  • 1
    @chrisl I'm not using a microcontroller I'm just using a ttp223 and a relay with the output of ttp223 sensor hooked to input of the relay – rohithrathod banoth May 23 at 5:34
  • without power the fan won't run either. I would put a diode in front of the tp, then a large capacitor parallel to it's vcc/gnd to keep the touchpad running during brief power outages. – dandavis May 23 at 7:20
  • 1
    Have you looked at a latching relay? – Gil May 23 at 18:57
  • 1
    @Gil I have and they are not available in my region atleast the ones that are reasonably priced – rohithrathod banoth May 23 at 19:04