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

User avatar
By Marcel
#7427 I managed to create a simple webpage with the Lua examples on the web. I'm using the ESP8266-01 for this.

Is it possible to send an UART answer to a host microcontroller . So for example: the host microcontroller sends a request with some specific ID field every x ms to receive a variable who can be changed from the webpage. The esp8266 has to recognize this ID and has to respond immediately. Is this possible with LUA?
User avatar
By GeoNomad
#7481
Marcel wrote:I managed to create a simple webpage with the Lua examples on the web. I'm using the ESP8266-01 for this.

Is it possible to send an UART answer to a host microcontroller . So for example: the host microcontroller sends a request with some specific ID field every x ms to receive a variable who can be changed from the webpage. The esp8266 has to recognize this ID and has to respond immediately. Is this possible with LUA?


Yes, it should be possible to do this.

You need to connect to the webserver, retrieve the page and parse the results. Then send the information to the UART. There are examples of the code needed in various posts on here.
User avatar
By Marcel
#8114 Is it correct that the host microcontroller always has to end with a CR (carriage return) to let the "uart.on()" function work?? That would be a pity....
User avatar
By GeoNomad
#8116
Marcel wrote:Is it correct that the host microcontroller always has to end with a CR (carriage return) to let the "uart.on()" function work?? That would be a pity....


You can define it as a number of characters, every character, or upon receiving a predetermined character, which could be '\r', but doesn't have to be.

Seems pretty flexible to me.

https://github.com/nodemcu/nodemcu-firm ... art-module

uart.on(method, [number/end_char], [function], [run_input])

Parameters

method = "data", there is data input from uart.
number/end_char: if pass in a number n if n=0, will receive every char in buffer.
if pass in a one char string "c", the callback will called when "c" is encounterd, or max n=255 received.
function: callback function, event "data" has a callback like this: function(data) end
run_input: 0 or 1, 0: input from uart will not go into lua interpreter, can accept binary data.
1: input from uart will go into lua interpreter, and run.