As the title says... Chat on...

User avatar
By ccxx
#6257 Need help !!!
I made a very simple circuit, as you can see, based on http://importhack.wordpress.com/2014/11/22/how-to-use-ep8266-esp-01-as-a-sensor-web-client/
Image
With this code as input.lua
Code: Select allsu=net.createConnection(net.UDP)
su:on("receive",function(su,c) print(c) end)
su:connect(8889,"192.168.1.255")
pincitofono=3
pinporta=4
gpio.mode(pincitofono, gpio.INPUT)
print(gpio.read(pincitofono))
gpio.mode(pinporta, gpio.INPUT)
print(gpio.read(pinporta))
tmr.alarm(0, 100, 1, function()
if gpio.read(pincitofono)==0 then
su:send("CITOFONO")
print("CITOFONO")
end
if gpio.read(pinporta)==0 then
su:send("PORTA")
print("PORTA")
end)


Init.lua very simple "tmr.alarm(1,4000, 0, function() dofile("input.lua") end )"

Can someone explain to me why sometime it works well at power up and sometimes not ? I'm doing something wrong ?