Sonoff-Tasmota: GPIO14 - Wall switch

2,842 views
Skip to first unread message

Tobias

unread,
Mar 19, 2017, 5:55:10 PM3/19/17
to SonoffUsers
Hi.

I've have some issues with using GPIO14, hopefully some of you can help!
My firmware is pretty plain, but I cannot get my GPIO14 to work with a wallswitch.

I simply want it to toggle the power-state and user_config.h is changed with
 #define SWITCH_MODE            TOGGLE

When I now connect GND to GPIO14 nothing happens, anyone who know what I've done wrong ^^? 

David Lang

unread,
Mar 19, 2017, 6:02:09 PM3/19/17
to Tobias, SonoffUsers
toggle is appropriate for momentary switches, you want either follow or follow
inverted if you have a on/off switch

with a toggle switch, connect it to ground and then disconnect it.

Tobias

unread,
Mar 19, 2017, 6:08:15 PM3/19/17
to SonoffUsers, tgund...@gmail.com, da...@lang.hm
Right now I just use a cable between the two pins to give a "puls", but I am normally using a momentary switch.
But nothing really happens, no change of state, nothing.

David Lang

unread,
Mar 19, 2017, 7:15:25 PM3/19/17
to Tobias, SonoffUsers
nothing in the log (web console)?

try setting logging to a higher level

Tim Wellington

unread,
Mar 20, 2017, 1:05:50 PM3/20/17
to SonoffUsers
Go into the module configuration and make sure you've got GPIO14 set to "09 Switch1".
Message has been deleted
Message has been deleted

Tobias

unread,
Mar 20, 2017, 3:43:48 PM3/20/17
to SonoffUsers
Hi Tim!

That worked better, however - it seems like the SWITCH mode of set PUSHBUTTON. I've defined it as "TOGGLE" in user_config.h, but it goes back to previous state as soon as GND is disconnected. 

Tim Wellington

unread,
Mar 21, 2017, 9:02:25 AM3/21/17
to SonoffUsers
If you're using a momentary button you should change TOGGLE to PUSHBUTTON. It's changing state when you push the button then changing again when you let go. 


Tobias

unread,
Mar 21, 2017, 11:25:17 AM3/21/17
to SonoffUsers
I did that already, but no difference - same behavior. 

David Lang

unread,
Mar 21, 2017, 11:51:00 AM3/21/17
to Tobias, SonoffUsers
what happens when you do switchmode1 in the web console (of via mqtt)

On Mon, 20 Mar 2017, Tobias wrote:

> Date: Mon, 20 Mar 2017 12:43:48 -0700 (PDT)
> From: Tobias <tgund...@gmail.com>
> To: SonoffUsers <sonof...@googlegroups.com>
> Subject: Re: Sonoff-Tasmota: GPIO14 - Wall switch

Tobias

unread,
Mar 22, 2017, 8:35:10 AM3/22/17
to SonoffUsers, tgund...@gmail.com, da...@lang.hm
GPIO14 is set up with 09 Switch1

#define SWITCH_MODE            PUSHBUTTON            // [SwitchMode] TOGGLE, FOLLOW, FOLLOW_INV, PUSHBUTTON or PUSHBUTTON_INV (the wall switch state)

13:32:14 CMND: Switchmode1
13:32:14 MQTT: stat/sonoff/RESULT = {"SwitchMode1":1}
13:32:30 MQTT: stat/sonoff/RESULT = {"POWER":"OFF"}
13:32:30 MQTT: stat/sonoff/POWER = OFF
13:32:30 MQTT: stat/sonoff/RESULT = {"POWER":"ON"}
13:32:30 MQTT: stat/sonoff/POWER = ON

AS you can see, when I push my impulse button, it goes back to ON as soon as the pulse is gone.

David Lang

unread,
Mar 22, 2017, 8:40:22 AM3/22/17
to Tobias, SonoffUsers
On Wed, 22 Mar 2017, Tobias wrote:

> GPIO14 is set up with 09 Switch1
>
> #define SWITCH_MODE PUSHBUTTON // [SwitchMode]
> TOGGLE, FOLLOW, FOLLOW_INV, PUSHBUTTON or PUSHBUTTON_INV (the wall switch
> state)
>
> 13:32:14 CMND: Switchmode1
> 13:32:14 MQTT: stat/sonoff/RESULT = {"SwitchMode1":1}
> 13:32:30 MQTT: stat/sonoff/RESULT = {"POWER":"OFF"}
> 13:32:30 MQTT: stat/sonoff/POWER = OFF
> 13:32:30 MQTT: stat/sonoff/RESULT = {"POWER":"ON"}
> 13:32:30 MQTT: stat/sonoff/POWER = ON
>
> AS you can see, when I push my impulse button, it goes back to ON as soon
> as the pulse is gone.

working as designed

https://github.com/arendst/Sonoff-Tasmota/wiki/Commands

SwitchMode<x> | | Show current external switch mode
SwitchMode<x> | 0 | (default) Set switch mode to TOGGLE
SwitchMode<x> | 1 | Set switch mode to FOLLOW (0 = Off, 1 = On)
SwitchMode<x> | 2 | Set switch mode to inverted FOLLOW (0 = On, 1
= Off)
SwitchMode<x> | 3 | Set switch mode to PUSHBUTTON (Normally 1, 0 =
toggle)
SwitchMode<x> | 4 | Set switch mode to inverted PUSHBUTTON
(Normally 0, 1 = toggle)

switchmode1 is follow, when the button is down, it's on, when it's up it's off
(for a normally open momentary switch)

try changing switchmode1 to one of the other values.
Reply all
Reply to author
Forward
0 new messages