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

User avatar
By kamal sonani
#44844 can anybody please suggest me ,that how to show status of esp's pin on web page.

i try to find on most of ESP's community but still i didn't find how to.........../

i agree that esp8266 is cheap and user friendly but truth is so far than reality......
whenever i search for solution or any kind of support, their are only result with simple code(in LUA)
like gpio,uart,pwm,....and many more///

is their any document available for ,how to use esp8266 with web interface(in LUA).
User avatar
By jim121049
#44880
Code: Select all-- a small http server to report the state of a switch connected to GPIO0

   GPIO0  = 3
-- GPIO1  = 10
-- GPIO2  = 4
-- GPIO3  = 9
-- GPIO4  = 1   
-- GPIO5  = 2   
-- GPIO9  = 11
-- GPIO10 = 12
-- GPIO12 = 6      
-- GPIO13 = 7   
-- GPIO14 = 5      
-- GPIO15 = 8
-- GPIO16 = 0   

srv=net.createServer(net.TCP)
srv:listen(80,function(conn)
   conn:on("receive",function(conn,payload)
   if gpio.read(GPIO0)==1
      then sw="off"
      else sw="on"
   end
   conn:send("<h1>The switch is " .. sw ..".</h1>")
   end)
   conn:on("sent",function(conn)
      conn:close()
   end)
end)