Current Lua downloadable firmware will be posted here

User avatar
By scargill
#2923 Your new code from this afternoon. I had to blow it a couple of times as it would not seem to work... then I uploaded my file to it and it reset..... and worked... everything was well,. I turned the power off then on 5 times - worked perfectly.

Then I sent my file to it again - which should have erased the two functions and replaced them - the only difference being a longer delay (2 seconds) before reading the IP address as it was getting 0.0.0.0... back to repeats and rebooting.

Perhaps when you remove files there's a problem??

Now it is just resetting over and over.

Here's is what is in now minus my password

file.remove("init.lua")
file.open("init.lua","w")
file.writeline([[print("Petes Tester 4")]])
file.writeline([[tmr.alarm(15000, 0, function() dofile("thelot.lua") end )]])
file.close()
file.remove("thelot.lua")
file.open("thelot.lua","w")
file.writeline([[print("Stopping timer")]])
file.writeline([[tmr.stop()]])
file.writeline([[tmr.delay(500000)]])
file.writeline([[print("creating function")]])
file.writeline([[connecttoap = function (ssid,pw)]])
file.writeline([[print(wifi.sta.getip())]])
file.writeline([[wifi.setmode(wifi.STATION)]])
file.writeline([[tmr.delay(500000)]])
file.writeline([[wifi.sta.config(ssid,pw)]])
file.writeline([[tmr.delay(2000000)]])
file.writeline([[print("Connected to ",ssid," as ",wifi.sta.getip())]])
file.writeline([[end]])
file.writeline([[print("Running function")]])
file.writeline([[connecttoap("loft-east","xxxxxxx")]])
file.writeline([[print("Done")]])
file.close()
User avatar
By Erni
#2924 I tried your code on my board and it works without error.
I uploade two times and still works.

The only difference is that in this line

Code: Select allfile.writeline([[tmr.alarm(15000, 0, function() dofile("thelot.lua") end )]])


There should be a space after dofile.
User avatar
By scargill
#2927 Ernie - I don't agree. That is a function call - I don't think there should be a space where you suggest. If it IS necessary surely that's a bug?

All -

I've done some more tests.

In each case I am blowing the BLANK file and then the nodemcu_512k.bin file just to be sure.

In each case after doing this.. If I send the file below to the unit.. it works... BUT the delay is too short to show the IP address.

When I say WORKS I mean one initial message and one run of the code.

There are TWO things wrong.

Firstly If I then RELOAD the file - subsequent powerup goes wrong - there is something wrong with your file.remove() command
Secondly if I try to change the time delay HERE...

file.writeline([[wifi.sta.config(ssid,pw)]])
file.writeline([[tmr.delay(500000)]])

from half a seconds to 2 seconds....

EITHER by making it longer OR using it 4 times..

i.e.

file.writeline([[wifi.sta.config(ssid,pw)]])
file.writeline([[tmr.delay(2000000)]])

or

file.writeline([[wifi.sta.config(ssid,pw)]])
file.writeline([[tmr.delay(500000)]])
file.writeline([[tmr.delay(500000)]])
file.writeline([[tmr.delay(500000)]])
file.writeline([[tmr.delay(500000)]])

Either way this FAILS and the unit ends up in a loop - Am I right in guessing this is some kind of WATCHDOG issue?

Is it possible to fix these two issues - we are SO CLOSE!!




file.remove("init.lua")
file.open("init.lua","w")
file.writeline([[print("Petes Tester 4")]])
file.writeline([[tmr.alarm(15000, 0, function() dofile("thelot.lua") end )]])
file.close()
file.remove("thelot.lua")
file.open("thelot.lua","w")
file.writeline([[print("Stopping timer")]])
file.writeline([[tmr.stop()]])
file.writeline([[tmr.delay(500000)]])
file.writeline([[print("creating function")]])
file.writeline([[connecttoap = function (ssid,pw)]])
file.writeline([[print(wifi.sta.getip())]])
file.writeline([[wifi.setmode(wifi.STATION)]])
file.writeline([[tmr.delay(500000)]])
file.writeline([[wifi.sta.config(ssid,pw)]])
file.writeline([[tmr.delay(500000)]])
file.writeline([[print("Connected to ",ssid," as ",wifi.sta.getip())]])
file.writeline([[end]])
file.writeline([[print("Running function")]])
file.writeline([[connecttoap("loft-east","1921681974")]])
file.writeline([[print("Done")]])
file.close()