Post your best Lua script examples here

User avatar
By fixingthingsguy
#12770 Thanks for your patience.
I think my problem was one of timing;
If I first let the dofile do its thing as below AND then initiate the Ard sketch, things work just fine.
dofile("serial.lua")
uart.setup(0,9600,8,0,1) finished
waiting for serial data....
> cmd_2(78)
cmd_2(78) received

Anyway, the serial messaging set up by Stefan is working for me just as it was for him in my setup. I'll have to play with the timing to make sure that's taken care of in my case at least, ie I don't send stuff in before the ESP8266 is fine and ready. I think this was pointed out in Musti's post.
Anyway, happy tinkering, I'll be back when I extend this serial messaging communication module to serve my needs for sending measurements to my webserver at Grovestreams.com
User avatar
By Gus Smith
#23298 Hello,

I got this working from Arduino to ESP8266.

On Arduino I use SoftwareSerial.
On ESP8266 I have this test function:

Code: Select alluart.setup(0, 9600, 8, 0, 1, 0 )
 
function hello(data)
    print("ok " .. data)
end


From Arduino I send this:

Code: Select allespSerial.println("hello('test')");


In the console I see this everytime:

Code: Select allok test>


Where does this ">" character come from and how can I suppress from being sent from Lua to Arduino?
User avatar
By javo
#54440
Gus Smith wrote:Hello,

I got this working from Arduino to ESP8266.

On Arduino I use SoftwareSerial.
On ESP8266 I have this test function:

Code: Select alluart.setup(0, 9600, 8, 0, 1, 0 )
 
function hello(data)
    print("ok " .. data)
end


From Arduino I send this:

Code: Select allespSerial.println("hello('test')");


In the console I see this everytime:

Code: Select allok test>


Where does this ">" character come from and how can I suppress from being sent from Lua to Arduino?


The
Code: Select all>
is no more than the Lua prompt symbol that is printed immediately next to your string as it lacks of
Code: Select all\n
character. So actually it is not being sent to Arduino.

Note that in your case, ESP is just printing out the string and not executing as you expect.