Stap 6: BMS Web Server Interface
srv=net.createServer(net.TCP) srv:listen(80, function(conn) conn:on("receive",function(conn,payload) --print(payload) conn:send("HTTP/1.1 200 OK\n\n") conn:send("<META HTTP-EQUIV=\"REFRESH\" CONTENT=\"5\">") conn:send("<html><title>Battery Live Monitor System - ESP8266</title><body>") conn:send("<h1>Battery Live Monitor System - ESP8266</h1><BR>") conn:send("Voltage :<B><font color=red size=4>" ..string.format("%g",adcV).." V</font></b><br>") conn:send("Current :<B><font color=blue size=4>" ..string.format("%g",adcI).." mA</font></b><br>") conn:send("Power :<B><font color=red size=4>" ..string.format("%g",pwr).." mW</font></b><br>") conn:send("Energy :<B><font color=green size=4>" ..string.format("%g",cpct).." Wh</font></b><br>") conn:send("<BR><BR><BR>Node.HEAP : <b>" .. node.heap() .. "</b><BR>") conn:send("IP ADDR :<b>".. wifi.sta.getip() .. "</b><BR>") conn:send("TMR.NOW :<b>" .. tmr.now() .. "</b><BR<BR><BR>") conn:send("</html></body>") conn:on("sent",function(conn) conn:close() end) conn = nil end) end)