As the title says... Chat on...

User avatar
By shaolin30
#27809 Hi guys! So I have setup my esp module's init.lua by this code below...

Code: Select all--
-- SET UART CONFIGURATION
uart.setup(0, 115200, 8, 0, 1, 1)

-- SET WIFI CONFIGURATION
wifi.setmode(wifi.SOFTAP)

local cfg

cfg = {
   ip = "10.10.10.10",
   netmask = "255.255.255.0",
   gateway = "10.10.10.10"
}
wifi.ap.setip(cfg)

cfg = {
   ssid = "ESP",
   pwd = "12345678"
}
wifi.ap.config(cfg)

print("\r\n********************")
print("ESP IP:\r\n", wifi.ap.getip())
print("Heap:\r\n", node.heap())
print("********************")

cfg = nil

-- COMPILE LUA FILES

-- START SERVER
collectgarbage()


What I want is to start a server,
Code: Select alllocal srv = net.createServer(net.TCP)

   srv:listen(80, function(conn)
that I can connect to and send data or string. However I don't know where to start writing/programming the server.lua side? I want to connect my android phone to my esp module and send some string then print it out on the screen using ESPLorer IDE. I would highly appreciate any kind of help and if you can provide an example codes, please share it to me. Thanks guys...
User avatar
By be80be
#27842 This should maybe get you going.
Code: Select alluart.setup(0,9600,8,0,1,0)
sv=net.createServer(net.TCP, 60)
global_c = nil
sv:listen(9999, function(c)
   if global_c~=nil then
      global_c:close()
   end
   global_c=c
   c:on("receive",function(sck,pl)   uart.write(0,pl) end)
end)

uart.on("data",4, function(data)
   if global_c~=nil then
      global_c:send(data)
   end
end, 0)
User avatar
By shaolin30
#27922 Thank you so much @be80be! My esp is now working fine and I can see the string received from my android phone and prints out to the ESPLorer screen. Now I would like to ask if I can connect my esp to my arduino uno and prints out the string on serial monitor received by my esp module. Is that possible? Could give me some idea or starting point on how to do it. Thanks again for your help, I've appreciated it so much! Thanks.