stefanbode / Sonoff-Tasmota

Provide ESP8266 based itead Sonoff with Web, MQTT and OTA firmware using Arduino IDE, enhanced with I2C options
GNU General Public License v3.0
127 stars 41 forks source link

Sonoff Dual R2 and external switches #117

Closed albertbrufau closed 4 years ago

albertbrufau commented 5 years ago

Hello,

I'm trying to control Sonoff Dual R2 flashed with Tasmota with two external switches.

Firstly, I planned to use GPIO0 and GPIO9 that are available easily with a jumper. But, as I read in the Tasmota's wiki, GPIO0 can't be used with permanent switches (in a restart, it will start in upload mode). GPIO4 and GPIO14 are available but with a tricky direct soldering to Esp.

Also it says that GPIO1 and GPIO3 (TX and RX) should be avoided because of the use of serial connection between ESP8266 and a specific relay controller chip. Also it explains that Dual R2 use ESP8265 and it controls relays directly. So, can I use GPIO3 safely disabling serial log in Dual R2?

Thank you in advance,

Albert

B1G1 commented 5 years ago

Hi, i use GPIO0 and GPIO9, don’t worry about flash mode. If the sonoff restarts for some reason, it will go in flash mode only if in the meanwhile you push the external button.

shaggy72 commented 5 years ago

Hi, i use GPIO0 and GPIO9, don’t worry about flash mode. If the sonoff restarts for some reason, it will go in flash mode only if in the meanwhile you push the external button.

If you use switches (and not push buttons) it could go in flash mode depending on the state of the switch!

albertbrufau commented 5 years ago

Thanks @B1G1, but I want to use a switch like this 1-m-blind-control-with-roller-shutter-switches-1

So may be switched on restart.

Thank you,

titomontes commented 5 years ago

Hello

I also want to use an existinf¡g wall switch, similar to the last one, but with a central "Stop" position:

Where would you connect it?

calcipher49 commented 5 years ago

Hi, I confirm you can use safely GPIO1 and GPIO3 if you disable serial (SerialLog 0). Also you can use GPIO10 if you don't use the internal button, or even GPIO13 if you remove blue led.

stefanbode commented 5 years ago

Thats all fine. Please take care to define the INTERLOCK, even if it looks like this switch does not need it. It is required in the firmware to go to the correct operation mode. Commands with the current implementation are: INTERLOCK 1 INTERLOCK 1,2 first enable and second set the relays for the group

roondar commented 5 years ago

It could be possible to support hold state button ? I try this "rule on button2#state=3 do shutterposition 50 endon" but it doesn't seems to work. (like explain here) Someone have tried ?

stefanbode commented 5 years ago

Maybe not easy. As you can see in the code I have a hook in on the relay change. I do not know if this identically with button change. I will give it a try. Your idea is that a long press do nothing and the rule set the position. Correct?

stefanbode commented 5 years ago

There where already requests that a short press closes and a long press close as long as you hold the button. I remember that there where some issues how tasmota deals with the commands

roondar commented 5 years ago

Yes that's it. A long press for button1 or button2 set the position to 50%.

Le jeu. 4 avr. 2019 à 19:28, stefanbode notifications@github.com a écrit :

Maybe not easy. As you can see in the code I have a hook in on the relay change. I do not know if this identically with button change. I will give it a try. Your idea is that a long press do nothing and the rule set the position. Correct?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/stefanbode/Sonoff-Tasmota/issues/117#issuecomment-479990284, or mute the thread https://github.com/notifications/unsubscribe-auth/AAmtp-wfgHKWazDWB8f7PX-OpKJ3DMpaks5vdjYogaJpZM4aGxQu .

twproject commented 5 years ago

is it also possible to send a mqtt message when someone press a button? It's useful for automation management (if someone press, stop the automation and go in manual mode)

Thanks

B1G1 commented 5 years ago

is it also possible to send a mqtt message when someone press a button? It's useful for automation management (if someone press, stop the automation and go in manual mode)

Thanks

it would be usefull for me too

titomontes commented 5 years ago

It´s perfectly possible. You have to create a rule, stating the correct GPIO and topic

B1G1 commented 5 years ago

It´s perfectly possible. You have to create a rule, stating the correct GPIO and topic

I missed this feature, thank you

hjahend commented 5 years ago

Hi Stefan, I am already using standard Sonoff unit with Tasmoto software for LED illumination, controlled via mqtt and my home automation system. Now interested in your 2-relay solution and love to implement it for my external vertical somfy screen (hv= 3m 2m) & 220V AC powering. Major required functions: Up, Dn. No pulse. Max duration (screen 0-100% or vv) about 60 seconds. Automatic stop at begin and end position of the screen is already part of the Somfy screen-solution. Needed: manual switches for Up and DN, beside MQTT based instructions for UP and DN. My Home automation system deliver, receive and evaluate the mqtt messages. Questions to you:

  1. Is your solution (5DC 220V AC 10A) reliable and safe to use, based on your experience or
  2. Is a Sonoff Dual R2 better/preferable? How to implement that in hardware?
  3. What software to use and how to configure that correctly for 1 or 2? Thanking you in advance HJA Hendriks
stefanbode commented 5 years ago

Hi Hendriks, please check the wiki for the configuration and a wiring example. This should answer most of your questions. You can calibrate the open and lose duration just 1 second longer. Then you're sure you hit the end-stop of your configuration. A Sonoff DUAL is better for beginners because the wirering is easier.

hjahend commented 5 years ago

thx very much Stefan, I did not find a complete wiring for the Sonoff duo (with the required manual switches for UP and DN & and well interlocked (how?) to prevent damage). What software (standard Tasmota for the duo?) and settings do you advise in my situation, with only rather minimal mqtt instructions required?

stefanbode commented 5 years ago

because you have endstops and because you only need full down and full up, I think youre fine with the standard tasmoto and do not need my mod. just define: "INTERLOCK 1" and "INTERLOCK 1,2" to ensure that relay 1 and 2 never can be ON at the same time. than just BUTTON1 and BUTTON2 thats it. TO go up and down you just send trough MQTT an ON to the relay and the rest will be done through the INTERLOCK and the endstops.

titomontes commented 5 years ago

Hello again

I´m having a strange issue using Tx or Rx as external switches. After a few restarts with the switch on, the GPIO stops working (I was using GPIO 1, GPIO3 seems to be much more conflictive). Works fine a few times, and then the only way to make it work again is reflashing.

Question is: How can I use de reset button as another switch? (meaning, How to configure that GPIO as switch when it´s not available in the config dialog). Templates perhaps? HOW??

Thanks

stefanbode commented 5 years ago

Du the gpio is Not available, then you cannot use it with the device. Just simple. Rx and Tx never work with gpio. Please take a look in the master Projekt of tasmota. There is a reason why only some gpio are exposed for external usage

twproject commented 5 years ago

It´s perfectly possible. You have to create a rule, stating the correct GPIO and topic

I create a test rule: rule on Switch1#state=toggle do publish publish cmnd/AAA/switch1 1 endon

but nothing happen when i push the button. switchmode and switchstate is set to 0 Instead toggle I tried with 0/1/ON/OFF values with no luck

twproject commented 5 years ago

Du the gpio is Not available, then you cannot use it with the device. Just simple. Rx and Tx never work with gpio. Please take a look in the master Projekt of tasmota. There is a reason why only some gpio are exposed for external usage

I used TX pin as counter (i connected an anemometer) after disabling seriallog (from console: SerialLog 0)

image

MadDoct commented 5 years ago

You shouldn't use TX with a "permanent position" button for the same reason that you shouldn't use gpio0 and others. It's a little known feature, but restarting the esp with TX low will make it start in test mode... So, avoid using it for anything other than momentary push buttons...

MadDoct commented 5 years ago

@twproject, that's not TX, it's RX! TX is gpio1...

MadDoct commented 5 years ago

@stefanbode, you can use RX freely as long as you disable seriallog... For the others there are restrictions...

stefanbode commented 4 years ago

@MadDoct agree, but this is so special that you forget easily and then wonder why it did not work. After an upgrade or so.