ESP32 reset by software!

For general Flowcode discussion that does not belong in the other sections.
Post Reply
jgu1
Posts: 813
http://meble-kuchenne.info.pl
Joined: Thu Dec 03, 2020 8:25 pm
Location: Denmark
Has thanked: 696 times
Been thanked: 183 times

ESP32 reset by software!

Post by jgu1 »

Hi!

Is it possible to hardreset the software the ESP32 by help of a C command, pls ;) If it is possible, is it then nessesary to add something in "Supplementary code"

Br Jorgen
Last edited by jgu1 on Sun Jan 15, 2023 8:30 pm, edited 1 time in total.

mnfisher
Valued Contributor
Posts: 1635
Joined: Wed Dec 09, 2020 9:37 pm
Has thanked: 142 times
Been thanked: 761 times

Re: ESP32 reset by software!

Post by mnfisher »

Try:

Code: Select all

esp_restart();
In a C block.


See https://docs.espressif.com/projects/esp ... m_api.html


Martin

jgu1
Posts: 813
Joined: Thu Dec 03, 2020 8:25 pm
Location: Denmark
Has thanked: 696 times
Been thanked: 183 times

Re: ESP32 reset by software!

Post by jgu1 »

Hi Martin!

I already try your suggest, But then i get error when I compile?

I give it a new go tomorrow again.

Thank youvery much.

Jorgen

mnfisher
Valued Contributor
Posts: 1635
Joined: Wed Dec 09, 2020 9:37 pm
Has thanked: 142 times
Been thanked: 761 times

Re: ESP32 reset by software!

Post by mnfisher »

Seems to work okay...

A simple program - just waits 5s then restarts and does it all again...
restart.fcfx
(6.25 KiB) Downloaded 207 times
Martin

jgu1
Posts: 813
Joined: Thu Dec 03, 2020 8:25 pm
Location: Denmark
Has thanked: 696 times
Been thanked: 183 times

Re: ESP32 reset by software!

Post by jgu1 »

Hi Martin!

Work´s now, thank you ;)

Jorgen

mnfisher
Valued Contributor
Posts: 1635
Joined: Wed Dec 09, 2020 9:37 pm
Has thanked: 142 times
Been thanked: 761 times

Re: ESP32 reset by software!

Post by mnfisher »

Glad to hear it works okay.

Gave me an idea to do an utility component for esp32 with some of these type 'commands' in it.

I did a small trial:

Restart() - restart the MCU
RegisterShutdownHandler(addr of macro) - macro to be called before restart (see demo)
UnRegisterShudownHandler(addr of macro) - unregister a shutdownhandler
GetRestartReason() - 1 is power on, 3 is Restart() called (there are others though I didn't look them up)
GetFreeHeapSize() - get some memory stats
GetMinimumHeapSize()
GetFreeInternalHeapSize()

ESPUtils.fcpx
(1.61 KiB) Downloaded 215 times
ESPUtilsDemo.fcfx
(13.65 KiB) Downloaded 275 times
Need to add the fcpx file to component directory (Global Options->Locations->Search For Components in)

Demo - is very simple and just displays the values from each routine. - then uses a ShutDownHandler to do a 5s countdown to a restart...

Any ideas on 'useful' macros (I just used a handful from the link above)

Martin

Post Reply