Chapters

  • 01:40 Hardware Options
  • 10:18 Parts
  • 18:34 Wiring
  • 21:09 Servo
  • 23:05 Configure ESP8266
  • 27:41 Control Servo
  • 30:57 Server
  • 35:19 Bell in Action
  • 39:35 Magento Observer
  • 46:12 Queue
  • 50:46 Simple Daemon

Wiring

Wiring

Resources

ESP8266 Server

ding=function()
    -- down
    pwm.setup(4,100,80) ; pwm.start(4); tmr.delay(300000); pwm.stop(4);
    -- up
    pwm.setup(4,100,100) ; pwm.start(4); tmr.delay(300000); pwm.stop(4);
end

responseHeader = function(code, type) 
    return "HTTP/1.1 " .. code .. "\r\nConnection: close\r\nServer: nunu-Luaweb\r\nContent-Type: " .. type .. "\r\n\r\n";  
end 

httpserver = function() 
    if (srv) then 
        print("Closing existing server")
        srv.close(srv) 
        srv=null
    end

    print("Creating new server (listening to port 80)")
    srv=net.createServer(net.TCP)  
    srv:listen(80,function(conn)  
        conn:on("receive",function(conn,request)  
            ding();
            conn:send(responseHeader("200 OK","text/html")); 
            conn:send("Ding!"); 
        end) 
        conn:on("sent",function(conn)  
            conn:close();  
            conn = nil;     
      end) 
    end) 
end 

httpserver()

Parts used in this video

Links


comments powered by Disqus
Comment Permalink