logo elektroda
logo elektroda
X
logo elektroda

ESP32: Distinguish Wake-Up by Button vs. Deep Sleep Using RTC Module

Dawidixxx 585 7
ADVERTISEMENT
Treść została przetłumaczona polish » english Zobacz oryginalną wersję tematu
  • #1 19806057
    Dawidixxx
    Level 7  
    Hey hey ;) .
    I'm working on a small project where I need to distinguish if the esp was woken up by a button or a wakeup.
    My plan was to extract the time from the RTC module and compare it with a fixed wake-up time, I am looking for such a solution but cannot find one.

    The second solution is the circuit I already used Link . That is, a single state change on reset and a continuous signal on the pin, but I would like to solve this somehow in code rather than circuit.

    Does anyone know maybe a better solution or a version with an RTC clock would be good? I don't know much how to get the time out of it.
    Greetings Dawid
  • ADVERTISEMENT
  • #2 19806537
    khoam
    Level 42  
    Now write which chip you are referring to, ESP8266 or ESP32? This is quite important in the context of wake-up and RTC.
  • ADVERTISEMENT
  • #3 19806701
    Dawidixxx
    Level 7  
    8266 on d1 mini, will eventually be on the raw version, there are probably better solutions for this on 32
  • Helpful post
    #4 19809586
    khoam
    Level 42  
    Dawidixxx wrote:
    My plan was to pull the time from the RTC module and compare it with the fixed wake-up time
    .
    If without an external RTC chip, it remains to run the NTP client to get the current and accurate time. The wake-up time should then be calculated based on the current time and the time of the scheduled wake-up.
  • ADVERTISEMENT
  • #5 19809616
    Dawidixxx
    Level 7  
    This is a very cool idea, the program connects to the network to send data (when the button is called) and every 10 minutes to retrieve the data.
    However, it's also about detecting the click quite quickly (the circuit controls the servo), I guess I'll have to use this circuit though so that I have to hold the button down a bit longer while waiting for the effect, the program will detect that it has a signal on the pin during reset.

    Thank you for your help and good advice ;) it's a pity that in this module there is not some extra flag from this, or that the RTC time clears after preinit().
  • ADVERTISEMENT
  • #6 19809832
    khoam
    Level 42  
    Dawidixxx wrote:
    It's a pity that there isn't some extra flag from this module, or that the RTC time clears after preinit()
    .
    I don't really understand this statement. What functionality would be needed?
  • #7 19809926
    Dawidixxx
    Level 7  
    To distinguish precisely whether the reset was triggered spontaneously or by the user. E.g. by a value in the RTC memory or if a wake-up was triggered. It's just a pity, as I read somewhere, that the RTC memory (I'm still referring to the built-in module here) is erased when the chip is booted up, although this probably already happens together with the reset.
  • #8 19810052
    khoam
    Level 42  
    Dawidixxx wrote:
    To distinguish just whether the reset was triggered spontaneously or by the user.
    .
    At this link is an example of how to identify the cause of an ESP32 reboot: Link

    Dawidixxx wrote:
    It's just a pity as I read somewhere that the RTC memory (I mean the built-in module all the time) is erased during chip startup
    .
    But not during deep-sleep on the ESP32. Link

Topic summary

The discussion revolves around distinguishing whether an ESP32 microcontroller was woken up by a button press or a scheduled wake-up using an RTC module. The user initially considered comparing the RTC time with a fixed wake-up time but sought a code-based solution rather than a circuit modification. Responses highlighted the importance of specifying the chip model, with suggestions to use an NTP client for accurate time retrieval if an external RTC is not available. The conversation also touched on the limitations of the built-in RTC memory, which may be erased upon boot, complicating the detection of the wake-up source. A link to an example of identifying reboot causes on the ESP32 was shared, although it noted limitations during deep sleep.
Summary generated by the language model.
ADVERTISEMENT