Skip to main content
Graduate II
November 15, 2024
Question

Power turn ON and Power turn OFF detection.

  • November 15, 2024
  • 3 replies
  • 2586 views

My requirement is as follows.
When I power ON the STM32L4 series MCU, a string must be sent on to the UART terminal like "Power is ON". Now abruptly I will power OFF. Now at this instance, another string must be sent to UART terminal which is "Power is OFF". How to do this? Kindly let me know the solution if anyone has come across such a situation.

Thank you!

    This topic has been closed for replies.

    3 replies

    Technical Moderator
    November 15, 2024

    Not obvious.

    Need to keep the MCU powered while sending string over UART.

    Use external capacitor/super cap to power supply the MCU during the power down? + detect the power drop on power source to trigger the UART transmission?

    vbk22398Author
    Graduate II
    November 15, 2024

    @mƎALLEm wrote:

    + detect the power drop on power source to trigger the UART transmission?


    How to do the above? I am completely out of ideas to implement your logic. Could you be a little elaborate. I have doubts like to which pin should I connect the external capacitor/super cap. What is the rating of capacitor? Are there any other options apart from capacitor. How to track the power down? Kindly elaborate.

    Thank you!

    Technical Moderator
    November 15, 2024

    @vbk22398 wrote:


    I have doubts like to which pin should I connect the external capacitor/super cap. 

    Check if the MCU features an internal comparator that will compare the power supply level to what expected. Otherwise need to add an external comparator that detects the power down which triggers over MCU EXTI the UART transfer.

     


    @vbk22398 wrote:


    What is the rating of capacitor? Are there any other options apart from capacitor. 


    The capacitor needs to be mounted on the power supply of the MCU. For the rating you need to find it yourself by test ..

    Make some internet search on super cap usage, example: https://www.digikey.com/en/articles/how-to-use-a-single-supercapacitor-as-backup-power-for-a-5-volt-supply

    PS: we are here to guide you and propose some guidelines not supposed to provide a complete solution.

    Thanks

    Super User
    November 15, 2024

    @vbk22398 wrote:

    When I power ON the STM32L4 series MCU, a string must be sent on to the UART terminal like "Power is ON". N!


    That bit's easy - just make sending that message the first thing you do!

     


    @vbk22398 wrote:

    Now abruptly I will power OFF. Now at this instance, another string must be sent to UART terminal which is "Power is OFF". How to do this? 


    That requires two things:

    1. detect that the power has gone OFF;
    2. have sufficient backup power to keep the microcontroller running long enough to complete sending the  "Power is OFF" message.

     

    Super User
    November 15, 2024

    But this can be also seen "upside down". Imagine a smarter terminal that understands periodic "heart beat" signals from the MCU. The first time it sees the signal, it prints "Power on". After it misses couple of signals it prints "power off" or whatever ))