Sonoff 4ch r2 toggle all 4 switches with one ext. Button.

73 views
Skip to first unread message

Christopher

unread,
Jul 21, 2019, 4:54:22 PM7/21/19
to SonoffUsers


Hello!

It is about the following problem:

I would like to install an external button on my Sonoff 4CH R2 (tasmota 6.6.0).

I would like to use GPIO2 for that. As far as I've read so far, this is anyway PullUP. Even if its not, that would be no problem to pull him up with a resistor.

The bigger problem is the software solution.
I'll give you a few guesses:

- I have to define the button in the menu at GPIO2 as Switch5 (or 5n?).

- the Switch5(n) has to setup as a toggle?
- Then I have to create a rule that turns all lamps on / off when the external button is toggled.



I also use the Sonoff 4ch via MQTT via ioBroker. Therefore, the default settings for the 4 switches should be preserved.

Is there perhaps already a HowTo which I have not found so far?

If not, how do I solve the software part?
Are there better ideas?

The background is: Even if my Raspberry Pi fails, I'd like to have the ability to turn on all the lights with a simple hardware push-button.
A kind of emergency switch.
Because the Sonoff himself sits in a hard to reach place.

By the way, for me it may also be a switch instead of a button.

I think a button is idiot-safe because of the FlashBoot.
The chance that the button is pressed exactly in the moment when the Sonoff voltage is supplied is very unlikely. : D


Thank you for your help!

Phil

unread,
Jul 21, 2019, 8:57:29 PM7/21/19
to SonoffUsers
just a thought but how about pairing a rf button to one of the 4 channels, i think there is a rfrecieved trigger you can use to toggle the remaining 3 relays.

Christopher

unread,
Jul 21, 2019, 9:18:48 PM7/21/19
to SonoffUsers
Yes, thats an idea... Thanks for your replay 
 But i haven't one. The Button and 3 Meters of cable wel.

Phil

unread,
Jul 22, 2019, 12:32:37 AM7/22/19
to SonoffUsers
in that case go for it.  but set the button up as button5  unless it is a switch?? and yes use rules.. with Button5 configured you can use the Button5#state trigger to fire your rules to turn on the relays.

Philip Knowles

unread,
Jul 22, 2019, 4:02:19 AM7/22/19
to Christopher, SonoffUsers
To prevent boot problems (if the switch gets left in the wrong position) I would set it as a Button (and use a push to make button) you can get 'retractive' light switches to do this now. Then create a dummy relay 5 on a 'spare' GPIO. The button will now 'toggle' the relay 5. 
Then create a rule
On power5#state=1 power1 1 power2 1 power3 1 power4 1 endon
And an off rule too to toggle them all off

Regards

Phil K

--
You received this message because you are subscribed to the Google Groups "SonoffUsers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sonoffusers...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/sonoffusers/847daa21-3b4f-4862-994a-33f8520a70dc%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "SonoffUsers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sonoffusers...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/sonoffusers/847daa21-3b4f-4862-994a-33f8520a70dc%40googlegroups.com.

Christopher

unread,
Jul 22, 2019, 4:10:45 PM7/22/19
to SonoffUsers
Thanks for your answer! I will build it tomorrow and let you know if it works =)
To unsubscribe from this group and stop receiving emails from it, send an email to sonof...@googlegroups.com.
On Sun, 21 Jul 2019, 21:54 Christopher, <NasInf...@gmail.com> wrote:


Hello!

It is about the following problem:

I would like to install an external button on my Sonoff 4CH R2 (tasmota 6.6.0).

I would like to use GPIO2 for that. As far as I've read so far, this is anyway PullUP. Even if its not, that would be no problem to pull him up with a resistor.

The bigger problem is the software solution.
I'll give you a few guesses:

- I have to define the button in the menu at GPIO2 as Switch5 (or 5n?).

- the Switch5(n) has to setup as a toggle?
- Then I have to create a rule that turns all lamps on / off when the external button is toggled.



I also use the Sonoff 4ch via MQTT via ioBroker. Therefore, the default settings for the 4 switches should be preserved.

Is there perhaps already a HowTo which I have not found so far?

If not, how do I solve the software part?
Are there better ideas?

The background is: Even if my Raspberry Pi fails, I'd like to have the ability to turn on all the lights with a simple hardware push-button.
A kind of emergency switch.
Because the Sonoff himself sits in a hard to reach place.

By the way, for me it may also be a switch instead of a button.

I think a button is idiot-safe because of the FlashBoot.
The chance that the button is pressed exactly in the moment when the Sonoff voltage is supplied is very unlikely. : D


Thank you for your help!

--
You received this message because you are subscribed to the Google Groups "SonoffUsers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sonof...@googlegroups.com.

Christopher

unread,
Jul 25, 2019, 9:03:18 AM7/25/19
to SonoffUsers

Ok. It works!

For completeness a short tutorial if someone has the same problem as me.

I soldered a 5 pin header to my Sonoff 4ch R2 for the Tasmota Flash.
So I used 2 patch / breadboard cables, cut them off and soldered a wire to each one.
This cable ends up in a switch.
I led the cable with the patch cable neatly and electrically insulated thorugh the housing.

Software Webinterface:
Via Settings Template: Select "Switch5" for GPIO2.

Via Webconsole: 
SwitchState5 1
for Detail browse: https://github.com/arendst/Sonoff-Tasmota/wiki/Buttons-and-Switches

Now enter the rules:
Rule2 on switch5#state=1 do backlog power1 on; power2 on; power3 on; power4 on endon


Rule3 on switch5#state=0 do backlog power1 off; power2 off; power3 off; power4 off endon


That's it.

Many thanks for the help!

Michael Ingraham

unread,
Jul 25, 2019, 9:35:12 AM7/25/19
to SonoffUsers
Tips & tricks ;-)

A single rule for both...

Rule2 on switch5#state do backlog power1 %value%; power2 %value%; power3 %value%; power4 %value% endon

Also, you can put multiple rules in a single rule set (up to 511 characters in each buffer), e.g., 
Rule2 on switch5#state=1 do backlog power1 on; power2 on; power3 on; power4 on endon on switch5#state=0 do backlog power1 off; power2 off; power3 off; power4 off endon
Reply all
Reply to author
Forward
0 new messages