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

#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
New 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: 113
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: 369
Joined: 07 Feb 2018, 19:14
Location: Helmstedt, Germany

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: 587
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: 369
Joined: 07 Feb 2018, 19:14
Location: Helmstedt, Germany

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: 587
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: 369
Joined: 07 Feb 2018, 19:14
Location: Helmstedt, Germany

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: 587
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: 369
Joined: 07 Feb 2018, 19:14
Location: Helmstedt, Germany

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: 587
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: 369
Joined: 07 Feb 2018, 19:14
Location: Helmstedt, Germany

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: 587
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: 369
Joined: 07 Feb 2018, 19:14
Location: Helmstedt, Germany

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: 587
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: 369
Joined: 07 Feb 2018, 19:14
Location: Helmstedt, Germany

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: 369
Joined: 07 Feb 2018, 19:14
Location: Helmstedt, Germany

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: 587
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 908 times

Micha_he
Normal user
Posts: 369
Joined: 07 Feb 2018, 19:14
Location: Helmstedt, Germany

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: 8643
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: 369
Joined: 07 Feb 2018, 19:14
Location: Helmstedt, Germany

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: 8643
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: 587
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 938 times

Micha_he
Normal user
Posts: 369
Joined: 07 Feb 2018, 19:14
Location: Helmstedt, Germany

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
New 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: 113
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: 587
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: 587
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
New 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: 587
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 939 times

Micha_he
Normal user
Posts: 369
Joined: 07 Feb 2018, 19:14
Location: Helmstedt, Germany

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: 587
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: 113
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: 113
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: 113
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: 587
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%

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

Re: Serial MCU controlled relay/switch

#337 Post by _Cyber_ » 11 Dec 2019, 23:13

just to have it said: rock-stable since one month now, working flawless - thank you! :-)

riker1
Normal user
Posts: 344
Joined: 26 Dec 2017, 18:02

Re: Serial MCU controlled relay/switch

#338 Post by riker1 » 12 Dec 2019, 07:59

_Cyber_ wrote: 11 Dec 2019, 23:13 just to have it said: rock-stable since one month now, working flawless - thank you! :-)
...which version are you using?

thanks

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

Re: Serial MCU controlled relay/switch

#339 Post by _Cyber_ » 12 Dec 2019, 08:13

This one: viewtopic.php?p=40308#p40308
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)];
            }

riker1
Normal user
Posts: 344
Joined: 26 Dec 2017, 18:02

Re: Serial MCU controlled relay/switch

#340 Post by riker1 » 12 Dec 2019, 09:45

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)];
            }
Hi

what is the difference between 2 firmware verions?
what dows 128kS stand for?
ESPEasy_P165.1M_128kS_c252.bin

thanks

riker1
Normal user
Posts: 344
Joined: 26 Dec 2017, 18:02

Re: Serial MCU controlled relay/switch

#341 Post by riker1 » 12 Dec 2019, 10:21

Hi

having a problem running the latest firmware on
ESP01 1M

both versions from 20191028.

Code: Select all

10:19:48.228 -> 
10:19:48.228 ->  ets Jan  8 2013,rst cause:2, boot mode:(3,7)
10:19:48.228 -> 
10:19:48.228 -> load 0x4010f000, len 1384, room 16 
10:19:48.228 -> tail 8
10:19:48.228 -> chksum 0x2d
10:19:48.228 -> csum 0x2d
10:19:48.228 -> v8b899c12
10:19:48.228 -> ~ld
10:19:48.335 -> ⸮U102 : 
10:19:48.335 -> 
10:19:48.335 -> 
INIT : Booting version: (custom) (ESP82xx Core 2_5_2, NONOS SDK 2.2.2-dev(c0eb301), LWIP: 2.1.2)
10:19:48.335 -> 103 : INIT : Warm boot #12 - Restart Reason: Exception
10:19:48.335 -> 105 : FS   : Mounting...
10:19:48.335 -> 111 : FS   : Mount successful, used 1255 bytes of 113201
10:19:48.335 -> RESET: Resetting factory defaults... using default settings
10:19:49.332 -> RESET: Warm boot, reset count: 3
10:19:49.332 -> RESET: Too many resets, protecting your flash memory (powercycle to solve this)
10:19:49.368 -> 1119 : CRC  : No program memory checksum found. Check output of crc2.py
10:19:49.368 -> 1127 : FS   : Error while reading/writing config.dat in 709
10:19:49.368 -> 
10:19:49.368 -> PID:0
10:19:49.368 -> Version:0
10:19:49.368 -> INIT : Incorrect PID or version!
10:19:50.361 -> RESET: Resetting factory defaults... using default settings
10:19:51.357 -> RESET: Warm boot, reset count: 3
10:19:51.357 -> RESET: Too many resets, protecting your flash memory (powercycle to solve this)
10:19:51.390 -> 
10:19:51.390 -> Exception (0):
10:19:51.390 -> epc1=0x4000e25d epc2=0x00000000 epc3=0x00000000 excvaddr=0x00000000 depc=0x00000000
10:19:51.390 -> 
10:19:51.390 -> >>>stack>>>
10:19:51.390 -> 
10:19:51.390 -> ctx: cont
10:19:51.390 -> sp: 3ffffd60 end: 3fffffc0 offset: 01a0
10:19:51.390 -> 3fffff00:  40247e3e 00000001 3fff2a3c 40247f35  
10:19:51.390 -> 3fffff10:  00000000 0000001c 00000000 00000003  
10:19:51.390 -> 3fffff20:  3ffef91d 00000001 3fff0aa4 3fff0aa4  
10:19:51.426 -> 3fffff30:  3ffef91d 00000001 3fff0aa4 402427f4  
10:19:51.426 -> 3fffff40:  00000000 0000001c 00000000 40247cde  
10:19:51.426 -> 3fffff50:  4024617a 3ffef8b8 3ffefbd8 40201519  
10:19:51.426 -> 3fffff60:  3ffef91d 3ffef8b8 3ffefbd8 40237be8  
10:19:51.426 -> 3fffff70:  00000000 00000000 ff240000 4024d898  
10:19:51.426 -> 3fffff80:  3fff2824 0030006f ffefeffe feefeffe  
10:19:51.426 -> 3fffff90:  feefeffe feefeffe feefeffe 3fff0bc4  
10:19:51.426 -> 3fffffa0:  3fffdad0 00000000 3fff0b94 40245258  
10:19:51.456 -> 3fffffb0:  feefeffe feefeffe 3ffe8674 40101459  
10:19:51.456 -> <<<stack<<<

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

Re: Serial MCU controlled relay/switch

#342 Post by _Cyber_ » 12 Dec 2019, 10:56

[/quote]

Hi

what is the difference between 2 firmware verions?
what dows 128kS stand for?
ESPEasy_P165.1M_128kS_c252.bin

thanks
[/quote]

1M 128k is for the memory chip on your ESP01.
in my case the original delivered ESP was without SPIFFs (therefore you would need a "PUYA" called image, I do not know if enesbcs has offered latest codebase compiled for PUYA ESPs).
I bought some ESP01 - they normally have 1M_128k soldered storage. I use one of them for the relay switch.

riker1
Normal user
Posts: 344
Joined: 26 Dec 2017, 18:02

Re: Serial MCU controlled relay/switch

#343 Post by riker1 » 12 Dec 2019, 18:29

thanks

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

#344 Post by enesbcs » 12 Dec 2019, 22:18

_Cyber_ wrote: 12 Dec 2019, 10:56 (therefore you would need a "PUYA" called image, I do not know if enesbcs has offered latest codebase compiled for PUYA ESPs).
Latest firmware is based on core 2.5.2 which is natively supports Puya, so no patching is needed. However i do not consider 2.5.2 as a stable release.
riker1 wrote: 12 Dec 2019, 10:21 having a problem running the latest firmware on
Then do a full flash erase before uploading firmware... or use a previous firmware.

Puya safe previous:
download/file.php?id=3976

Older ones with previous (more stable) core:
download/file.php?id=3807

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

Re: Serial MCU controlled relay/switch

#345 Post by _Cyber_ » 20 Dec 2019, 10:48

hi enesbcs,

I am still struggling with rules and the 4ch relay: a thread about is here: viewtopic.php?f=2&t=7215&p=41280#p40640

I tried with rules and I do not get it working, sadly.

on studying _P165_SerSwitch.ino I saw in the header the relaypulse command. It works in general, but during the pulse the ESP is completely blocked.

I think the reason is the "delay" in https://github.com/enesbcs/ESPEasyPlugi ... h.ino#L634 which blocks completely until the time exceeded.

Would there be a possibility to have this in a non-blocking counter?

In my case I tried "control?cmd=relaypulse,1,1,7200000" - this even did not recover after 2 hours, I had to powercycle the module.

Thanks. :-)

BR

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

#346 Post by enesbcs » 20 Dec 2019, 20:34

_Cyber_ wrote: 20 Dec 2019, 10:48 Would there be a possibility to have this in a non-blocking counter?
Yes, relaypulse is works exactly as the gpio pulse command, in this blocking nature.
I've added a new command "relaylongpulse" which needs relay number, state and pulse time _in seconds_ as parameter.

It may work. Or freeze your device, i did not tested it, only compiled. :)
Attachments
ESPEasy_P165_beta.zip
(883.07 KiB) Downloaded 1109 times

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

Re: Serial MCU controlled relay/switch

#347 Post by _Cyber_ » 20 Dec 2019, 23:33

:geek:

Code: Select all

84392: HTTP: relaylongpulse,1,1,7200
84404: EVENT: WohnzimmerRelays#Relay0=0.00
84409: EVENT: WohnzimmerRelays#Relay1=1.00
84413: EVENT: WohnzimmerRelays#Relay2=0.00
84417: EVENT: WohnzimmerRelays#Relay3=0.00
84422: SerSW : SetSwitchPulse r1:1 Pulse for 7200 sec
first try looks promising. will look depper tomorrow. 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

#348 Post by enesbcs » 21 Dec 2019, 09:24

_Cyber_ wrote: 20 Dec 2019, 23:33

Code: Select all

84392: HTTP: relaylongpulse,1,1,7200
84404: EVENT: WohnzimmerRelays#Relay0=0.00
84409: EVENT: WohnzimmerRelays#Relay1=1.00
84413: EVENT: WohnzimmerRelays#Relay2=0.00
84417: EVENT: WohnzimmerRelays#Relay3=0.00
84422: SerSW : SetSwitchPulse r1:1 Pulse for 7200 sec
first try looks promising. will look depper tomorrow. thank you!
It looks fine, but after 7200 sec a "SerSW : SetSwitchPulse r1:1 pulse ended" line also has to be shown. I propose to start testing with smaller numbers. :D

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

Re: Serial MCU controlled relay/switch

#349 Post by _Cyber_ » 21 Dec 2019, 13:12

for sure I did before with 10 seconds and saw there already the "pulse ended" message.

until now i could not see any negative impact or any unexpected behavior. So, in my opinion, commit. :-)
What I missed in documentation and also could not read out in code (as I could not find defines of data types): for pulse and now longpulse what is the max value?

Thank you for your great work!

Best 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

#350 Post by enesbcs » 21 Dec 2019, 16:23

_Cyber_ wrote: 21 Dec 2019, 13:12 What I missed in documentation and also could not read out in code (as I could not find defines of data types): for pulse and now longpulse what is the max value?
I did not documented the limits as i do not know... But as pulse is blocking it is not a very good idea to pulse more than 1 minutes.
For longpulse i use the "setPluginTaskTimer()" function that takes an unsigned long 4,294,967,295 (2^32 - 1) parameter in milliseconds, which means 4294967 seconds alias 49 days. In theory. On the other hand the event->Par3 (that passes delay arguments to plugin) is defined in the ESPEasy core as "int" type which size depends on the compiler but i guess it is an "int32" (signed) so the max value will be 2147483647 which means 24days.

Post Reply

Who is online

Users browsing this forum: No registered users and 33 guests