-- v12345vtm youtube https://youtu.be/MzH8zR34x0Y --http://www.instructables.com/editInstructable/publish/EDRHQW8IG415EAG -----uart mode uart.setup(0,9600,8,0,1) -- Your Wifi connection data local SSID = "yourSSID" local SSID_PASSWORD = "yourSSIDpassword" local rtctijd = "15:50" local var1 = "initvar1" local var2 = "initvar2" local var3 = "initvar3" local function connect (conn, data) webcode=" "; webcode = webcode .. "" webcode = webcode .. "" webcode = webcode .. "

" webcode = webcode .. "
" webcode = webcode .. "p1,ssid:
" webcode = webcode .. "p2,passw:
" webcode = webcode .. "p3,time:
" webcode = webcode .. "
" webcode = webcode .. "" webcode = webcode .. "" conn:on ("receive",function (cn, req_data) --print("wat is dat hier") print (req_data) -- print("staat er hier iet boven") if string.match(req_data, "p1") then positiep1 = string.find(req_data, "p1") positiep2 = string.find(req_data, "p2") positiep3 = string.find(req_data, "p3") positieEnd = string.find(req_data, "HTTP/") valuep1 = (string.sub(req_data, positiep1+3, positiep2-2)) valuep2 = (string.sub(req_data, positiep2+3 , positiep3-2)) valuep3 = (string.sub(req_data, positiep3+3 , positieEnd-2)) uart.write (0, valuep1 , "\r\n") uart.write (0, valuep2 , "\r\n") uart.write (0, valuep3 , "\r\n") -- = time-15-10-23-12-27-35-4 var1 = valuep1 var2 = valuep2 var3 = valuep3 --webfomtijd opslaan else -- print ("geen data in form ingevuld gewest of de browser vroeg zijn favicon.ico daarnet ook nog") end cn:send (webcode) -- Close the connection for the request cn:close ( ) end) end function wait_for_wifi_conn ( ) tmr.alarm (1, 1000, 1, function ( ) if wifi.sta.getip ( ) == nil then print ("Waiting for Wifi connection") else tmr.stop (1) print ("ESP8266 mode is: " .. wifi.getmode ( )) print ("The module MAC address is: " .. wifi.ap.getmac ( )) print ("Config done, IP is " .. wifi.sta.getip ( )) ---gpio.write(led1, gpio.HIGH) end end) end -- Configure the ESP as a station (client) wifi.setmode (wifi.STATION) wifi.sta.config (SSID, SSID_PASSWORD) wifi.sta.autoconnect (1) -- Hang out until we get a wifi connection before the httpd server is started. wait_for_wifi_conn ( ) -- Create the httpd server svr = net.createServer (net.TCP, 30) -- Server listening on port 80, call connect function if a request is received svr:listen (80, connect) print ("uart.setup(0,9600,8,0,1) finished") print ("waiting for serial data....")