id = '4567' -自己设置自己的id替换4567
ssid = 'wifi名'
ssidpwd = 'wifi密码'
wifi.setmode(wifi.STATION)
wifi.sta.config(ssid,ssidpwd) --set your ap info !!!!!!
wifi.sta.autoconnect(1)
led1 = 3
led2 = 4
gpio.mode(led1, gpio.OUTPUT)
gpio.mode(led2, gpio.OUTPUT)
function startServer()
conn=net.createConnection(net.TCP, 0)
conn:on("connection", function(conn, c)
conn:send(id)
tmr.alarm(2, 30000, 1, function()
conn:send('<h1></h1>')
end)
end)
conn:on("receive", function(conn, pl)
local _, _, method, path, vars = string.find(pl, "([A-Z]+) (.+)?(.+) HTTP");
local buf = "";
local _GET = {}
if (vars ~= nil)then
for k, v in string.gmat
【公网远程】网页控制nodemcu的LED
最新推荐文章于 2024-06-23 08:00:00 发布
通过修改McuNode程序,设置自己的id和连接的公网路由器信息,可以实现远程控制nodemcu的LED。访问特定格式的网址(如http://eiot.club/proxy/4567/index.html)即可操作,目前仅支持Get方法。服务器源码在https://github.com/IoTServ/McuNode-server,需自行部署。测试阶段,能从公网任意位置访问并控制nodemcu。
摘要由CSDN通过智能技术生成