1
\$\begingroup\$

I am really new to electronic and wish to learn more. Pardon me if the question is inappropriate.

I am trying to turn a led on, off or dim over the Internet. My question is how can i maintain the state of the led if something happens to the Esp8266, for example the unit get reset or crash. So that the led doesnt go off if it was previous turn on when the Esp8266 rebooting.

My guess is that this might involve some external chip or circuit. When the esp8266 receives a command to turn the led on. it will then forward the state to a chip which powered separately. And so, the chip can power the led even if the esp8266 is rebooting.

I am wondering what the chip or circuit would be? (shift register or etc).

Thanks for the advice.

asked Apr 18, 2016 at 16:44
\$\endgroup\$

1 Answer 1

0
\$\begingroup\$

You are correct, if the micro resets, the GPIO state will be lost.

You will need an external chip, but you need to make sure that any intermediate state of the micro's GPIO during reset does not update the external chip's state. This often means putting pull-up or pull-down resistors so that the GPIOs going high-Z doesn't trigger anything.

The external chip could be a shift register with an independently clocked output stage, such as the SN54HC595 or an addressable latch such as the 74HC259.

One other thing I suggest is to feed the outputs from the external chip back to additional GPIOs, set as inputs. This way, when your microcontroller reboots, it can read these GPIOs to see the actual state of these outputs.

answered Apr 18, 2016 at 19:08
\$\endgroup\$
3
  • \$\begingroup\$ Hi @DoxyLover, thanks for the information. Just a few more doubt i would like to seek for your advice. if a shift register is used, how can i provide a independent clock to the shift register and the mcu? Both clocks have to be sync right? \$\endgroup\$ Commented Apr 19, 2016 at 2:07
  • \$\begingroup\$ In general, the shift register clock is completely independent of any clock going to the mcu. You'd use several GPIO outputs from the mcu: one for the clock, one for data, and one for the load outputs (and maybe one for output enable). Basically, your code would set the data GPIO, then set the clock high and then low (or visa versa if active low) to clock the data into and through the SR. Most shift registers are completely synchronous to the clock and it can come as fast or slow or have as much jitter as you want, as long as you obey the timing restrictions of the device. (continued) \$\endgroup\$ Commented Apr 19, 2016 at 5:35
  • \$\begingroup\$ Running code on a low-MHz clocked mcu, it's almost impossible to overrun most shift registers. \$\endgroup\$ Commented Apr 19, 2016 at 5:36

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.