Serial MCU controlled relay/switch

Moderators: grovkillen, Stuntteam, TD-er

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

Re: Serial MCU controlled relay/switch

#301 Post by enesbcs » 03 Aug 2019, 21:10

fiets wrote:
03 Aug 2019, 18:58
Can you give me an example?
Examples given at the first post viewtopic.php?p=16998#p16998
The following command switches the second relay on the panel, if it has a second relay and you set the correct number of relays on the plugin settings page:

Code: Select all

relay,1,1
The following command switches the first relay on the panel.

Code: Select all

relay,0,1
If it is not working, there are several other possibilities, from unstable power supply to not correct baud rates which render this device unusable. (for example: some units has misprogrammed MCU firmware which will not work without IPD setting, and some of them has absolutely no firmware...)

marcov
Normal user
Posts: 2
Joined: 03 Aug 2019, 15:14

Re: Serial MCU controlled relay/switch

#302 Post by marcov » 05 Aug 2019, 12:58

- If the led on the relayboard is flashing constandly even without the esp module then the mcu is emty.
- if the LED is working but not the relay then check resistor R3 and R4 values. with my board the where swapped. and is solderred a 10K resistor over the R3 (10K) resistor
- also you kan test the relay without the esp on it by ussing the programmer interface.
- Here is explained how to (Re)program the MCU chip on the relay board with firmware, also adding some new features. see https://www.esp8266.com/viewtopic.php?f ... =68#p74262

_Cyber_
Normal user
Posts: 7
Joined: 20 Oct 2019, 09:46

Re: Serial MCU controlled relay/switch

#303 Post by _Cyber_ » 20 Oct 2019, 09:57

hi,

thanks for detailled descriptions and firmwares in here. does anybody know if it is planned to add this "Serial MCU controlled switch" option to ESP Easy stock firmware?

another issue I have: I have a 4ch relay module, I flashed firmware and it worked already flawless with esp easy and switching the 4 relays. Red led lighting, green one blinkink.

now I pressed "SW1" on the board. blue led lights on the board, green and red led are off, I cannot do anything to get it working again with the esp.
regarding vendor (http://www.chinalctech.com/cpzx/Programmer/428.html):
LED D5(blue):indicator for mode 2
Mode 2: cellphone and wifi module carry on router together

so it seems like the board is now waiting for the esp to do something?
Issue is, I do not have the original firmware any more, never made any tries with the original one (so it is not set up!), and also on pressing SW1 again it does not switch back to mode 1 any more.

has anybody an idea how I can tell the board to go back to mode 1?
if not, has anybody the stock firmware preserved before flashing and can share it with me?

//Edit: I just found out - holding down SW1 until powering on the board sets it back to mode1. I think nobody managed to "init" it correctly without stock firmware?

Thanks!

Best regards!

Micha_he
Normal user
Posts: 79
Joined: 07 Feb 2018, 19:14

Re: Serial MCU controlled relay/switch

#304 Post by Micha_he » 21 Oct 2019, 08:28

@enesbcs: Do you think this dimmer should work with the P165-plugin too?
https://forum.creationx.de/forum/index. ... logen-etc/

I've flashed the attached Tasmota-Firmware which works.

When I flash your firmware 'ESPEasy_P165.1M_128kS_PUYA3' from port #295 of this thread, then I can't get the dimmer to switch on or set any dim-value.
Command (.../control?cmd=relay,0,1 or .../control?cmd=ydim,100) returns OK, but all values are still 0.

Switch Type: Yewelink/TUYA
Number of relays: '1' or '2/Dimmer#2' (which is the correct one?)
Enabled Serial port: ON
Serial Log Level: NONE

Any idea ???

Thanks from germany
Micha

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

Re: Serial MCU controlled relay/switch

#305 Post by enesbcs » 21 Oct 2019, 09:52

Micha_he wrote:
21 Oct 2019, 08:28
@enesbcs: Do you think this dimmer should work with the P165-plugin too?
https://forum.creationx.de/forum/index. ... logen-etc/

I've flashed the attached Tasmota-Firmware which works.

When I flash your firmware 'ESPEasy_P165.1M_128kS_PUYA3' from port #295 of this thread, then I can't get the dimmer to switch on or set any dim-value.
Command (.../control?cmd=relay,0,1 or .../control?cmd=ydim,100) returns OK, but all values are still 0.

Switch Type: Yewelink/TUYA
Number of relays: '1' or '2/Dimmer#2' (which is the correct one?)
Enabled Serial port: ON
Serial Log Level: NONE

Any idea ???

Thanks from germany
Micha
As i know, Tasmota is using a very similar method for controll, so in theory it has to work.
2/Dimmer#2 and 3/Dimmer#3 is the only valid options for dimmer, "1" is not a valid choice.
As the Tasmota wiki says: "The DpId generally is 2 or 3. The easiest is to try both"
Try to reboot after change settings.

Commands always replies with OK this has no meaning.. if the command is succesful, than the MCU sends back the value and state through serial, if the value is still 0 than the command failed/no reply arrived from MCU.

Micha_he
Normal user
Posts: 79
Joined: 07 Feb 2018, 19:14

Re: Serial MCU controlled relay/switch

#306 Post by Micha_he » 21 Oct 2019, 10:11

Currently there is Tasmota on the dimmer. Can I use it to help to troubleshoot ?
If not, I will flash it new with your #295-firmware. Is the baudrate-settings (default 115200) important ?

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

Re: Serial MCU controlled relay/switch

#307 Post by enesbcs » 21 Oct 2019, 11:04

Micha_he wrote:
21 Oct 2019, 10:11
Currently there is Tasmota on the dimmer. Can I use it to help to troubleshoot ?
If not, I will flash it new with your #295-firmware. Is the baudrate-settings (default 115200) important ?
I've never used Tasmota for Tuya so i do not know how to troubleshoot that.
The baudrate setting for Tuya is 9600 and you can not alter that. The ESPEasy default is 115200 but it is not used for that.

digiblur captured the serial communication directly and found out that ID 3 is the right choice for him.
viewtopic.php?p=31388#p31388

Micha_he
Normal user
Posts: 79
Joined: 07 Feb 2018, 19:14

Re: Serial MCU controlled relay/switch

#308 Post by Micha_he » 22 Oct 2019, 21:14

Both modes (2/Dimmer#2 and 3/Dimmer#3) didn't work :(

Here's a log from the Tasmota firmware that works:

Code: Select all

20:04:55 CMD: dimmer 100
20:04:55 Script: performs "SerialSend5 FF556e05DC0A"
20:04:55 RSL: RESULT = {"SerialSend":"Done"}
20:04:55 Script: performs "Dimmer 50.00"
20:04:55 RSL: RESULT = {"POWER":"ON","Dimmer":50}
20:04:55 RSL: RESULT = {"POWER":"ON","Dimmer":50}
20:04:55 Script: performs "SerialSend5 FF556e05DC0A"
20:04:55 RSL: RESULT = {"SerialSend":"Done"}
20:04:55 Script: performs "Dimmer 50.00"
20:04:55 RSL: RESULT = {"POWER":"ON","Dimmer":50}
20:05:09 CMD: dimmer 100
20:05:09 RSL: RESULT = {"POWER":"ON","Dimmer":100}
20:05:09 Script: performs "SerialSend5 FF55dc05DC0A"
20:05:09 RSL: RESULT = {"SerialSend":"Done"}
20:05:09 Script: performs "Dimmer 100.00"
20:05:09 RSL: RESULT = {"POWER":"ON","Dimmer":100}
20:05:14 CMD: dimmer 50
20:05:14 RSL: RESULT = {"POWER":"ON","Dimmer":50}
20:05:14 Script: performs "SerialSend5 FF556e05DC0A"
20:05:14 RSL: RESULT = {"SerialSend":"Done"}
20:05:14 Script: performs "Dimmer 50.00"
20:05:14 RSL: RESULT = {"POWER":"ON","Dimmer":50}
20:05:20 CMD: dimmer 0
20:05:20 Script: performs "SerialSend5 FF550005DC0A"
20:05:20 RSL: RESULT = {"SerialSend":"Done"}
20:05:20 Script: performs "Dimmer 0.00"
20:05:20 RSL: RESULT = {"POWER":"OFF","Dimmer":0}
20:05:20 RSL: RESULT = {"POWER":"OFF","Dimmer":0}
20:05:20 Script: performs "SerialSend5 FF550005DC0A"
20:05:20 RSL: RESULT = {"SerialSend":"Done"}
20:05:20 Script: performs "Dimmer 0.00"
20:05:20 RSL: RESULT = {"POWER":"OFF","Dimmer":0}
The same byte-data you can see in the log, I'd read on the com-port ! Any idea, why the byte sequence is completely different from ESPeasy here:

Code: Select all

55 AA 00 06 00 08 03 02 00 04 00 00 00 C8 DE
Byte-Sequence for ydim,200

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

Re: Serial MCU controlled relay/switch

#309 Post by enesbcs » 23 Oct 2019, 09:20

Micha_he wrote:
22 Oct 2019, 21:14
The same byte-data you can see in the log, I'd read on the com-port ! Any idea, why the byte sequence is completely different from ESPeasy here:

Code: Select all

55 AA 00 06 00 08 03 02 00 04 00 00 00 C8 DE
Byte-Sequence for ydim,200
Because this is the standard Tuya package with header 55 AA...
viewtopic.php?p=31388#p31388

Micha_he
Normal user
Posts: 79
Joined: 07 Feb 2018, 19:14

Re: Serial MCU controlled relay/switch

#310 Post by Micha_he » 23 Oct 2019, 10:31

Maybe I can find a way, to modify the P165 plugin, to work with this dimmer too.
I was just surprised, because the original TuyaSmart-App is the recommended application for it.

Can I send data to the COM-port, via ESPeasy-rules (for a simple test) ?

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

Re: Serial MCU controlled relay/switch

#311 Post by enesbcs » 24 Oct 2019, 09:28

Micha_he wrote:
23 Oct 2019, 10:31
Maybe I can find a way, to modify the P165 plugin, to work with this dimmer too.
I was just surprised, because the original TuyaSmart-App is the recommended application for it.
According to templates it is a noname "Wifi-Dimmer":
https://blakadder.github.io/templates/q ... immer.html

It has nothing to do with the official Tuya-serial-protocol, it is using another "protocol" and the only non-standard packet type that it accepts is this:
FF 55 xx 05 DC 0A

I can add it to the code easily the only hard issue will be the compilation.

Micha_he
Normal user
Posts: 79
Joined: 07 Feb 2018, 19:14

Re: Serial MCU controlled relay/switch

#312 Post by Micha_he » 24 Oct 2019, 09:56

enesbcs wrote:
24 Oct 2019, 09:28
I can add it to the code easily...
Thanks, that would be nice. I didn't understand the complete code in the plugin :(
enesbcs wrote:
24 Oct 2019, 09:28
...the only hard issue will be the compilation.
Because ?

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

Re: Serial MCU controlled relay/switch

#313 Post by enesbcs » 24 Oct 2019, 10:31

Micha_he wrote:
24 Oct 2019, 09:56
Because ?
I have to reinstall core 2.4.1 to make sure that serial 2way communication works as expected to not break real Tuya support, which also receives from serial. (core 2.5 is unstable, core 2.5.2 is untested)
After that i have to do Puya patching and compiling to 1M/128k, 4M/1M flash format. Not my favourite.

Micha_he
Normal user
Posts: 79
Joined: 07 Feb 2018, 19:14

Re: Serial MCU controlled relay/switch

#314 Post by Micha_he » 24 Oct 2019, 11:16

Maybe you can modify the source (in your GitHub) in a first step and explain me, how I integrate the plugin for compiling in my ATOM-IDE.
As far as I know, the dimmer QS-WIFI-D01 doesn't return the actual state. So that would not be so important to the test it.

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

Re: Serial MCU controlled relay/switch

#315 Post by enesbcs » 24 Oct 2019, 14:01

Micha_he wrote:
24 Oct 2019, 11:16
Maybe you can modify the source (in your GitHub) in a first step and explain me, how I integrate the plugin for compiling in my ATOM-IDE.
As far as I know, the dimmer QS-WIFI-D01 doesn't return the actual state. So that would not be so important to the test it.
Source modified:
https://github.com/enesbcs/ESPEasyPlugi ... Switch.ino

I am using Arduino IDE and a reduced ESPEasy 2018dec source for compiling. Mravko wrote some instructions for platformio: viewtopic.php?p=36756#p36756

Anyway i have compiled with current Core 2.5.2 and attached for testing. Remember it is "Wifi Dimmer" type, not "Tuya".

Micha_he
Normal user
Posts: 79
Joined: 07 Feb 2018, 19:14

Re: Serial MCU controlled relay/switch

#316 Post by Micha_he » 24 Oct 2019, 14:28

Thanks a lot :) I'll take a look at it and report the results...

Micha_he
Normal user
Posts: 79
Joined: 07 Feb 2018, 19:14

Re: Serial MCU controlled relay/switch

#317 Post by Micha_he » 24 Oct 2019, 21:12

The plugin/firmware works like it should. Top !

Now I'll have to design a rule for ON/OFF/DIM+/DIM-, to evaluate the switch-counter (S-input works with AC-frequency oft 50Hz at this dimmer).

Edit: Can you update the plugin-values (relay-state and dim-value) of "Wifi Dimmer", if the ydim-command is executed? Actually Relay0-4 are stay at zero!

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

Re: Serial MCU controlled relay/switch

#318 Post by enesbcs » 24 Oct 2019, 23:08

Micha_he wrote:
24 Oct 2019, 21:12
The plugin/firmware works like it should. Top !

Now I'll have to design a rule for ON/OFF/DIM+/DIM-, to evaluate the switch-counter (S-input works with AC-frequency oft 50Hz at this dimmer).

Edit: Can you update the plugin-values (relay-state and dim-value) of "Wifi Dimmer", if the ydim-command is executed? Actually Relay0-4 are stay at zero!
You can use the relay,0,0 command to set off, and the relay,0,1 to set on. The ydim is now followed - in theory.
Attachments
ESPEasy_P165_dim2.zip
ESPEasy P165 dim2 - core 2.5.2
(881.76 KiB) Downloaded 8 times

Micha_he
Normal user
Posts: 79
Joined: 07 Feb 2018, 19:14

Re: Serial MCU controlled relay/switch

#319 Post by Micha_he » 25 Oct 2019, 19:59

I've flashed the last of your firmware.
If I execute a 'ydim'-command, all (#0 and #1) is set to the correct values. But there is one issue:

If I execute 'relay,0,1' (value #1 is 0 before), the value #1 not set to the last dimvalue.
And if the value #1 is set to something between 1-255 and i execute a 'relay,0,0', the value #1 not set to 0.

TD-er
Core team member
Posts: 1809
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Serial MCU controlled relay/switch

#320 Post by TD-er » 25 Oct 2019, 22:09

Micha_he wrote:
25 Oct 2019, 19:59
I've flashed the last of your firmware.
If I execute a 'ydim'-command, all (#0 and #1) is set to the correct values. But there is one issue:

If I execute 'relay,0,1' (value #1 is 0 before), the value #1 not set to the last dimvalue.
And if the value #1 is set to something between 1-255 and i execute a 'relay,0,0', the value #1 not set to 0.
There are some issues with the parsing of commands when using the latest code in the mega branch.

Micha_he
Normal user
Posts: 79
Joined: 07 Feb 2018, 19:14

Re: Serial MCU controlled relay/switch

#321 Post by Micha_he » 25 Oct 2019, 22:21

Are you sure? enebcs has integrateted a new wifi-dimmer, which return no state. Here we need to set the values while the command in the plugin is being executed.
Last edited by Micha_he on 25 Oct 2019, 23:15, edited 1 time in total.

TD-er
Core team member
Posts: 1809
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Serial MCU controlled relay/switch

#322 Post by TD-er » 25 Oct 2019, 23:13

Micha_he wrote:
25 Oct 2019, 22:21
Are you sure? enebcs has integrateted a new wifi-dimmer, which return no state. Here wie need to set the values while the command in the plugin is being executed.
It was more a warning to enebcs to not spend too much time in looking for an error if it does apply to his build.
If he didn't use the latest mega code, then it would probably not be an issue.

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

Re: Serial MCU controlled relay/switch

#323 Post by enesbcs » 26 Oct 2019, 21:10

TD-er wrote:
25 Oct 2019, 23:13
It was more a warning to enebcs to not spend too much time in looking for an error if it does apply to his build.
If he didn't use the latest mega code, then it would probably not be an issue.
Thanks TD-er, but i am using ESPEasy core 20181231 for P165, before the Serial library (and i think Arduino support) changed.
Micha_he wrote:
25 Oct 2019, 19:59
If I execute 'relay,0,1' (value #1 is 0 before), the value #1 not set to the last dimvalue.
And if the value #1 is set to something between 1-255 and i execute a 'relay,0,0', the value #1 not set to 0.
You are right, my logic failed. Now i think it is fixed. v3 attached.
Attachments
ESPEasy_P165_dim3.zip
ESPEasy P165 core 2.5.2
(881.73 KiB) Downloaded 10 times

Micha_he
Normal user
Posts: 79
Joined: 07 Feb 2018, 19:14

Re: Serial MCU controlled relay/switch

#324 Post by Micha_he » 27 Oct 2019, 10:00

enesbcs wrote:
26 Oct 2019, 21:10
You are right, my logic failed. Now i think it is fixed. v3 attached.
Now all looks good. Thanks.

DirkB19
Normal user
Posts: 2
Joined: 27 Oct 2019, 20:29

Re: Serial MCU controlled relay/switch

#325 Post by DirkB19 » 27 Oct 2019, 20:38

enesbcs wrote:
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>

Hi,
from my Chrome webbrowser this command works : http://192.168.2.134/control?cmd=relay,1,1
The relay on my LCTECH X2 is switched as supposed to.

but if I do this command from another ESPEASY module in a rule like this :
On RFID_1#Tag1=71499966 do
SendToHTTP 192.168.2.134/control?cmd=relay,1,1
endon

I also tried adding admin:pasword@ before, but still doesn't work.
I tried many other syntaxes but none work, actually :roll:
Thanks for any suggestion,
DirkB

_Cyber_
Normal user
Posts: 7
Joined: 20 Oct 2019, 09:46

Re: Serial MCU controlled relay/switch

#326 Post by _Cyber_ » 28 Oct 2019, 07:05

hi enesbcs,

do you think it would be possible and a good idea to have instead of switches for the relay's also toggles? so if on and I call e.g. control?cmd=relay,1,2 it switches relay from 1 to 0 and vice-versa?

thanks and best regards

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

Re: Serial MCU controlled relay/switch

#327 Post by enesbcs » 28 Oct 2019, 08:40

DirkB19 wrote:
27 Oct 2019, 20:38
SendToHTTP 192.168.2.134/control?cmd=relay,1,1
According the Wiki the syntax more like this:
SendToHTTP 192.168.2.134,80,/control?cmd=relay,1,1
In case it is not working, try to urlencode the last part:
SendToHTTP 192.168.2.134,80,%2Fcontrol%3Fcmd%3Drelay%2C1%2C1%20

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

Re: Serial MCU controlled relay/switch

#328 Post by enesbcs » 28 Oct 2019, 08:43

_Cyber_ wrote:
28 Oct 2019, 07:05
do you think it would be possible and a good idea to have instead of switches for the relay's also toggles? so if on and I call e.g. control?cmd=relay,1,2 it switches relay from 1 to 0 and vice-versa?
I do not know if it is a good idea, but it is possible to develop, as the plugin maintaining the current state, so it can invert state.

DirkB19
Normal user
Posts: 2
Joined: 27 Oct 2019, 20:29

Re: Serial MCU controlled relay/switch

#329 Post by DirkB19 » 28 Oct 2019, 17:39

enesbcs wrote:
28 Oct 2019, 08:40
DirkB19 wrote:
27 Oct 2019, 20:38
SendToHTTP 192.168.2.134/control?cmd=relay,1,1
According the Wiki the syntax more like this:
SendToHTTP 192.168.2.134,80,/control?cmd=relay,1,1
In case it is not working, try to urlencode the last part:
SendToHTTP 192.168.2.134,80,%2Fcontrol%3Fcmd%3Drelay%2C1%2C1%20
OK, thanks !!
SendToHTTP 192.168.2.134,80,/control?cmd=relay,1,1 works !
I thought I had tried this syntax before and it didn't work but now it just works. Great :D
(I must have forgotten some comma or some slash before)

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

Re: Serial MCU controlled relay/switch

#330 Post by enesbcs » 28 Oct 2019, 18:27

_Cyber_ wrote:
28 Oct 2019, 07:05
I call e.g. control?cmd=relay,1,2 it switches relay from 1 to 0 and vice-versa?
I've added this simple code to the relay block, i guess it will be enough.

Code: Select all

            if (event->Par2 == 2) { // toggle
              rcmd = 1-UserVar[(varIndex + rnum)];
            }
Attachments
ESPEasy_P165_191028.zip
ESPEasy P165 192028
(882.27 KiB) Downloaded 19 times

Micha_he
Normal user
Posts: 79
Joined: 07 Feb 2018, 19:14

Re: Serial MCU controlled relay/switch

#331 Post by Micha_he » 29 Oct 2019, 10:19

Indicates the file name 'ESPEasy_P165_191028.zip' that you use the sourcecode from this date or only the compile-date ?

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

Re: Serial MCU controlled relay/switch

#332 Post by enesbcs » 29 Oct 2019, 10:27

Micha_he wrote:
29 Oct 2019, 10:19
Indicates the file name 'ESPEasy_P165_191028.zip' that you use the sourcecode from this date or only the compile-date ?
Its only compile time. Sources after 20181231 will not compile with P165.

_Cyber_
Normal user
Posts: 7
Joined: 20 Oct 2019, 09:46

Re: Serial MCU controlled relay/switch

#333 Post by _Cyber_ » 29 Oct 2019, 20:12

enesbcs wrote:
28 Oct 2019, 18:27
_Cyber_ wrote:
28 Oct 2019, 07:05
I call e.g. control?cmd=relay,1,2 it switches relay from 1 to 0 and vice-versa?
I've added this simple code to the relay block, i guess it will be enough.

Code: Select all

            if (event->Par2 == 2) { // toggle
              rcmd = 1-UserVar[(varIndex + rnum)];
            }
works, awesome, thank you! :-)
the relays will control my living room lights - as I have already two multiway switches (3-way switch it is called in english I think) I can now install the relay-module as 4-way-switch at the lamp - and leave the switches in the wall like they are. :-)
kind of smart-home with legacy switches. :lol:

best regards

_Cyber_
Normal user
Posts: 7
Joined: 20 Oct 2019, 09:46

Re: Serial MCU controlled relay/switch

#334 Post by _Cyber_ » 31 Oct 2019, 19:01

hi,

anybody ever tried to remove the LEDs of the LCTech board? Are they needed for the circuit anywhere or is it save to remove?

somebody also tried to rectify the MCU state regarding the blinking green LED?

Have a great Haloween :D

BR
Alois

_Cyber_
Normal user
Posts: 7
Joined: 20 Oct 2019, 09:46

Re: Serial MCU controlled relay/switch

#335 Post by _Cyber_ » 10 Nov 2019, 21:38

hi,

I am trying to use the rules-part to disable a relay after a specific time.

But, how can I switch the relays with rules?

in the log I can read:
SerSW : SetSwitch r2:0

but on using this it logs a "unknown command"

e.g.:
on WohnzimmerRelays#Relay2 do
if [WohnzimmerRelays#Relay2]=1
SetSwitch r1:1
endif
endon

leads to:

286521934: EVENT: WohnzimmerRelays#Relay2=1.00
286521946: ACT : SetSwitch r1:1
286521949: Command: setswitch
286521949: Command unknown: 'setswitch'

I tried also with "SendToHTTP" but then it does not do anything, so even no ACT logline is printed - have tried it also with url encoded part - but i think the issue is that SendToHttp maybe does not like to send commands to itself and that's wha it is not working?

Any ideas?

Thanks! :-)

BR
Alois

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

Re: Serial MCU controlled relay/switch

#336 Post by enesbcs » 10 Nov 2019, 21:59

_Cyber_ wrote:
10 Nov 2019, 21:38
I am trying to use the rules-part to disable a relay after a specific time.
Basic commands are written in the first post in this thread.
All commands are documented inside the source code header:
https://github.com/enesbcs/ESPEasyPlugi ... Switch.ino
"ACT : SetSwitch r1:1" is debug information only, "relay" is the command that you used before...

List of commands :
- relay,[relay_number],[status]
Set specific relay (0-3) to status (0/1)

- relaypulse,[relay_number],[status],[delay]
Pulse specific relay for DELAY millisec with STATUS state, than return to inverse state

- ydim,[DIM_VALUE]
Set DIM_VALUE to Tuya dimmer switch (value can be 0-255, no range check!)
Of course, only the Tuya dimmer can do it... dim value can be read from plugin values.
There are no checks for is it state on or off.

Command Examples :
- /control?cmd=relay,0,1
Switch on first relay

- /control?cmd=relay,0,0
Switch off first relay

- /control?cmd=relay,1,1
Switch on second relay

- /control?cmd=relay,1,0
Switch off second relay

- /control?cmd=relaypulse,0,1,500
Set first relay to ON for 500ms, than stay OFF

- /control?cmd=relaypulse,0,0,1000
Set first relay to OFF for 1s, than stay ON

- /control?cmd=ydim,255
Set dimmer to MAX value

- /control?cmd=ydim,25
Set dimmer to ~10%

Post Reply

Who is online

Users browsing this forum: No registered users and 10 guests