Chat freely about anything...

User avatar
By AlexZ
#28801 Hi, I'm running nodeMCU (net, GPIO, tmr, wifi, node, file modules built custom from the master distribution) on an ESP-01 that is powered and uart connected via a CP2102 module to my computer. No pull up/down resistors or power supply capacitors. Super basic connections.

I have a script that is designed to connect the ESP01 to any unencrypted wifi it finds.

The first time I run the script (init.lua) it works flawlessly. Every time after the first time the script is run it causes the module to crash in ~5sec with no error generated. The only way for me to get the script to run again is to reflash the AT sdk then noeMCU.

What could be causing this? It's rather frustrating that the script executes no problem the first time, but fails every time after that. It seem like my software is OK. Could it be a hardware limitation that I am not accounting for in my script? Power supply problem? What would cause the module to reboot with no error thrown?
User avatar
By AlexZ
#28863 I figured out a way around this is btw.

There are numerous wifi ap's in my vicinity that require authentication, but are unencrypted. My script attempted to connect to these automatically, but it of course would get stuck with wifi.sta.status() == 1 until I reconfigured and connected to a different access point. It seems that restarting the module while it is trying to connect to an access point was causing the reboot cycle. To get around this I wrote a bit of code that would attempt to connect to an SSID that I came up with but cannot actually exist (the SSID has extended ASCII characters in it). The module then tries to connect to this nonexistent AP for 10 seconds after which wifi.sta.status() becomes 3 rather than 1. I can then call wifi.sta.disconnect() returning the module to wifi.sta.status() == 0. This entirely eradicated my problem and the script runs fine.

Also, while wifi.sta.status() == 1 calling wifi.sta.disconnect() does nothing to the status. This seems like a bug to me (I would think that wifi.sta.disconnect() would return the wifi module to idle no matter what).

I wish I had a better understanding of exactly why this works.

Also, on a side note. How would one connect to a AP requiring authentication?