Serial MCU controlled relay/switch

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
rira2005
Normal user
Posts: 30
Joined: 25 Jun 2017, 21:09

Re: Serial MCU controlled relay/switch

#11 Post by rira2005 » 05 Jul 2017, 08:35

HI

the new image(for the sonoff dual) is working, relays are set on/off!
Perfect work, many thanks.

but i get no status in domoticz, if i set the relay manally (with the the
ON command:
http://ESPEASY_IP/control?cmd=relay,1,1
The OFF command:
http://ESPEASY_IP/control?cmd=relay,1,0)
commands...
tried it with the extra switch trick. but didnt works.
any idea?

What can i do to help you?

tia
raphael

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

#12 Post by enesbcs » 05 Jul 2017, 12:41

rira2005 wrote: 05 Jul 2017, 08:35 HI
the new image(for the sonoff dual) is working, relays are set on/off!
...
but i get no status in domoticz, if i set the relay manally (
Thank you for your feedback.

Did you create the rules? Please be careful with the relay names, first relay is "Relay0"
If you named your SerSwitch module for example to "sonoff", it's 1st relay named "Relay0", 2nd relay named "Relay1", the 1st dummy switch domoticz idx=2, the 2nd dummy switch idx=3, the following rules needed:

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

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

Sadly i do not find any other way, to use multiple domoticz idx numbers from one plugin - to do MQTT publishing. Explicit "Publish" command can only be used from rules, if i understand correctly the ESPEasy documentation.

In theory Sonoff Dual reports it's state to ESP with the same serial packets, as the ESP sent to it. Could you please copy from Tools->Log what is happening exactly when you do switching? If Sonoff reports back, the log will be: "SW: State r0:0" or "SW: State r0:1". If only the set command logged, the log will be: "SW: SetSwitch r0,0" or "SW: SetSwitch r0,1".

In case that the "State" log line do not show, i attach an updated image with an extra Senddata line after SetSwitch, which - in theory - will trigger the Relay0/Relay1 changes to the rule engine.
Last edited by enesbcs on 20 Aug 2017, 18:09, edited 1 time in total.

rira2005
Normal user
Posts: 30
Joined: 25 Jun 2017, 21:09

Re: Serial MCU controlled relay/switch

#13 Post by rira2005 » 18 Jul 2017, 22:51

Hello

Sorry for my late answer was an vacation. Soon testet your last image.
same as before.

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

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

in domoticz named it "relay0" with idx 48 and "relay1" with idx 49.

with mqttlens i see NO pubilsh messages when i switch the relay0 or relay1 on/off!

the log reports :
2698474 : EVENT: sonoff#Relay1=0.00
2698486 : ACT : Publish domoticz/in,{"idx":49,"nvalue":0,"svalue":""}
2698504 : EVENT: sonoff#Relay2=0.00
2698531 : SW : SetSwitch r0:1
2701637 : EVENT: sonoff#Relay0=0.00
2701644 : ACT : Publish domoticz/in,{"idx":48,"nvalue":0,"svalue":""}
2701668 : EVENT: sonoff#Relay1=0.00
2701679 : ACT : Publish domoticz/in,{"idx":49,"nvalue":0,"svalue":""}
2701697 : EVENT: sonoff#Relay2=0.00
2701725 : SW : SetSwitch r0:0

any idea?

Many thanks
Raphael

rira2005
Normal user
Posts: 30
Joined: 25 Jun 2017, 21:09

Re: Serial MCU controlled relay/switch

#14 Post by rira2005 » 18 Jul 2017, 23:31

Hi
One Info more.

somtime the mqtt state works in domoticz.... but cant find when.

Only see in the logfile from easyesp:
4765500 : MQTT : Connected to broker
4765501 : Subscribed to: domoticz/out
4787094 : MQTT : Ignored too big message
4794470 : WD : Uptime 77 ConnectFailures 120 FreeMem 22992
4824471 : WD : Uptime 78 ConnectFailures 119 FreeMem 23256
4824471 : MQTT : Connection lost
4825503 : MQTT : Connected to broker
4825504 : Subscribed to: domoticz/out
4847203 : MQTT : Ignored too big message

Using standard mqtt broker (mosquito 1.4.12).

Next:
And tried to test the send2http in the rules
on sonoff#Relay0 do
if [sonoff#Relay0]=0
SendToHTTP 192.168.253.11,80,/json.htm?type=command&param=switchlight&idx=50&switchcmd=Off
else
SendToHTTP 192.168.253.11,80,/json.htm?type=command&param=switchlight&idx=50&switchcmd=On
endif
endon

But every time the rules were cut at the first "&", i think a parser error. tested it with an other easyesp there is no problem with adding the rule....

May that helps you.
tia
raphael

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

#15 Post by enesbcs » 19 Jul 2017, 00:31

rira2005 wrote: 18 Jul 2017, 23:31 And tried to test the send2http in the rules
on sonoff#Relay0 do
if [sonoff#Relay0]=0
SendToHTTP 192.168.253.11,80,/json.htm?type=command&param=switchlight&idx=50&switchcmd=Off
else
SendToHTTP 192.168.253.11,80,/json.htm?type=command&param=switchlight&idx=50&switchcmd=On
endif
endon

But every time the rules were cut at the first "&", i think a parser error. tested it with an other easyesp there is no problem with adding the rule....
It maybe related to ESPEasy Mega dev10 version Domoticz bug, in dev11 it is fixed.
https://github.com/letscontrolit/ESPEasy/releases

I compiled with new dev11, but i see some strange characters on the web GUI.. even so the MQTT and Domoticz connection seems flawless.
Last edited by enesbcs on 20 Aug 2017, 18:09, edited 1 time in total.

rira2005
Normal user
Posts: 30
Joined: 25 Jun 2017, 21:09

Re: Serial MCU controlled relay/switch

#16 Post by rira2005 » 02 Aug 2017, 20:39

HI

Works Perfect! yet i get the mqtt messages!

MANY THANKS for your work! --> should be added to the EASYESP Libary.

One Question : which "gpio" command i need to use it in rules ...
like :
On toogle-r0 do
sonoff#Relay0=1
timerSet 1,5
endon

on Rules#Timer=1 do
sonoff#Relay0=0
endon

need a one second pulse!

many thanks.
Rira

rira2005
Normal user
Posts: 30
Joined: 25 Jun 2017, 21:09

Re: Serial MCU controlled relay/switch

#17 Post by rira2005 » 03 Aug 2017, 07:31

Forget my last post it allready made it.

relay,0,1 (relay1 on)
relay,0,0 (relay1 off)

relay,1,1 (relay2 on)
relay,1,0 (relay2 off)

But may you can compile a new version without the "dev" digtis in the webinterface for me?

many thanks. RR

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

#18 Post by enesbcs » 04 Aug 2017, 07:21

rira2005 wrote: 03 Aug 2017, 07:31

But may you can compile a new version without the "dev" digtis in the webinterface for me?

many thanks. RR
Thank you, for testing it. In the meantime i also win a Sonoff Dual for 8$ i hope it will arrive from China soon. :)
I removed the development bit from the plugin and from espeasy.ino,i hope it's enough to remove the dev digits.

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

#19 Post by enesbcs » 20 Aug 2017, 18:14

rira2005 wrote: 03 Aug 2017, 07:31 But may you can compile a new version without the "dev" digtis in the webinterface for me?
I've get rid of the 'dev' digits, it's in fact in the webserver.ino for some reason, the numbers were the length of the written chunks.. i do not know what was the purpose, commented out the lines doing it and compiled, the resulted binaries attached in the first post of this thread. I've done some cleanup in thread, so every other uploads deleted, only the latest can be downloaded. (It is not based on the dev11, but on the github ESPEasy Mega source)
'ESPEasy.bin.serialswitch.zip'

PS.: My Sonoff Dual finally arrived from China, tested and it works! :)

rira2005
Normal user
Posts: 30
Joined: 25 Jun 2017, 21:09

Re: Serial MCU controlled relay/switch

#20 Post by rira2005 » 31 Aug 2017, 13:55

hi

yes me too. works fine! Many Thanks for your work.

One Question more...
Bought this ESP8266 5 V WiFi relaismodul in china
https://de.aliexpress.com/item/ESP8266- ... 0.0.5Thz2C
it also works with a serial controled MCU... May you have a idea to get it work with easyesp?

Tia
Raphael

papperone
Normal user
Posts: 497
Joined: 04 Oct 2016, 23:16

Re: Serial MCU controlled relay/switch

#21 Post by papperone » 31 Aug 2017, 15:19

rira2005 wrote: 31 Aug 2017, 13:55 hi

yes me too. works fine! Many Thanks for your work.

One Question more...
Bought this ESP8266 5 V WiFi relaismodul in china
https://de.aliexpress.com/item/ESP8266- ... 0.0.5Thz2C
it also works with a serial controled MCU... May you have a idea to get it work with easyesp?

Tia
Raphael
That's not wokring with serial but it's a plain old ESP-01 module with 1Mb of memory.
It can potentially run R12o or maybe R148 but defintely not V2.0.0 (or at least without loosing OTA functionality).
If you are good at soldering you can upgrade the memory chip to 4Mb and give this module a new life :D
My TINDIE Store where you can find all ESP8266 boards I manufacture --> https://www.tindie.com/stores/GiovanniCas/
My Wiki Project page with self-made PCB/devices --> https://www.letscontrolit.com/wiki/inde ... :Papperone

Shardan
Normal user
Posts: 1156
Joined: 03 Sep 2016, 23:27
Location: Bielefeld / Germany

Re: Serial MCU controlled relay/switch

#22 Post by Shardan » 31 Aug 2017, 16:34

papperone wrote: 31 Aug 2017, 15:19
That's not wokring with serial but it's a plain old ESP-01 module with 1Mb of memory.
It can potentially run R12o or maybe R148 but defintely not V2.0.0 (or at least without loosing OTA functionality).
If you are good at soldering you can upgrade the memory chip to 4Mb and give this module a new life :D
The serial MCU is the 8-pin STC chip on the baseboard connected to a standard ESP-01.
You can see the chip left of the ESP's antenna on the base PCB int he first picture.

The 1MB can use 2.0.0, OTA works if you use a two step upgrade as described in the Wiki.
It just can't take a direct update from one 2.00 to another 2.000 version.

I'd try to remove the STC chip and switch relay directly from an ESP's GPIO and leave the flash rom untouched...
For just a relay and the limited GPIO's of an ESP-01 the ESPEasy-version and updating is nothing i'd take too much care of.

Regards
Shardan
Regards
Shardan

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

#23 Post by enesbcs » 31 Aug 2017, 17:24

rira2005 wrote: 31 Aug 2017, 13:55 Bought this ESP8266 5 V WiFi relaismodul in china
https://de.aliexpress.com/item/ESP8266- ... 0.0.5Thz2C
it also works with a serial controled MCU... May you have a idea to get it work with easyesp?
I am sure that it can be done. But first we need to know the commands, that the ESP-01 is sending to drive the relay ON/OFF state.

I see the serial speed is: 9600,8,1,0,0.

And i've found a fantastic article by makerrelay:
https://www.hackster.io/makerrelay/esp8 ... ome-e8a437

According to it:
A00101A2 open relay,
A00100A1 closed relay

If you're willing to try, i can make a test binary with the above commands, but there is no guarantee. :)

Update: attached 1M/128k SPIFFS for black ESP-01
Last edited by enesbcs on 26 Sep 2017, 19:53, 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

#24 Post by enesbcs » 19 Sep 2017, 19:34

enesbcs wrote: 31 Aug 2017, 17:24 If you're willing to try, i can make a test binary with the above commands, but there is no guarantee. :)
Update: attached 1M/128k SPIFFS for black ESP-01
There are 8 downloads, if anyone had time to try it, please let me know the results. :)
Last edited by enesbcs on 26 Sep 2017, 19:52, edited 1 time in total.

cmcooper123
New user
Posts: 4
Joined: 25 Sep 2017, 09:59

Re: Serial MCU controlled relay/switch

#25 Post by cmcooper123 » 25 Sep 2017, 12:42

I wasn't able to get it working with the test binary but with ESPEasy I was able to make a Serial server with these settings and was able to turn the relay off and on using these commands from my linux computer :D

Code: Select all

echo -n -e '\xA0\x01\x01\xA2' | nc -q 0 192.168.1.50 8080
echo -n -e '\xA0\x01\x00\xA1' | nc -q 0 192.168.1.50 8080

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

#26 Post by enesbcs » 25 Sep 2017, 23:09

cmcooper123 wrote: 25 Sep 2017, 12:42 I wasn't able to get it working with the test binary but with ESPEasy I was able to make a Serial server with these settings and was able to turn the relay off and on using these commands from my linux computer :D

Code: Select all

echo -n -e '\xA0\x01\x01\xA2' | nc -q 0 192.168.1.50 8080
echo -n -e '\xA0\x01\x00\xA1' | nc -q 0 192.168.1.50 8080
Thanx, it is very interesting, the init sequence that i used in the plugin is the same:
Serial.begin(9600, SERIAL_8N1);

The relay off command "/control?cmd=relay,0,0" executes:
Serial.write(0xA0);
Serial.write(0x01);
Serial.write(0x00);
Serial.write(0xA1);

The relay on command "/control?cmd=relay,0,1" executes:
Serial.write(0xA0);
Serial.write(0x01);
Serial.write(0x01);
Serial.write(0xA2);

So in theory it should work. It is implemented in a very similar way, that the Sonoff Dual works, maybe the ESP chip is an 512k module? Did the binary starts up at all? Did the log said anything? What ESPEasy version did you use?

cmcooper123
New user
Posts: 4
Joined: 25 Sep 2017, 09:59

Re: Serial MCU controlled relay/switch

#27 Post by cmcooper123 » 25 Sep 2017, 23:26

What I got working was with the binary you provided, I have the 1mb model, I didn't see anything in the logs, I might have configured the plugin wrong "/control?cmd=relay,0,1" loads as a blank page

cmcooper123
New user
Posts: 4
Joined: 25 Sep 2017, 09:59

Re: Serial MCU controlled relay/switch

#28 Post by cmcooper123 » 26 Sep 2017, 12:57

OK I got "/control?cmd=relay,0,1" to work I had to load the page twice because the relay needs to be sent "A00101A2" twice for it to turn on sometimes

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

#29 Post by enesbcs » 26 Sep 2017, 19:52

cmcooper123 wrote: 26 Sep 2017, 12:57 OK I got "/control?cmd=relay,0,1" to work I had to load the page twice because the relay needs to be sent "A00101A2" twice for it to turn on sometimes
Interesting, maybe serial logging is enabled in Espeasy?
But can be fixed, new binary attached with command doubling. :)

Anyway the proposed Espeasy setup:
Tools->Advanced->Serial log Level: 0
Tools->Advanced->Enable Serial port: enabled
Tools->Advanced->Rules:enabled
Last edited by enesbcs on 07 Oct 2017, 14:21, edited 1 time in total.

cmcooper123
New user
Posts: 4
Joined: 25 Sep 2017, 09:59

Re: Serial MCU controlled relay/switch

#30 Post by cmcooper123 » 26 Sep 2017, 20:33

I thought about serial logging as well but I think the problem is to do with the relay not the ESP,
because it didn't always turn on the first time when I sent the command from my computer using serial and also when I was using different firmware,
but with firmware you sent it seems to work every time.
Also I didn't need to have the "Enable Serial port" option enabled for it to function.
Thanks for this, hopefully these additions will be merged to the git. :D

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

#31 Post by enesbcs » 27 Sep 2017, 21:50

cmcooper123 wrote: 26 Sep 2017, 20:33 I thought about serial logging as well but I think the problem is to do with the relay not the ESP,
because it didn't always turn on the first time when I sent the command from my computer using serial and also when I was using different firmware,
but with firmware you sent it seems to work every time.
Also I didn't need to have the "Enable Serial port" option enabled for it to function.
Thanks for this, hopefully these additions will be merged to the git. :D
Thank you for testing it, i've uploaded the source to github.
Just noticed that the P165 plugin found it's way to the official ESPEasyPluginPlayground thanx to psy0rz. :) I started a new pull request.

Mattley30
New user
Posts: 4
Joined: 04 Oct 2017, 17:41

Re: Serial MCU controlled relay/switch

#32 Post by Mattley30 » 04 Oct 2017, 18:00

Hi enesbcs
Congratulations on your job, I used your plugin successfully with domoticz. Now I have trouble with the rules for 4/5 days that I'm doing tests but not successful so I wanted to write to you.
My project as I think others is to use the Sonoff Dual for the blinds, and make sure that when I turn on relay0 the relay1 is turned off, and when I get the relay1, the relay0 is turned off, using pin “Button 0” and “Button1” present on the Sonoff dual.
I tried different rules and this seemed to me the simplest and most logical but it does not work:

on sonoff#relay0 do
if [sonoff#relay0]=1
relay1,0
endif
endon

on sonoff#relay1 do
if [sonoff#relay1]=1
relay0,0
endif
endon

Could you give me some help?

Thanks
P.s. Sorry for my english

Mattley30

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

#33 Post by enesbcs » 04 Oct 2017, 20:44

Mattley30 wrote: 04 Oct 2017, 18:00 Hi enesbcs
Congratulations on your job, I used your plugin successfully with domoticz. Now I have trouble with the rules for 4/5 days that I'm doing tests but not successful so I wanted to write to you.
My project as I think others is to use the Sonoff Dual for the blinds, and make sure that when I turn on relay0 the relay1 is turned off, and when I get the relay1, the relay0 is turned off, using pin “Button 0” and “Button1” present on the Sonoff dual.
I tried different rules and this seemed to me the simplest and most logical but it does not work:

on sonoff#relay0 do
if [sonoff#relay0]=1
relay1,0
endif
endon

on sonoff#relay1 do
if [sonoff#relay1]=1
relay0,0
endif
endon

Could you give me some help?

Thanks
P.s. Sorry for my english

Mattley30
Thanx! Your english is at least as understandable as mine. Currently my Dual is in a box somewhere, but i will do my best to search it and try at the weekend. :) Can you try the following?
//
On sonoff#relay0=1 do
relay,1,0
Endon

On sonoff#relay1=1 do
relay,0,0
Endon
//

If it is not working i can implement an exluding working mode for blinds to the Dual, that can be choosed in the plugin options.. in that mode, switching on a relay will automatically switch off the other one instantly.
When the rules method used, i think there will always be a little time, when both relays states are ON before the other one go OFF.

Mattley30
New user
Posts: 4
Joined: 04 Oct 2017, 17:41

Re: Serial MCU controlled relay/switch

#34 Post by Mattley30 » 05 Oct 2017, 14:44

hi
I did a test with the rules you wrote in your post, but it does not work, it does not switch relay0,1 and relay1,0, I even noticed that with this rule when the Button0 or the Button1 is active the dual janeff crashes and after a few seconds restarts.

The solution to include in your plugin the possibility of using dual with the blinds seems great, if you can be of assistance i have done tests on domoticz using the actions to turn off the switch between one relay and the other 1 second time between switching off and on is a good delay.

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

#35 Post by enesbcs » 05 Oct 2017, 19:40

Mattley30 wrote: 05 Oct 2017, 14:44 it does not switch relay0,1 and relay1,0, I even noticed that with this rule when the Button0 or the Button1 is active the dual janeff crashes and after a few seconds restarts.
relay1,0 is not a command
relay1,0, is not a command
relay,1,0 is a command

Are you sure that you are using it correctly?

Anyway the implementation of exclusive mode is not so complicated i will try it at the weekend.

Mattley30
New user
Posts: 4
Joined: 04 Oct 2017, 17:41

Re: Serial MCU controlled relay/switch

#36 Post by Mattley30 » 06 Oct 2017, 08:13

enesbcs wrote: 05 Oct 2017, 19:40
Mattley30 wrote: 05 Oct 2017, 14:44 it does not switch relay0,1 and relay1,0, I even noticed that with this rule when the Button0 or the Button1 is active the dual janeff crashes and after a few seconds restarts.
relay1,0 is not a command
relay1,0, is not a command
relay,1,0 is a command

Are you sure that you are using it correctly?

Anyway the implementation of exclusive mode is not so complicated i will try it at the weekend.
the commands I used are relay,0,1 etc.
I made a copy and paste the rules you wrote in your previous post. :P

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

#37 Post by enesbcs » 07 Oct 2017, 09:56

Mattley30 wrote: 06 Oct 2017, 08:13 the commands I used are relay,0,1 etc.
I made a copy and paste the rules you wrote in your previous post. :P
Now i understand the problem. This plugin has 3 return value, and everytime when either is changing returns all three value... so if the first relay is on, and the second is also on there were a little endless loop, after little fixing now only the first rule runs, second never fired.. so i do not think that it can be done with rules - easily.

Anyway i implemented blinds mode directly in the plugin, tested with my Dual, it works.

Also fixed the button0 and button1 support (panel pins) and the third relay "Relay2" now holds the value of the WiFi on-board button of the Dual. This button do nothing alone (no relay behind), but can be used in rules, also thinking to implement in the plugin such as "Relay0 ON/OFF", "Relay1 ON/OFF", "Relay0+1 ON/OFF" functions.. look forward to the ideas. :)

Tested with every possible scenario that crossed my mind.. currently there are no delay in case of switching, please let me know it it is needed.
Last edited by enesbcs on 07 Oct 2017, 14:22, edited 1 time in total.

Mattley30
New user
Posts: 4
Joined: 04 Oct 2017, 17:41

Re: Serial MCU controlled relay/switch

#38 Post by Mattley30 » 07 Oct 2017, 12:58

Hi,
Your new plugin with the solution to include the blinds works fine. In fact with this solution there is not even a need to put a delay time between one switch and the other because the communications with domoticz work well and the blind engine has no problems.
Congratulations still on your job, I think other people will use it well.
Now I do other tests with actions on domoticz for up, down and stop.

papperone
Normal user
Posts: 497
Joined: 04 Oct 2016, 23:16

Re: Serial MCU controlled relay/switch

#39 Post by papperone » 07 Oct 2017, 13:36

I think this idea of dual relays control for blinds should be implemented in a more generic plugin.
Like you can select the output (SonoffDual, or 2 GPIOs controlling to normal relays) and have all the logic applied when UP/DOWN (or left/right in case of curtains!) commands are sent to it.
We can call this "Blind Control" plugin... :D

PS: I do not have personally any automated blinds as I dont' have actually blinds in my house.... But my wife has always asked me to automate our curtains (and the logic should be similar).
My TINDIE Store where you can find all ESP8266 boards I manufacture --> https://www.tindie.com/stores/GiovanniCas/
My Wiki Project page with self-made PCB/devices --> https://www.letscontrolit.com/wiki/inde ... :Papperone

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

#40 Post by enesbcs » 07 Oct 2017, 14:14

Mattley30 wrote: 07 Oct 2017, 12:58 Hi,
Your new plugin with the solution to include the blinds works fine. In fact with this solution there is not even a need to put a delay time between one switch and the other because the communications with domoticz work well and the blind engine has no problems.
Congratulations still on your job, I think other people will use it well.
Now I do other tests with actions on domoticz for up, down and stop.
Thank you for testing! Binary attached to first post of this thread, source code uploaded to github!
Last edited by enesbcs on 07 Oct 2017, 14:23, 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

#41 Post by enesbcs » 07 Oct 2017, 14:16

papperone wrote: 07 Oct 2017, 13:36 I think this idea of dual relays control for blinds should be implemented in a more generic plugin.
Like you can select the output (SonoffDual, or 2 GPIOs controlling to normal relays) and have all the logic applied when UP/DOWN (or left/right in case of curtains!) commands are sent to it.
We can call this "Blind Control" plugin... :D

PS: I do not have personally any automated blinds as I dont' have actually blinds in my house.... But my wife has always asked me to automate our curtains (and the logic should be similar).
Currently i have no blinds at all, but not a bad idea. Anyway the source code is uploaded to github. :)

papperone
Normal user
Posts: 497
Joined: 04 Oct 2016, 23:16

Re: Serial MCU controlled relay/switch

#42 Post by papperone » 08 Oct 2017, 12:41

@enesbcs: watch out that your plugin cannot work properly in all conditions due to limitation design of ESPEasy PLUGIN_WRITE call.
Basically while executing PLUGIN_WRITE you have 2 limits:
1) only first device of the same "plugin type" will execute the commands sent (in this case not relevant as it makes no sense to define more than one :) )
2) when PLUGIN_WRITE is called the EventStruc of the device is not passed interely so you cannot be sure you can access the right Device parameters :(
To test point 2 you can define something as device 1, then setup P165 as device 2, and play a round and you will see a loooooot of issues when sending commands (PLUG_WRITE) :o
It shoudl be as well sufficient while device works to reboot the ESP and try to send commands without doing anythign else before and commands wont' be executed most probably...
My TINDIE Store where you can find all ESP8266 boards I manufacture --> https://www.tindie.com/stores/GiovanniCas/
My Wiki Project page with self-made PCB/devices --> https://www.letscontrolit.com/wiki/inde ... :Papperone

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

#43 Post by enesbcs » 09 Oct 2017, 19:24

papperone wrote: 08 Oct 2017, 12:41 @enesbcs: watch out that your plugin cannot work properly in all conditions due to limitation design of ESPEasy PLUGIN_WRITE call.
Basically while executing PLUGIN_WRITE you have 2 limits:
1) only first device of the same "plugin type" will execute the commands sent (in this case not relevant as it makes no sense to define more than one :) )
2) when PLUGIN_WRITE is called the EventStruc of the device is not passed interely so you cannot be sure you can access the right Device parameters :(
To test point 2 you can define something as device 1, then setup P165 as device 2, and play a round and you will see a loooooot of issues when sending commands (PLUG_WRITE) :o
It shoudl be as well sufficient while device works to reboot the ESP and try to send commands without doing anythign else before and commands wont' be executed most probably...
On point 1: I see, but P165 is made for specific devices, that hardwired to hardware UART, i can not think any real world scenario, when two of the P165 plugin will be necessery on the same physical device, on the same time. In fact, if there are any method to disable multiple usage of the plugin, i will do it. :)

On point 2: it can be a problem, i tought that Eventstruct *event is declared in global scope, so i do not expect any problem.. thank you for pointing to it, i think i fixed it with global variables - ugly but works- tested with sonoff dual 165 as second device. Binaries updated in first post.
https://github.com/enesbcs/ESPEasyPlugi ... Switch.ino

papperone
Normal user
Posts: 497
Joined: 04 Oct 2016, 23:16

Re: Serial MCU controlled relay/switch

#44 Post by papperone » 09 Oct 2017, 21:07

Thanks to the "God" of ESPEasy we have a neat solution here --> https://github.com/letscontrolit/ESPEas ... -335028103
So defintely it's not a blocking limit, just required a bit of code to access proper device parameters specially useful when you could have more than one device of the same plugin (not your case thou)...
My TINDIE Store where you can find all ESP8266 boards I manufacture --> https://www.tindie.com/stores/GiovanniCas/
My Wiki Project page with self-made PCB/devices --> https://www.letscontrolit.com/wiki/inde ... :Papperone

mcfarlde
New user
Posts: 1
Joined: 20 Oct 2017, 13:05

Re: Serial MCU controlled relay/switch

#45 Post by mcfarlde » 20 Oct 2017, 13:09

Can you share the binary, I have the same boards.

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

#46 Post by enesbcs » 20 Oct 2017, 19:11

mcfarlde wrote: 20 Oct 2017, 13:09 Can you share the binary, I have the same boards.
Yes of course, the binary is always being uploaded to the first post of this thread, and the source is uploaded to the github.
download/file.php?id=1581

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

#47 Post by enesbcs » 17 Nov 2017, 10:55

I've compiled the binary against ESP8266 Arduino Core 2.4.0 rc2, attached to the first post of this thread:
download/file.php?id=1715

saundersrg
New user
Posts: 5
Joined: 13 Dec 2017, 10:18

Re: Serial MCU controlled relay/switch

#48 Post by saundersrg » 13 Dec 2017, 13:26

Perhaps I've missed the boat completely, but been tearing my hair out with a Sonoff Dual V2.0. Between ESPEasy, ESPurna, and Tasmota, none of them work. Other people seem to be having the same issue on other forums.

I don't know if maybe its a slight difference in the boards, but I just cannot get the relays to fire no matter what I do. Anyone else seeing this issue?

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

Re: Serial MCU controlled relay/switch

#49 Post by grovkillen » 13 Dec 2017, 13:34

saundersrg wrote: 13 Dec 2017, 13:26 Perhaps I've missed the boat completely, but been tearing my hair out with a Sonoff Dual V2.0. Between ESPEasy, ESPurna, and Tasmota, none of them work. Other people seem to be having the same issue on other forums.

I don't know if maybe its a slight difference in the boards, but I just cannot get the relays to fire no matter what I do. Anyone else seeing this issue?
If you take a picture of the board we might see if the ESP MCU is doing the actual pulling of the relay or if they (itead) has started to put in a middle hand MCU which is controlled via the ESP MCU.

EDIT: sorry, I see that it is in fact discussed in this thread. It i a serial controlled MCU. So how are you trying to make the relay trigger? Using serial commands?
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
enesbcs
Normal user
Posts: 587
Joined: 18 Jun 2017, 11:02
Location: Békéscsaba, Hungary
Contact:

Re: Serial MCU controlled relay/switch

#50 Post by enesbcs » 13 Dec 2017, 17:16

saundersrg wrote: 13 Dec 2017, 13:26 Perhaps I've missed the boat completely, but been tearing my hair out with a Sonoff Dual V2.0. Between ESPEasy, ESPurna, and Tasmota, none of them work. Other people seem to be having the same issue on other forums.

I don't know if maybe its a slight difference in the boards, but I just cannot get the relays to fire no matter what I do. Anyone else seeing this issue?
If you have a Sonoff Dual R2 there are no more MCU, relays are directly attached to 8285 GPIO, you have to choose R2 modell in Tasmota, or use GPIO directly in ESPEasy
https://github.com/arendst/Sonoff-Tasmo ... nd-Dual-R2

If you have an old Sonoff Dual, then please read the first post of this thread, and use the binary attached to it. If it is not working for some reason and this board is definitely is not an R2, then you can test with ESPEasy+SER2NET plugin the serial status messages, that this board reply when you short the onboard button0 and button1 pins.

saundersrg
New user
Posts: 5
Joined: 13 Dec 2017, 10:18

Re: Serial MCU controlled relay/switch

#51 Post by saundersrg » 16 Dec 2017, 06:35

enesbcs wrote: 13 Dec 2017, 17:16
If you have a Sonoff Dual R2 there are no more MCU, relays are directly attached to 8285 GPIO, you have to choose R2 modell in Tasmota, or use GPIO directly in ESPEasy
https://github.com/arendst/Sonoff-Tasmo ... nd-Dual-R2

If you have an old Sonoff Dual, then please read the first post of this thread, and use the binary attached to it. If it is not working for some reason and this board is definitely is not an R2, then you can test with ESPEasy+SER2NET plugin the serial status messages, that this board reply when you short the onboard button0 and button1 pins.
[/quote]

Well, from what I've seen it's a V2 not R2. Compiled the binary into Dev 11, no luck. Will try out SER2NET in the next couple of days. Thanks!

saundersrg
New user
Posts: 5
Joined: 13 Dec 2017, 10:18

Re: Serial MCU controlled relay/switch

#52 Post by saundersrg » 16 Dec 2017, 06:37

grovkillen wrote: 13 Dec 2017, 13:34
If you take a picture of the board we might see if the ESP MCU is doing the actual pulling of the relay or if they (itead) has started to put in a middle hand MCU which is controlled via the ESP MCU.

EDIT: sorry, I see that it is in fact discussed in this thread. It i a serial controlled MCU. So how are you trying to make the relay trigger? Using serial commands?
Not able to trigger at all, it's like the relays are disconnected entirely. Have tried 3 different firmwares and none work.

Will try the suggestion of SER2NET and see what I can get.

saundersrg
New user
Posts: 5
Joined: 13 Dec 2017, 10:18

Re: Serial MCU controlled relay/switch

#53 Post by saundersrg » 16 Dec 2017, 07:39

saundersrg wrote: 16 Dec 2017, 06:35
Well, from what I've seen it's a V2 not R2. Compiled the binary into Dev 11, no luck. Will try out SER2NET in the next couple of days. Thanks!
SER2NET sadly returns absolutely nothing. The LED changes on the unit when closing button 0 / 1 jumpers, but the relays themselves don't seem to fire.

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

#54 Post by enesbcs » 16 Dec 2017, 09:50

saundersrg wrote: 16 Dec 2017, 07:39 SER2NET sadly returns absolutely nothing. The LED changes on the unit when closing button 0 / 1 jumpers, but the relays themselves don't seem to fire.
If the relay do not fire when you physically close button jumpers, i think it is simply a faulty one. :(
Was it worked with the original firmware? I always try every Sonoff that i get with the original firmware, before i flash it. Can you post pictures from the panel (back&front)?

mixycsabi
New user
Posts: 1
Joined: 19 Dec 2017, 11:47

Re: Serial MCU controlled relay/switch

#55 Post by mixycsabi » 19 Dec 2017, 11:49

Same situation here...

[Edit]
Sorry, my mistake... I used wrong bin file.
After when I chose a good file, everything works fine :)

saundersrg
New user
Posts: 5
Joined: 13 Dec 2017, 10:18

Re: Serial MCU controlled relay/switch

#56 Post by saundersrg » 29 Dec 2017, 15:21

enesbcs wrote: 16 Dec 2017, 09:50 If the relay do not fire when you physically close button jumpers, i think it is simply a faulty one. :(
Was it worked with the original firmware? I always try every Sonoff that i get with the original firmware, before i flash it. Can you post pictures from the panel (back&front)?
In a sad twist, the dual was the only one that I a) didn't test beforehand and b) didn't dump the original firmware beforehand.

I will perhaps fiddle again sometime, for now it's been packed in a box.

Images here:

Image
Image
Image
Image

Chips to right of ESP8266EX are as follows from what I can see.

XTX
BN25F08
1(?)644Q0R

SIL
F330
B0GAZ
1624+

itanczos
New user
Posts: 4
Joined: 25 Jan 2018, 00:05

Re: Serial MCU controlled relay/switch

#57 Post by itanczos » 25 Jan 2018, 12:24

Hello nesbcs!

Is it possible to use button1 or button2 input for pulse counting? Or is it possible to count impulse with Sonoff Dual?

(Van arra lehetőség, hogy a 2 gomb bemenetet figyeljük és impulzus számlálásra használjuk? Vagy egyéb más lehetőség Sonoff Dual-lal? A lefordított binárisban benne van az impulzus számláló plugin?)

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

#58 Post by enesbcs » 25 Jan 2018, 18:47

itanczos wrote: 25 Jan 2018, 12:24 Hello nesbcs!

Is it possible to use button1 or button2 input for pulse counting? Or is it possible to count impulse with Sonoff Dual?

(Van arra lehetőség, hogy a 2 gomb bemenetet figyeljük és impulzus számlálásra használjuk? Vagy egyéb más lehetőség Sonoff Dual-lal? A lefordított binárisban benne van az impulzus számláló plugin?)
I am not familiar with the P003 Pulse plugin, however, it is compiled in the binary. If P003 is not watching GPIO's but device variables, it can work... but because the serial communication, i doubt that it will be fast.

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

Re: Serial MCU controlled relay/switch

#59 Post by riker1 » 28 Jan 2018, 15:31

@enesbcs,

just to let you knwo lc tech is also available with 2 relais

http://www.chinalctech.com/index.php?_m ... &p_id=1261

mabye you can update your plugin to support 2 releais.

Thanks T

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

#60 Post by enesbcs » 28 Jan 2018, 21:17

riker1 wrote: 28 Jan 2018, 15:31 @enesbcs,
just to let you knwo lc tech is also available with 2 relais

http://www.chinalctech.com/index.php?_m ... &p_id=1261

mabye you can update your plugin to support 2 releais.
Thanks T
Good to know, LCTECH 2 relay support added, i compiled binaries for ESPEasy Mega, R147 and R120 for testing, attached to this post.

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 55 guests