Current Lua downloadable firmware will be posted here

User avatar
By sambirb
#65480 Hi,

I have ESP-12E board which is being used with nodemcu firmware 1.5.4, I tried connecting to my router but it is not able to connect properly. I am using following code:

Code: Select allprint("Connecting to WiFi access point...")
wifi.setmode(wifi.STATION)
wifi.sta.config(wifi_ssid, wifi_password)
-- wifi.sta.connect() not necessary because config() uses auto-connect=true by default
tmr.create():alarm(1000, tmr.ALARM_AUTO, function(cb_timer)
    if wifi.sta.getip() == nil then
        print("Waiting for IP address...")
    else
        cb_timer:unregister()
        print("WiFi connection established, IP address: " .. wifi.sta.getip())
        print("You have 3 seconds to abort")
        print("Waiting...")
        tmr.create():alarm(3000, tmr.ALARM_SINGLE, startup)
    end
end)


I tried connecting to multiple routers but all of them are having issues.

I tried using Arduino IDE using NodeMCU 1.0 (ESP-12E Module) with following code and it connected fine:

Code: Select all  WiFi.begin(ssid, password);
 
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  Serial.println("");
  Serial.println("WiFi connected");


I am trying to test out this project which is written in lua: https://github.com/heythisisnate/nodemcu-smartthings

Tried porting it to Arduino but its limited feature in finding out the exact GPIO pin that caused the interrupt is a limitation.

Can you guys help how to get WiFi working fine with lua.

Thanks,
Sambi
User avatar
By marcelstoer
#65484
sambirb wrote:it is not able to connect properly


It's usually helpful to show what exactly the output is. However, in this case it seems a piece of our documentation is outdated (I filed https://github.com/nodemcu/nodemcu-firmware/issues/1951 for that).

The var args notation for `wifi.sta.config` is outdated, use a Lua table as per https://nodemcu.readthedocs.io/en/lates ... istaconfig
User avatar
By sambirb
#65488 I did try to use the table parameter but the result is same.

After setting mode, I turned off autoconnect from config and explicitly called connect there was no output.

I am not seeing any output other than the "Waiting for IP address..." as getip() is returning null.