-- allows to interrupt start up in the first 5 seconds by hitting -- borrowed from https://bigdanzblog.wordpress.com/2015/04/24/esp8266-nodemcu-interrupting-init-lua-during-boot/ function abortInit() -- initailize abort boolean flag abort = false print('Press ENTER within 5 seconds to abort startup') -- if is pressed, call abortTest uart.on('data', '\r', abortTest, 0) -- start timer to execute startup function in 5 seconds tmr.create():alarm(5000,tmr.ALARM_SINGLE,startup) end function abortTest(data) -- user requested abort abort = true -- turns off uart scanning uart.on('data') end function startup() uart.on('data') -- if user requested abort, exit if abort == true then print('startup aborted') return end -- otherwise, start up print('in startup') dofile('main.lua') end tmr.create():alarm(1000,tmr.ALARM_SINGLE,abortInit) -- call abortInit after 1s