Longer story: I flash NodeMCU on my ESP8266 with esptools. This works fine, and I can connect to the ESP8266 with screen, at 9600 baud.
For example, I'll upload a script with luatools, like this:
wifi.setmode(wifi.STATION)
wifi.sta.config("login","password")
gpio.mode(4, gpio.OUTPUT)
srv=net.createServer(net.TCP)
srv:listen(80,function(conn)
conn:on("receive", function(client,request)
local buf = "";
local _, _, method, path, vars = string.find(request, "([A-Z]+) (.+)?(.+) HTTP");
if(method == nil)then
_, _, method, path = string.find(request, "([A-Z]+) (.+) HTTP");
end
local _GET = {}
if (vars ~= nil)then
for k, v in string.gmatch(vars, "(%w+)=(%w+)&*") do
_GET[k] = v
end
end
buf = buf.."<h1> Hello!</h1><form src=\"/\">Turn LED on <select name=\"pin\" onchange=\"form.submit()\">";
local _on,_off = "",""
if(_GET.pin == "ON")then
_on = " selected=true";
gpio.write(4, gpio.HIGH);
elseif(_GET.pin == "OFF")then
_off = " selected=\"true\"";
gpio.write(4, gpio.LOW);
end
buf = buf.."<option".._on..">ON</opton><option".._off..">OFF</option></select></form>";
client:send(buf);
client:close();
collectgarbage();
end)
end)
and it works as expected. For a little bit. After playing around with it for 10 minutes, just turning the LED on or off, suddenly it goes dead. I tried pinging it: Not there. I tried resetting it: Still nothing. I reconnect the RX and TX and try to communicate with it via "screen" at 9600 baud rate, but all I get it garbage, as if the baud rate were wrong.
This has happened several times, and the only solution I've found is to flash the original firmware, ESP_8266_BIN0.92.bin, with esptools, and then after that, flashing the latest NodeMCU firmware. This only works for a little bit, however.
Does anyone know what's happening? It's very strange, because I really can't tell what is happening when it "breaks," nor can I tell what, if anything, triggers it.
Thanks, and apologies if this isn't the correct subforum for this!