id = 0 pin = 7 gpio.mode(7, gpio.OUTPUT) print("webapp running @ ip\n") function sendData() -- connection to thingspeak.com conn=net.createConnection(net.TCP, 0) conn:on("receive", function(conn, payload) print(payload) end) -- api.thingspeak.com 184.106.153.149 conn:connect(80,'184.106.153.149') -- 0V <= Vadc value <= 3.03V ADC_value = (adc.read(0)*3030)/1024; print("Sending data to thingspeak.com, ADC value:"..ADC_value.."mV") conn:send("GET /update?key=99UMWAO1LLNVI7TR&field1="..ADC_value.." HTTP/1.1\r\n") conn:send("Host: api.thingspeak.com\r\n") conn:send("Accept: */*\r\n") conn:send("User-Agent: Mozilla/4.0 (compatible; esp8266 Lua; Windows NT 5.1)\r\n") conn:send("\r\n") conn:on("sent",function(conn) print("Closing connection") conn:close() end) conn:on("disconnection", function(conn) print("Got disconnection...\n") end) end -- send data every 60 000 ms to thing speak tmr.alarm(0, 60000, 1, function() sendData() end )