나는 HTTP 내가 버튼을 누를 때마다 GET 보내려고에서 :HTTP GET LUA/NodeMCU
wifi.setmode(wifi.STATION)
wifi.sta.config("SSID","PWD")
function loop()
if wifi.sta.status() == 5 then
-- Stop the loop
tmr.stop(0)
else
print("Connecting...")
end
end
tmr.alarm(0, 100, 1, function() loop() end)
print(wifi.sta.getip())
outpin_led = 1
inpin_button = 3
gpio.mode(outpin_led,gpio.OUTPUT)
gpio.mode(inpin_button,gpio.INPUT)
light_on = false
function light()
if not light_on then
-- turn the light on
gpio.write(outpin_led,gpio.HIGH)
light_on = true
http.get("https://google.com", function(clt, data)
print(data)
end)
else
-- turn the light off
gpio.write(outpin_led,gpio.LOW)
light_on = false
end
end
gpio.trig(inpin_button,"down",light)
http.get
를 포함하는 라인이 오류 메시지를 던지고있다
:
> PANIC: unprotected error in call to Lua API (stdin:6: attempt to index global 'http' (a nil value))
내 NodeMCU 빌드에 http
모듈이 포함되어 있는지 확인했습니다. http://nodemcu-build.com/
?
감사합니다.
사실은 펌웨어에 HTTP 모듈이 누락되었다는 것입니다. 그러나, 나는 당신이 오늘 방아쇠를 당기는 3 개의 건축 전부에는 그것을 포함해야한다 (나의 기록에 따르면). 정말로 그들 중 하나를 깜박 했나요? 장치가 부팅 될 때 "NodeMCU custom build by frightanic.com"과 UART에 대한 여러 구성 매개 변수를 인쇄해야합니다. 예는 http://stackoverflow.com/q/37559525/131929에서 확인할 수 있습니다. –