How to restore infinite loop nodemcu

I made a mistake loading init.lua with infinite loop on my nodemcu / ESP8266 board.

The board then continues to reboot without any other instruction.

i = 10
timerId = 0
timerDelay = 30000 -- Milisec
pin = 5
gpio.mode(pin,gpio.INPUT) 
repeat(    
    print(gpio.read(pin))
    i = i + 1
    end)
until i < 5

      

+3


source to share


5 answers


I tried flashing the board

python esptool.py -p /dev/tty.wchusbserial1450 run

python esptool.py -p /dev/tty.wchusbserial1450 write_flash 0x0000 ../nodemcu_latest.bin

      



And after that fix my code and upload it again and now works fine

+2


source


I am using ESPlorer (Java Application) http://esp8266.ru/esplorer/#download

While I'm cheating, I just have my init.lua

file named init1.lua

, if ESP doesn't reload it you just click the button init1.lua

that is displayed on the right (after you use Reload to display the contents of the filesystem)



Nice and easy, when you do that, you can right click on the file to rename it back to init.lua

.

+1


source


--This file is init.lua
local IDLE_AT_STARTUP_MS = 10000;

tmr.alarm(1,IDLE_AT_STARTUP_MS,0,function()
    dofile("program.lua")--Write your program name in dofile
end)

      

I use this strategy to prevent an infinite loop on startup when an error occurs. Save this file as init.lua and write your programs in program.lua

+1


source


There is no elegant way to recover.

The best thing to do is build a way to prevent your code from speaking out in an emergency. For example, as TerryE suggests, set a one-shot timer using timer.alarm

in init.lua

to trigger your main code with a long enough delay that you can call timer.stop

in case you don't want to load into your main code.

0


source


I had the same problem and was looping in a loop while

.

Flashing another firmware for me.

0


source







All Articles