Serial MCU controlled relay/switch

Moderators: grovkillen, Stuntteam, TD-er

Message
Author
User avatar
enesbcs
Normal user
Posts: 587
Joined: 18 Jun 2017, 11:02
Location: Békéscsaba, Hungary
Contact:

Re: Serial MCU controlled relay/switch

#121 Post by enesbcs » 01 May 2018, 08:38

xury wrote: 30 Apr 2018, 23:51 If someone would like test it. Compiled using recent sources (core 2.4.1)
I compiled it with PUYA patched Esp.cpp
It should by work with differ than PUYA flash IC too.
To fit in 1MB II got rid of some plugins that I think it can not be used with serial controlled boards.
Nice work! Did you used the latest Mega sources to compile?
Finally I am also able to apply puya patch and compiled some binaries (with P165) for testing, attached on the first post of this thread.

xury
Normal user
Posts: 44
Joined: 02 Apr 2018, 12:54

Re: Serial MCU controlled relay/switch

#122 Post by xury » 01 May 2018, 10:41

Yes, I used sources from yesterday and patched Esp.cpp and obviously your nice plugin.
Working well witch domoticz ESP-01s and LC TECH single relay.
Added a button and some rules to get full feedback about relay state.

Code: Select all

on sonoff#Relay0 do
Publish domoticz/in,{"idx":92,"nvalue":[sonoff#Relay0],"svalue":""}
endon

on Przycisk#switch do

if [sonoff#Relay0]=1
relay,0,0
else
relay,0,1
endif
endon
Przycisk is a name of switch input connected between GPIO-2 and GND Switch type" Push button active low" with internal pullup.
Whatever I use to change relay state (button, external command etc.) Its show always real state in domoticz.

alabama
Normal user
Posts: 90
Joined: 24 Nov 2017, 10:04

Re: Serial MCU controlled relay/switch

#123 Post by alabama » 01 May 2018, 11:31

I'm successfull with 3 of 4 Module with ESPEasy_R147_1M_64kS. The forths also first works fine until I tried to change the IP-settings. After that I can reach it. Even after several successful flashes with different FWs it is not visible in the WLAN. I'm not so really a profi in this topic, but I'm wondering that the simple change of the IP-settings can have this effect.
Next I'll try the version of @xury.

EDIT:
Wonderfull, the problematic ESP8266-01 is running now, with the changed IP configuration and with the FW of @xury. Now I have to connet it with the relay.

Thanks a lot both of you!

qingz
New user
Posts: 5
Joined: 04 May 2018, 01:05

Re: Serial MCU controlled relay/switch

#124 Post by qingz » 04 May 2018, 01:18

I bought 4 relays from AliExpress from this user.
https://www.aliexpress.com/item/ESP8266 ... 88295.html

None of them works.
I tried send the serial command A00101A2 and A00100A1 in hex to the device directly from my computer using the utility downloaded from LCTech. No response from the relay.
I probed the signals on the serial port with a oscilloscope, they looks perfect.

Is it possible the relays are faked? The MCU on the relay does not work? Or it takes a different command?

I'm totally lost.

User avatar
enesbcs
Normal user
Posts: 587
Joined: 18 Jun 2017, 11:02
Location: Békéscsaba, Hungary
Contact:

Re: Serial MCU controlled relay/switch

#125 Post by enesbcs » 04 May 2018, 06:59

qingz wrote: 04 May 2018, 01:18 I bought 4 relays from AliExpress from this user.

Is it possible the relays are faked? The MCU on the relay does not work? Or it takes a different command?
There are several devices on the wild which is not programmed, you need a programmer, the STC15F104W microprograms can be found at:
https://www.esp8266.com/viewtopic.php?f ... =68#p74262

qingz
New user
Posts: 5
Joined: 04 May 2018, 01:05

Re: Serial MCU controlled relay/switch

#126 Post by qingz » 04 May 2018, 08:11

enesbcs wrote: 04 May 2018, 06:59
qingz wrote: 04 May 2018, 01:18 I bought 4 relays from AliExpress from this user.

Is it possible the relays are faked? The MCU on the relay does not work? Or it takes a different command?
There are several devices on the wild which is not programmed, you need a programmer, the STC15F104W microprograms can be found at:
https://www.esp8266.com/viewtopic.php?f ... =68#p74262
That's should be exactly what happened to my relays. I contacted LCTech, and they said those relays were not made by them.
I will try to program them.

Thank you!

qingz
New user
Posts: 5
Joined: 04 May 2018, 01:05

Re: Serial MCU controlled relay/switch

#127 Post by qingz » 04 May 2018, 15:33

Is there a way to read our the binary code from MCU of the official LCTech product and use it to program my relays?

qingz
New user
Posts: 5
Joined: 04 May 2018, 01:05

Re: Serial MCU controlled relay/switch

#128 Post by qingz » 05 May 2018, 03:56

qingz wrote: 04 May 2018, 08:11
enesbcs wrote: 04 May 2018, 06:59
qingz wrote: 04 May 2018, 01:18 I bought 4 relays from AliExpress from this user.

Is it possible the relays are faked? The MCU on the relay does not work? Or it takes a different command?
There are several devices on the wild which is not programmed, you need a programmer, the STC15F104W microprograms can be found at:
https://www.esp8266.com/viewtopic.php?f ... =68#p74262
That's should be exactly what happened to my relays. I contacted LCTech, and they said those relays were not made by them.
I will try to program them.

Thank you!
Programmed the MCU of relay with the hex code from the post. And the relay works now. Well, sort of.
The LED works, it turns on and off with the on/off command, but the relay does not switch.

The problem is that the R3 is too big. It is 10K instead of 4.7K from LCTech. Once I changed it to 4.7K, it worked.
Screenshot_1.jpg
Screenshot_1.jpg (16.83 KiB) Viewed 113989 times
Last edited by qingz on 07 May 2018, 18:50, edited 1 time in total.

User avatar
enesbcs
Normal user
Posts: 587
Joined: 18 Jun 2017, 11:02
Location: Békéscsaba, Hungary
Contact:

Re: Serial MCU controlled relay/switch

#129 Post by enesbcs » 05 May 2018, 16:35

qingz wrote: 05 May 2018, 03:56 Programmed the MCU of relay with the hex code from the post. And the relay works now. Well, sort of.
The LED works, it turns on and off with the on/off command, but the relay does not switch.

The problem is that the R3 is too big. It is 10K instead of 4.7K from LCTech. Once I changed it to 4.7K, it worked.
Nice work! I know that counterfeit's sometimes missing software, but never tought that they are incompatible at hardware level. If i were you, i would ask for refund.

qingz
New user
Posts: 5
Joined: 04 May 2018, 01:05

Re: Serial MCU controlled relay/switch

#130 Post by qingz » 06 May 2018, 05:06

enesbcs wrote: 05 May 2018, 16:35
qingz wrote: 05 May 2018, 03:56 Programmed the MCU of relay with the hex code from the post. And the relay works now. Well, sort of.
The LED works, it turns on and off with the on/off command, but the relay does not switch.

The problem is that the R3 is too big. It is 10K instead of 4.7K from LCTech. Once I changed it to 4.7K, it worked.
Nice work! I know that counterfeit's sometimes missing software, but never tought that they are incompatible at hardware level. If i were you, i would ask for refund.
Less than $5 for 4. Not worth the hassle to ask for refund.

nygma
Normal user
Posts: 25
Joined: 26 Nov 2016, 11:16

Re: Serial MCU controlled relay/switch

#131 Post by nygma » 07 May 2018, 23:27

xury wrote: 30 Apr 2018, 23:51 If someone would like test it. Compiled using recent sources (core 2.4.1)
I compiled it with PUYA patched Esp.cpp
It should by work with differ than PUYA flash IC too.
To fit in 1MB II got rid of some plugins that I think it can not be used with serial controlled boards.
Hi Xury,

I have an LCTech Relay X2 (2 relay module). The stock firmware on the MCU and ESP worked, I was able to control the relays with HEX codes over TCP. I flashed your ESPEasy_1M_128kSPIFFS_PUYA.bin to the ESP-01 (not a PUYA chip). ESP Easy works. I configured it in the following way:
Device: Serial MCU controlled switch
Name: Relay
Enabled: X
Switch type: LC TECH
Number of Relays: 2
Serial speed: 9600
Use command doubling: NO
Send to Controller: X
Interval: 0
Names: Relay0, Relay1, Relay2

I also configured a OpenHAB MQTT controller. I am trying to send 0 and 1 to /LCTech/Relay/Relay0 but nothing happens. The device and MQTT definitely works as I am getting the RSSI and update messages from the System Info devices that I have also created. When I am sending the MQTT messages to the above relay topics, nothing is appearing in the Log.

How can I check this further? Can I switch the relays from the Webserver?

Thanks,
Csongor

User avatar
enesbcs
Normal user
Posts: 587
Joined: 18 Jun 2017, 11:02
Location: Békéscsaba, Hungary
Contact:

Re: Serial MCU controlled relay/switch

#132 Post by enesbcs » 08 May 2018, 07:05

nygma wrote: 07 May 2018, 23:27
I have an LCTech Relay X2 (2 relay module). The stock firmware on the MCU and ESP worked, I was able to control the relays with HEX codes over TCP. I flashed your
...
I also configured a OpenHAB MQTT controller. I am trying to send 0 and 1 to /LCTech/Relay/Relay0 but nothing happens. The device and MQTT definitely works as I am
...
How can I check this further? Can I switch the relays from the Webserver?
You have to implement MQTT support if you wish to use it.

Currently the plugin can be used with the following commands:

The ON command for Relay0:
relay,0,1
The OFF command for Relay0:
relay,0,0
The ON command for Relay1:
relay,1,1
The OFF command for Relay1:
relay,1,0

Commands can be executed on the web interface directly, or in a user-written RULE, or with a HTTP URL:
http://ESPEASY_IP/control?cmd=relay,0,1

Or command through MQTT (from ESPEasy wiki)
<MQTT subscribe template>/cmd with payload: <command>

nygma
Normal user
Posts: 25
Joined: 26 Nov 2016, 11:16

Re: Serial MCU controlled relay/switch

#133 Post by nygma » 08 May 2018, 07:31

enesbcs wrote: 08 May 2018, 07:05
You have to implement MQTT support if you wish to use it.

Currently the plugin can be used with the following commands:

The ON command for Relay0:
relay,0,1
The OFF command for Relay0:
relay,0,0
The ON command for Relay1:
relay,1,1
The OFF command for Relay1:
relay,1,0

Commands can be executed on the web interface directly, or in a user-written RULE, or with a HTTP URL:
http://ESPEASY_IP/control?cmd=relay,0,1

Or command through MQTT (from ESPEasy wiki)
<MQTT subscribe template>/cmd with payload: <command>
Is it possible that this 2 relay module is somehow different? I tried the HTTP commands. First of all there is no HTTP response (empty head and body) (I am not sure if that is intentional or not).

I see the following in the log after I issue the HTTP command:
228095 : EVENT: Relay#Relay0=1.00
228097 : EVENT: Relay#Relay0=1.00 Processing time:2 milliSeconds
228098 : EVENT: Relay#Relay1=1.00
228099 : EVENT: Relay#Relay1=1.00 Processing time:1 milliSeconds
228100 : EVENT: Relay#Relay2=0.00
228101 : EVENT: Relay#Relay2=0.00 Processing time:2 milliSeconds
228110 : MQTT : /LCTech/Relay/Relay0 1
228110 : MQTT : /LCTech/Relay/Relay1 1

I am not sure why there are relay 0, 1 and 2 when I have configured that I only have 2 relays. But I guess that should not cause any issues.

User avatar
enesbcs
Normal user
Posts: 587
Joined: 18 Jun 2017, 11:02
Location: Békéscsaba, Hungary
Contact:

Re: Serial MCU controlled relay/switch

#134 Post by enesbcs » 08 May 2018, 07:46

nygma wrote: 08 May 2018, 07:31 Is it possible that this 2 relay module is somehow different? I tried the HTTP commands. First of all there is no HTTP response (empty head and body) (I am not sure if that is intentional or not).
...
I am not sure why there are relay 0, 1 and 2 when I have configured that I only have 2 relays. But I guess that should not cause any issues.
Yes, there are multiple variants of this relay, some of them also have hardware bugs. (power supply inefficient so they auto restart when relay is on)
relay number 0 is always the first relay, and 1 is the second one on every supported device, it does not matter how you name it - the commands using their hardwired number.
There will be no HTTP response, we never know if the command is succesfully completed, because there are absolutely no answer from the device, nor any option to check the relay active status. I can modify the code the output some meaningless text, such as "command completed", if anybody need it.
riker1 wrote: 30 Jan 2018, 08:37 Now I can switch relay with 115200 baut.
According to riker 115200 baud is the necessary setting. Save than power off&power on the device, and check if it works. If nothing helps you can try other speeds, and for last resort: command doubling.

nygma
Normal user
Posts: 25
Joined: 26 Nov 2016, 11:16

Re: Serial MCU controlled relay/switch

#135 Post by nygma » 08 May 2018, 08:34

enesbcs wrote: 08 May 2018, 07:46 According to riker 115200 baud is the necessary setting. Save than power off&power on the device, and check if it works. If nothing helps you can try other speeds, and for last resort: command doubling.
WOW, man, it works! Thank you very much! Let me add a post here with the exact settings for anyone who comes around next time.

User avatar
enesbcs
Normal user
Posts: 587
Joined: 18 Jun 2017, 11:02
Location: Békéscsaba, Hungary
Contact:

Re: Serial MCU controlled relay/switch

#136 Post by enesbcs » 08 May 2018, 09:13

nygma wrote: 08 May 2018, 08:34 WOW, man, it works! Thank you very much! Let me add a post here with the exact settings for anyone who comes around next time.
Nincs mit. Nyugodtan posztold ide a beállításokat, jellemzően úgyse olvasnak vissza, inkább kérdeznek. :)

nygma
Normal user
Posts: 25
Joined: 26 Nov 2016, 11:16

Re: Serial MCU controlled relay/switch

#137 Post by nygma » 08 May 2018, 09:18

enesbcs wrote: 08 May 2018, 09:13 Nincs mit. Nyugodtan posztold ide a beállításokat, jellemzően úgyse olvasnak vissza, inkább kérdeznek. :)
:D Igen, és én is ilyen vagyok

nygma
Normal user
Posts: 25
Joined: 26 Nov 2016, 11:16

Re: Serial MCU controlled relay/switch

#138 Post by nygma » 08 May 2018, 09:29

This for anyone who would like to setup ESP Easy for a LCTech Relay X2 board. Thanks for the guys here for making this happen and helping me getting it working with my relay board.
I got mine from ICStation.com: http://www.icstation.com/esp8266-wifi-c ... 12593.html

My model came with a ESP-01 NOT with a PUYA flash chip. But the firmware is PUYA compatible, so it should work with an ESP-01 with PUYA :D

This is how my board looks like:
IMG_20180508_085722.jpg
IMG_20180508_085722.jpg (383.79 KiB) Viewed 124186 times
And the back of the board:
IMG_20180508_085740.jpg
IMG_20180508_085740.jpg (411.79 KiB) Viewed 124186 times
Flash ESPEasy_1M_128kSPIFFS_PUYA.bin firmware to the ESP-01. You can find the link to the firmware on Page 12 post #120 of this thread.

Perform the basic settings of the ESP Easy (wifi, etc.)
I set LCTech as my unit name (it will be important for MQTT later):
Esp_main.png
Esp_main.png (19.79 KiB) Viewed 124186 times
Add the following in the Device section:
ESP_device.png
ESP_device.png (53.75 KiB) Viewed 124186 times
Of course your can rename the Relay0, Relay1 names at the bottom. Ignore Relay2.

I set up MQTT with the following settings:
esp_controller.png
esp_controller.png (50.08 KiB) Viewed 124186 times
Save the settings and power cycle the relay board. When I power up the board, the red LED (D7) is lit and after a few seconds the green LED (D6) starts flashing. And it will stay that way. The board is ready to receive commands. So far I am controlling it via HTTP and MQTT the following way:

HTTP commands:
Relay 0 Off: http://ESP_IP/control?cmd=relay,0,0
Relay 0 On: http://ESP_IP/control?cmd=relay,0,1
Relay 1 Off: http://ESP_IP/control?cmd=relay,1,0
Relay 1 On: http://ESP_IP/control?cmd=relay,1,1

MQTT commands:
Topic: /LCTech/cmd (of course this may change depending on the Unit name)
Payload:
Relay 0 Off: relay,0,0
Relay 0 On: relay,0,1
Relay 1 Off: relay,1,0
Relay 1 On: relay,1,1

With the above setup, you will be getting MQTT messages on /LCTech/Relay/Relay0 or /LCTech/Relay/Relay1 topic with payload of 0 or 1 when the relay status is changed either via HTTP or MQTT. There is no status message back via HTTP. Keep in mind that this is not based on the actual status of the relay, as the MCU is not sending status information / confirmation back to ESP.
Last edited by nygma on 12 May 2018, 14:09, edited 1 time in total.

angelo67
Normal user
Posts: 10
Joined: 08 May 2018, 21:32

Re: Serial MCU controlled relay/switch

#139 Post by angelo67 » 08 May 2018, 21:41

Hello,
I have problems with the configuration, post programming
Configure the wifi connection, I wait for 20 seconds but when I try again
I do not go ahead, I always stay in the wifi configuration.
What programmer should I use for flash esp-01?
sorry for my english, I use google translator.
thank you

User avatar
enesbcs
Normal user
Posts: 587
Joined: 18 Jun 2017, 11:02
Location: Békéscsaba, Hungary
Contact:

Re: Serial MCU controlled relay/switch

#140 Post by enesbcs » 09 May 2018, 08:11

angelo67 wrote: 08 May 2018, 21:41 I have problems with the configuration, post programming
Configure the wifi connection, I wait for 20 seconds but when I try again
I do not go ahead, I always stay in the wifi configuration.
What programmer should I use for flash esp-01?
I used a CP2102 (not FTDI) in such connections to program it:
Image
with DOUT mode and of course with the proper PUYA-safe binary.
If it stays in wifi config mode after programming, than power off&power on the module and retry.

xury
Normal user
Posts: 44
Joined: 02 Apr 2018, 12:54

Re: Serial MCU controlled relay/switch

#141 Post by xury » 09 May 2018, 12:14

enesbcs wrote: 08 May 2018, 07:46 I can modify the code the output some meaningless text, such as "command completed", if anybody need it.
if it was not a problem, I would ask for such function because Domoticz need any response otherwise shows error.
It would be nice if the response would be in JSON format.
Üdvözlet Lengyelországból.

angelo67
Normal user
Posts: 10
Joined: 08 May 2018, 21:32

Re: Serial MCU controlled relay/switch

#142 Post by angelo67 » 09 May 2018, 14:03

Hi,
I used a CP2102 (not FTDI) in such connections to program it:
http://m.blog.hu/bi/bitekmindenhol/imag ... rele_2.jpg
with DOUT mode and of course with the proper PUYA-safe binary.
If it stays in wifi config mode after programming, than power off&power on the module and retry.

This is good?
https://www.ebay.it/itm/Convertitore-Se ... SwZ2Na8bKJ

and wich programmer software you use??

User avatar
enesbcs
Normal user
Posts: 587
Joined: 18 Jun 2017, 11:02
Location: Békéscsaba, Hungary
Contact:

Re: Serial MCU controlled relay/switch

#143 Post by enesbcs » 09 May 2018, 16:09

angelo67 wrote: 09 May 2018, 14:03 and wich programmer software you use??
esptool and nodemcu-pyflasher

angelo67
Normal user
Posts: 10
Joined: 08 May 2018, 21:32

Re: Serial MCU controlled relay/switch

#144 Post by angelo67 » 09 May 2018, 23:47

Whats the different to the file
ESPEasy_Mega_P165_1M_128kS_lwip20_PUYA.bin
and
ESPEasy_Mega_P165_1M_128kS_lwip14_PUYA.bin

User avatar
enesbcs
Normal user
Posts: 587
Joined: 18 Jun 2017, 11:02
Location: Békéscsaba, Hungary
Contact:

Re: Serial MCU controlled relay/switch

#145 Post by enesbcs » 10 May 2018, 08:45

angelo67 wrote: 09 May 2018, 23:47 Whats the different to the file
ESPEasy_Mega_P165_1M_128kS_lwip20_PUYA.bin
and
ESPEasy_Mega_P165_1M_128kS_lwip14_PUYA.bin
The first was compiled with the newer lwIP 2.0 stack, the other compiled with the old lwIP 1.4. The older supposed to be more stable, but you can try and see. :)

User avatar
enesbcs
Normal user
Posts: 587
Joined: 18 Jun 2017, 11:02
Location: Békéscsaba, Hungary
Contact:

Re: Serial MCU controlled relay/switch

#146 Post by enesbcs » 10 May 2018, 22:29

xury wrote: 09 May 2018, 12:14 if it was not a problem, I would ask for such function because Domoticz need any response otherwise shows error.
Fair enough, Domoticz really shows an error, if reply did not arrive to the GET command. Now i am replying with an "OK" message, Domoticz error message disappeared.
xury wrote: 09 May 2018, 12:14 It would be nice if the response would be in JSON format.
Exactly what JSON message did you mean, and for what purpose? Domoticz did not care about replies from "Switch" devices as i see.

xury
Normal user
Posts: 44
Joined: 02 Apr 2018, 12:54

Re: Serial MCU controlled relay/switch

#147 Post by xury » 11 May 2018, 14:20

Yes you have right. Domoticz does not care about switch reply.
So simply OK will be good.

angelo67
Normal user
Posts: 10
Joined: 08 May 2018, 21:32

Re: Serial MCU controlled relay/switch

#148 Post by angelo67 » 18 May 2018, 22:25

Hi
now whit the CP2102 its ok
but one error :"Md5 check Fail!"
look the part of info page
Build 20102 - Mega
Libraries ESP82xx Core 2_4_1, NONOS SDK 2.2.1(cfd48f3), LWIP: 2.0.3
GIT version (custom)
Plugins 12 [Normal] [Testing] [Development]
Build Md5 4d44355f4d44355f4d44355f4d44355f
Md5 check fail !
Build time May 10 2018 21:39:17"

User avatar
enesbcs
Normal user
Posts: 587
Joined: 18 Jun 2017, 11:02
Location: Békéscsaba, Hungary
Contact:

Re: Serial MCU controlled relay/switch

#149 Post by enesbcs » 19 May 2018, 00:23

angelo67 wrote: 18 May 2018, 22:25 but one error :"Md5 check Fail!"
Maybe i have to inject somehow md5 hash into "runTimeMD5" after compiling, but honestly i I do not see its practical significance.
Until appearing more detailed information in here:
https://www.letscontrolit.com/wiki/inde ... are_Upload
this bug stays in "wontfix" category.
Or i will simply delete it completly before compiling if it will be annoying. :)

countcobolt
Normal user
Posts: 32
Joined: 12 Jun 2017, 11:12

Re: Serial MCU controlled relay/switch

#150 Post by countcobolt » 17 Jun 2018, 13:21

Hi all,

I just received a Jinvoo dual switch. I would like to install the ESP firmware yet I do not find any empty pin headers... Has anyone experience with flashing this device? Below are the pictures of the PCB board.
The attachment 20180617_131709.jpg is no longer available
20180617_131709.jpg
20180617_131709.jpg (3.88 MiB) Viewed 122151 times
In case someone already flashed it, which binary file did you use?

Kind regards

Steve

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: Serial MCU controlled relay/switch

#151 Post by grovkillen » 17 Jun 2018, 13:46

Look at the wiki for the Sonoff Touch.
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: Serial MCU controlled relay/switch

#152 Post by grovkillen » 17 Jun 2018, 13:48

ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

countcobolt
Normal user
Posts: 32
Joined: 12 Jun 2017, 11:12

Re: Serial MCU controlled relay/switch

#153 Post by countcobolt » 17 Jun 2018, 13:59

Heyhey

Looking further : would I be able to use this to flash it? Looked at the above link, but don't have a 3.3 + GND on the print.

Would I be able to solder on the chip
https://docs.tuya.com/en/hardware/WiFi- ... e-mcu.html

pin 16/15 and 12 for comms and 8 and 9 to put 3.3V on it?

Kind regards

Steve

countcobolt
Normal user
Posts: 32
Joined: 12 Jun 2017, 11:12

Re: Serial MCU controlled relay/switch

#154 Post by countcobolt » 17 Jun 2018, 14:32

and don't bother going any further, I just literally burned some of the traces... To be honest, crappy PCB :( :( :(.

Still have a Sonoff Touch 2-gang to go with

Kind regards

Steve

desprueht
New user
Posts: 4
Joined: 17 Jun 2018, 15:24

Re: Serial MCU controlled relay/switch

#155 Post by desprueht » 17 Jun 2018, 15:40

Hello,

I have a LCTech Relay X4 board. I installed ESPEasy on the ESP-01 (ESPEasy_1M_128kSPIFFS_PUYA.zip) and the first two relays are in function, but the last two relays are not contolled.
What can I do to use all four relays?

I would like to control with HTTP commands:
HTTP commands:
Relay 0 Off: http://ESP_IP/control?cmd=relay,0,0
Relay 0 On: http://ESP_IP/control?cmd=relay,0,1
Relay 1 Off: http://ESP_IP/control?cmd=relay,1,0
Relay 1 On: http://ESP_IP/control?cmd=relay,1,1
Relay 2 Off: http://ESP_IP/control?cmd=relay,2,0
Relay 2 On: http://ESP_IP/control?cmd=relay,2,1
Relay 3 Off: http://ESP_IP/control?cmd=relay,3,0
Relay 3 On: http://ESP_IP/control?cmd=relay,3,1

Who can help me?
Thanks
Last edited by desprueht on 17 Jun 2018, 16:09, edited 1 time in total.

User avatar
enesbcs
Normal user
Posts: 587
Joined: 18 Jun 2017, 11:02
Location: Békéscsaba, Hungary
Contact:

Re: Serial MCU controlled relay/switch

#156 Post by enesbcs » 17 Jun 2018, 15:46

desprueht wrote: 17 Jun 2018, 15:40 Hello,

I have a LCTech Relay X2 board. I installed ESPEasy on the ESP-01 (ESPEasy_1M_128kSPIFFS_PUYA.zip) and the first two relays are in function, but the last two relays are not contolled.
What can I do to use all four relays?
Hi,

I've never seen a 4 relay version, can you provide me the link or the datasheet, to find out what serial commands needed to operate it?

desprueht
New user
Posts: 4
Joined: 17 Jun 2018, 15:24

Re: Serial MCU controlled relay/switch

#157 Post by desprueht » 17 Jun 2018, 15:53

Hello,

Relay control instructions (hex hexadecimal):
Open the first relay: A0 01 01 A2
Turn off the first relay: A0 01 00 A1
Open the second relay: A0 02 01 A3
Close the second relay: A0 02 00 A2
Open the third relay: A0 03 01 A4
Turn off the third relay: A0 03 00 A3
Open the fourth relay: A0 04 01 A5
Turn off the fourth relay: A0 04 00 A4"

and the link:
http://www.chinalctech.com/index.php?_m ... &p_id=1288

countcobolt
Normal user
Posts: 32
Joined: 12 Jun 2017, 11:12

Re: Serial MCU controlled relay/switch

#158 Post by countcobolt » 17 Jun 2018, 16:13

Hi all

sorry is this is a stupid question, but will your firmware work with the Sonoff T1 2Gang (similar to the dual?). I both 2 and want to be able to control them using ESPEasy and Domoticz.

Kind regards

Steve

User avatar
enesbcs
Normal user
Posts: 587
Joined: 18 Jun 2017, 11:02
Location: Békéscsaba, Hungary
Contact:

Re: Serial MCU controlled relay/switch

#159 Post by enesbcs » 17 Jun 2018, 20:24

countcobolt wrote: 17 Jun 2018, 16:13 sorry is this is a stupid question, but will your firmware work with the Sonoff T1 2Gang (similar to the dual?). I both 2 and want to be able to control them using ESPEasy and Domoticz.
This plugin will not work with any Sonoff T1. According to Tasmota wiki:
"When pushing a button, the touch chip lift the power high to the EFM8BB1, and the EFM8BB1 chip ties the signal line for each button low, for the full duration of the keypress. There is no serial data, that i have seen at all."
The device's operation is somewhat obscure to me, i am using my own T1 2Gang with Tasmota without problmes. :)

User avatar
enesbcs
Normal user
Posts: 587
Joined: 18 Jun 2017, 11:02
Location: Békéscsaba, Hungary
Contact:

Re: Serial MCU controlled relay/switch

#160 Post by enesbcs » 17 Jun 2018, 22:44

desprueht wrote: 17 Jun 2018, 15:53 Hello,

Relay control instructions (hex hexadecimal):
Open the first relay: A0 01 01 A2
Turn off the first relay: A0 01 00 A1
Open the second relay: A0 02 01 A3
Close the second relay: A0 02 00 A2
Open the third relay: A0 03 01 A4
Turn off the third relay: A0 03 00 A3
Open the fourth relay: A0 04 01 A5
Turn off the fourth relay: A0 04 00 A4"

and the link:
http://www.chinalctech.com/index.php?_m ... &p_id=1288
Ok the commands seems consistent, i expanded the plugin to support 4 relay, now it can be selected in plugin options.
Last edited by enesbcs on 18 Jun 2018, 19:03, edited 1 time in total.

countcobolt
Normal user
Posts: 32
Joined: 12 Jun 2017, 11:12

Re: Serial MCU controlled relay/switch

#161 Post by countcobolt » 18 Jun 2018, 08:39

enesbcs wrote: 17 Jun 2018, 20:24
countcobolt wrote: 17 Jun 2018, 16:13 sorry is this is a stupid question, but will your firmware work with the Sonoff T1 2Gang (similar to the dual?). I both 2 and want to be able to control them using ESPEasy and Domoticz.
This plugin will not work with any Sonoff T1. According to Tasmota wiki:
"When pushing a button, the touch chip lift the power high to the EFM8BB1, and the EFM8BB1 chip ties the signal line for each button low, for the full duration of the keypress. There is no serial data, that i have seen at all."
The device's operation is somewhat obscure to me, i am using my own T1 2Gang with Tasmota without problmes. :)

Hey Enesbcs

do you use the web or MQTT component for this? (On Tasmota)

Kind regards

User avatar
enesbcs
Normal user
Posts: 587
Joined: 18 Jun 2017, 11:02
Location: Békéscsaba, Hungary
Contact:

Re: Serial MCU controlled relay/switch

#162 Post by enesbcs » 18 Jun 2018, 15:15

countcobolt wrote: 18 Jun 2018, 08:39 do you use the web or MQTT component for this? (On Tasmota)
I am using the Tasmota MQTT with Sonoff T1, works perfecty with my Domoticz server.

desprueht
New user
Posts: 4
Joined: 17 Jun 2018, 15:24

Re: Serial MCU controlled relay/switch

#163 Post by desprueht » 18 Jun 2018, 17:41

enesbcs wrote: 17 Jun 2018, 22:44
desprueht wrote: 17 Jun 2018, 15:53 Hello,

Relay control instructions (hex hexadecimal):
Open the first relay: A0 01 01 A2
Turn off the first relay: A0 01 00 A1
Open the second relay: A0 02 01 A3
Close the second relay: A0 02 00 A2
Open the third relay: A0 03 01 A4
Turn off the third relay: A0 03 00 A3
Open the fourth relay: A0 04 01 A5
Turn off the fourth relay: A0 04 00 A4"

and the link:
http://www.chinalctech.com/index.php?_m ... &p_id=1288
Ok the commands seems consistent, i expanded the plugin to support 4 relay, now it can be selected in plugin options.
Download and try: v23
Hi, thank you very much for your work.
I have a problem with the webinterface. when i click on Devices and add a Serial MCU controlled switch, then I can't edit the device. The ESP-01 makes a restart.

User avatar
enesbcs
Normal user
Posts: 587
Joined: 18 Jun 2017, 11:02
Location: Békéscsaba, Hungary
Contact:

Re: Serial MCU controlled relay/switch

#164 Post by enesbcs » 18 Jun 2018, 19:05

desprueht wrote: 18 Jun 2018, 17:41 Hi, thank you very much for your work.
I have a problem with the webinterface. when i click on Devices and add a Serial MCU controlled switch, then I can't edit the device. The ESP-01 makes a restart.
You're right... i left out one index, and ESP did not honor buffer overflow. :)
Try the updated binary.

desprueht
New user
Posts: 4
Joined: 17 Jun 2018, 15:24

Re: Serial MCU controlled relay/switch

#165 Post by desprueht » 18 Jun 2018, 21:22

enesbcs wrote: 18 Jun 2018, 19:05
desprueht wrote: 18 Jun 2018, 17:41 Hi, thank you very much for your work.
I have a problem with the webinterface. when i click on Devices and add a Serial MCU controlled switch, then I can't edit the device. The ESP-01 makes a restart.
You're right... i left out one index, and ESP did not honor buffer overflow. :)
Try the updated binary.
It's so wunderfull. Thank you for all...

Whitey
New user
Posts: 7
Joined: 04 Aug 2018, 12:02

Re: Serial MCU controlled relay/switch

#166 Post by Whitey » 04 Aug 2018, 12:13

Very new to all this so forgive me.

Had one of these laying around as it was useless in its original state. Managed to flash the firmware and get it working.

I wish to use it to control a garage opener that only requires a momentary switch. Is it possible to do that with this?

Have tried the pulse command but had a feeling it wound not work and I was correct.

At the moment I have a script setup in home assistant that turns the off after 1 second but find this is more like 2 or 3 seconds. The script is a very crude way to do what I want so was hoping for a better solution.

User avatar
enesbcs
Normal user
Posts: 587
Joined: 18 Jun 2017, 11:02
Location: Békéscsaba, Hungary
Contact:

Re: Serial MCU controlled relay/switch

#167 Post by enesbcs » 04 Aug 2018, 17:15

Whitey wrote: 04 Aug 2018, 12:13 Had one of these laying around as it was useless in its original state. Managed to flash the firmware and get it working.
What device? This plugin supports some kind from Lctech, Tuya, S.Dual.. be a little more specific. I think it can be done with EspEasy rules.

Whitey
New user
Posts: 7
Joined: 04 Aug 2018, 12:02

Re: Serial MCU controlled relay/switch

#168 Post by Whitey » 04 Aug 2018, 22:01

enesbcs wrote: 04 Aug 2018, 17:15 What device? This plugin supports some kind from Lctech, Tuya, S.Dual.. be a little more specific. I think it can be done with EspEasy rules.
Sorry about that, referring to the 12v LC Tech single channel relay (same one as the post at 116)
lctech12.jpg
lctech12.jpg (34.33 KiB) Viewed 161024 times

User avatar
enesbcs
Normal user
Posts: 587
Joined: 18 Jun 2017, 11:02
Location: Békéscsaba, Hungary
Contact:

Re: Serial MCU controlled relay/switch

#169 Post by enesbcs » 05 Aug 2018, 09:52

Whitey wrote: 04 Aug 2018, 22:01 Sorry about that, referring to the 12v LC Tech single channel relay (same one as the post at 116)
I see. You have to enable rules in Espeasy advanced settings, then if the serial device name is "lc" and the first relay named as "Relay0" (default) then the code below switches off the relay one seconds after switched on. It has to work, if somehow not, then i will ty to implement it inside the plugin.

Code: Select all

on lc#Relay0>0 do
 timerset,1,1
endon

on Rules#Timer=1 do
 relay,0,0
endon

Whitey
New user
Posts: 7
Joined: 04 Aug 2018, 12:02

Re: Serial MCU controlled relay/switch

#170 Post by Whitey » 05 Aug 2018, 10:08

enesbcs wrote: 05 Aug 2018, 09:52
Whitey wrote: 04 Aug 2018, 22:01 Sorry about that, referring to the 12v LC Tech single channel relay (same one as the post at 116)
I see. You have to enable rules in Espeasy advanced settings, then if the serial device name is "lc" and the first relay named as "Relay0" (default) then the code below switches off the relay one seconds after switched on. It has to work, if somehow not, then i will ty to implement it inside the plugin.

Code: Select all

on lc#Relay0>0 do
 timerset,1,1
endon

on Rules#Timer=1 do
 relay,0,0
endon
Will give it a go when I get home in an hour or so.

Thanks heaps

Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 133 guests