Current Lua downloadable firmware will be posted here

User avatar
By wifsimster
#62452 Hi everyone,

I just write a piece of code to command a relay throught an esp-01.

I used this http://www.esp8266.com/viewtopic.php?f=160&t=13164&start=8 to find how to command my relay.

My code with MQTT communication :

Code: Select allm:on("message", function(m, topic, data)
    if data then
        print(data)
        if data == "ON" then
            uart.setup(0, 9600, 8, 0, 1)
            uart.write(0, 0xA0, 0x01, 0x01, 0xA2)         
        elseif data == "OFF" then
            uart.setup(0, 9600, 8, 0, 1)
            uart.write(0, 0xA0, 0x01, 0x00, 0xA1)
    end
end)


My problem is the uart.write() works fine (relay change state) but then the esp is freez. I can't get any response.

I'm probably doing something wrong with the uart lib here... ?