Chat freely about anything...

User avatar
By wrbrower
#46531 Hello all,
I am running Lua based ESP-12s.
I want an ESP-12 to be able to send a web request like you would from a web browser.
From a web browser if I type http://192.168.1.110/?pin=OFF1 in the URL line it turns off an output on an ESP-12.

Does anyone have a code snippet that would send http://192.168.1.110/?pin=OFF1 from an ESP-12 ?

In other words I want one ESP-12 to be able to turn off an output on another ESP-12 using that URL format.

Thank you in advance,
Bill
User avatar
By wrbrower
#47160 This was the solution:

conn = nil
conn=net.createConnection(net.TCP, 0)
conn:on("receive", function(conn, payload)
success = true
print(payload)
end)
conn:on("connection", function(conn, payload)
print('\nConnected')
conn:send("GET /?pin=OFF1"
.." HTTP/1.1\r\n"
.."Host: 192.168.1.110\r\n"
.."Connection: close\r\n"
.."Accept: */*\r\n"
.."Test String\r\n"
.."\r\n")
end)
conn:on("disconnection", function(conn, payload) print('\nDisconnected') end)
conn:connect(80,'192.168.1.110')