Post your best Lua script examples here

User avatar
By TerryE
#16689 The simplest way is to have a companion process on the server which listens to a port which the ESP8266 can connect to and send data. If your "server" is an RPi then this would probably be a simple Python script. Your ESP8266 lua application would read the file into a local variable then connect to the server and send the file to it.

Just note that the ESP8266 can only send in a maximum chunk length (1426 off the top of my head), so I tend to chunk up any uploads into 1024 byte chunks, and in this case you'd want to read 1024 bytes at a time and send this to the host. There are examples of how to do this here, but once you've got yours sort of working, then post back here and we can help you with any problems.

If the "file" is quite short then one option is to convert this into a URI with a parameter and them use a simple HTTP client (again there are samples here and in the firmware distro), but note that you will need to escape some characters to make the URI -- again examples here and on the Internet.
User avatar
By dkumar
#47875 hello archivi
i tested your code working well, and i able to send data from client to server using atmega8 formate, but not send any data from server to client, how i can send data from server to client, and how to send data from server to multiple or single client, because i don't know "lua" language well, please help me??
thanks