Post your best Lua script examples here

User avatar
By glcos
#59246
torntrousers wrote:would be happy to be shown how to do that.

As I explained in my post above, I managed to do that with the following approach:

Going to sleep
Code: Select allwifi.setmode(wifi.NULLMODE)
node.dsleep(1000000)


After wake-up
Code: Select all--- your code here that doesn't need wifi
wifi.setmode(wifi.STATION)
wifi.sta.connect()
--- Wifi is connected


According to the PR linked above there will soon be a new function available to do this in more elegant and supported way.
User avatar
By schufti
#59276 did you check if it also skips the rf_calibration at startup?
Else one would like to do a
node.dsleep(sleeptime, 2);
normally and
node.dsleep(sleeptime, 1);
after unsuccessful connection attempt to be even more energy efficient
User avatar
By glcos
#59345
schufti wrote:did you check if it also skips the rf_calibration at startup?

I did not try that, but I believe that going to deep-sleep with
node.dsleep(sleeptime, 2)
wouldn't make any difference.
I will try it...