我遵循有关如何制作通过Feather-huzzah和连接到ARduino-uno和伺服器的3.3V ftdi编程器在wifi上工作的门锁的指南。经过数小时的尝试,尝试正确连接所有设备,然后发现以下问题,我偶然发现以下问题,每当我保存到我的esp(或发送)时,都会出现随机错误,例如“无法写新行”或“期望。和更多。请在代码下面举一些例子。我对ESPlorer不熟悉,因此我很难注意到这些错误。我觉得门锁的指南不是,这就是为什么它不起作用。
以下指南:https://www.instructables.com/id/Wifi-Smart-Doorsimplest-Method/
esplorer中的代码
-- Rui Santos
-- Complete project details at https://randomnerdtutorials.com
wifi.setmode(wifi.STATION)
wifi.sta.config("K&M forever","ts0c4jjfygo")
print(wifi.sta.getip())
led1 = 3
led2 = 4
gpio.mode(led1, gpio.OUTPUT)
gpio.mode(led2, gpio.OUTPUT)
srv=net.createServer(net.TCP)
srv:listen(80,function(conn)
conn:on("receive", function(client,request)
local buf = "";
buf = buf.."HTTP/1.1 200 OK\n\n"
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
if(_GET.pin == "ON1")then
gpio.write(led1, gpio.HIGH);
elseif(_GET.pin == "OFF1")then
gpio.write(led1, gpio.LOW);
elseif(_GET.pin == "ON2")then
gpio.write(led2, gpio.HIGH);
elseif(_GET.pin == "OFF2")then
gpio.write(led2, gpio.LOW);
end
client:send(buf);
client:close();
collectgarbage();
end)
end)
错误越来越严重(一次总是只有一个错误):
stdin:2: attempt to call global 'w' (a romtable value)
stdin:1: attempt to call field 'writelinew' (a nil value)
stdin:1: unexpected symbol near '=='
stdin:1: unexpected symbol near '['