ItKindaWorks Forum

A forum for everything that Kinda Works YouTube.com/ItKindaWorks

You are not logged in.

Announcement

Welcome to the ItKindaWorks Forum

#1 2018-01-23 00:11:52

agengler11
Member
Registered: 2018-01-23
Posts: 21

LC Technology Serial Relays

So I've been working on these relays that have an ESP8266-01 onboard and can only find a lua code to control them. Most of the information that I've found is in Chinglish so I haven't been able to program a good INO code.  It works great with the LUA code but I want to see if we can utilize MQTT with ItKindaWorks awesome OTA code and bells and whistles.



-- must switch to 9600 baud to control relay
uart.setup(0,9600,8,0,1)

-- join wifi
wifi.setmode(wifi.STATION)
wifi.sta.config("SSID","wifipassword")
-- print(wifi.sta.getip())

-- Lua web server
srv=net.createServer(net.TCP)
srv:listen(80,function(conn)
    conn:on("receive", function(client,request)
        local buf = "";
        local _, _, method, path, vars = string.find(request, "([A-Z]+) (.+)?(.+) HTTP");
        if(method == nil)then
            _, _, method, path = string.find(request, "([A-Z]+) (.+) HTTP");
        end
        local _GET = {}
        if (vars ~= nil)then
            for k, v in string.gmatch(vars, "(%w+)=(%w+)&*") do
                _GET[k] = v
            end
        end
        buf = buf.."<h1>ESP8266 relay control</h1>";
        buf = buf.."<p>Switch Relay 1<a href=\"?pin=ON1\"><button>ON</button></a>&nbsp;<a href=\"?pin=OFF1\"><button>OFF</button></a></p>";
        local _on,_off = "",""
        if(_GET.pin == "ON1")then
              tmr.stop(0);
              uart.write( 0, 0xA0,0x01,0x01,0xA2);
        end      
        if(_GET.pin == "OFF1")then
              tmr.stop(0);
              uart.write( 0, 0xA0,0x01,0x00,0xA1);
        end      
        client:send(buf);
        client:close();
        collectgarbage();
    end)
end)

2018-01-22_17.01.33.jpg

Offline

#2 2018-01-23 02:26:44

cromer
Administrator
From: internet land
Registered: 2017-12-26
Posts: 89
Website

Re: LC Technology Serial Relays

Those look like interesting little boards! Kind of weird that they use serial to talk to a dedicated driver chip though. It looks like you're not the only one around having some issues getting it to properly trigger the relay through arduino. I'd have to actually get one of these boards to test out though.

Definitely something to look into!


Creator of ItKindaWorks

Offline

#3 2018-01-23 02:52:36

agengler11
Member
Registered: 2018-01-23
Posts: 21

Re: LC Technology Serial Relays

I'd be happy to send you one.

Offline

#4 2018-01-23 17:57:49

cromer
Administrator
From: internet land
Registered: 2017-12-26
Posts: 89
Website

Re: LC Technology Serial Relays

If you have one to spare I'm certainly not going to say no wink

PM me and we can work out the details


Creator of ItKindaWorks

Offline

Board footer

Powered by FluxBB