logo elektroda
logo elektroda
X
logo elektroda

ESP8266 - How to preserve pin states after a power loss?

kuba2509 2406 3
ADVERTISEMENT
Treść została przetłumaczona polish » english Zobacz oryginalną wersję tematu
  • #1 16156556
    kuba2509
    Level 14  
    Hello
    i have an ESP8266-based circuit for connecting 10 power sockets via relays. During its construction, I did not pay attention to a small problem that occurs after a power failure. After the power supply reappears, the states on the pins have nothing to do with the states before the power failure, of course, after switching the relevant outputs on or off again, everything returns to normal (BLYNK). Is there a chance to eliminate this problem.
  • ADVERTISEMENT
  • #2 16156616
    szymon122
    Level 38  
    kuba2509 wrote:
    is there any chance of eradicating this problem

    No, it has :D
    You need to:
    (a) Delay the switching on of the outputs to the circuit.
    b) Use one output to "reset" the rest.
  • ADVERTISEMENT
  • #3 16162227
    krzbor
    Level 28  
    You have to store each change in the EEPROM. After restarting the circuit, you read the states from the EEPROM and set the outputs according to them.
  • #4 16163017
    Slawek K.
    Level 35  
    As colleague @krzbor writes, the simplest method is to write the pin state (0 or 1) to the EEPROM and load at startup. In order not to kill the EEPROM with writes, the write should only be done when the pin (relay) state changes to the opposite. I would suggest, however, for safety reasons (control of 230V devices) to switch off the relays at start-up, because it is not known whether after a power failure and some time the devices should be switched on, but you have to judge this yourself, because you know what you are controlling.

    Best regards
ADVERTISEMENT