Way to force reset of Nodemcu with a command?

Can i make a nodemcu reboot itself when a certain counter gets too high? I have googled and read a lot but most of it is over my head sadly.

Whenever we see a question like that (programmatically reset processor) our question is, why. There is, almost never, any reason to force a reset. This is an XY problem. You are asking us to help you use your solution to a problem without us knowing anything about the problem.

sevenoutpinball:
Can i make a nodemcu reboot itself when a certain counter gets too high? I have googled and read a lot but most of it is over my head sadly.

There is a way to do this, however this is not the correct solution. Please describe why you feel you need to reset when a counter gets too high? Would it not be far easier to detect when the count gets to this magic number and reset the counter?

ESP.reset();

https://arduino-esp8266.readthedocs.io/en/latest/libraries.html#esp-specific-apis

Not very elegant, but short:

while(1) ;

The watchdog timer will oblige.

And apart from the ESP.reset() already mentioned there is also ESP.restart() .

Sure I don't mind saying why, I have a 1958 pinball machine back glass (Williams Gusher) that I made into a clock and weather teller. Now this morning it fired up (it's on a timer) and for some reason the time was off. I unplugged it and plugged it back in and everything was fine.

Time comes from "pool.ntp.org"

But that got me to thinking, because the next project is having some exterior lights come on at sunset and off at sunrise, what if it makes a mistake again. So to prevent that, issue some command to have it do a reset. Obviously the WDT thing will do that, but maybe that is not the best approach.

sevenoutpinball:
Sure I don't mind saying why, I have a 1958 pinball machine back glass (Williams Gusher) that I made into a clock and weather teller. Now this morning it fired up (it's on a timer) and for some reason the time was off. I unplugged it and plugged it back in and everything was fine.

So what code was executed that reset which variables to their correct values ? Should you just execute that part of the code ?

no idea, only happened once.

sevenoutpinball:
no idea, only happened once.

I didn’t mean what code caused the reset, i meant what code do you need to execute to load the correct values in again.