Switch doesn't work?

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
Trocin
New user
Posts: 3
Joined: 18 Feb 2017, 20:29

Switch doesn't work?

#1 Post by Trocin » 18 Feb 2017, 20:46

Hello all Ladies and Gents

Firstly I would like to say HELLO because it is my first post on this forum.

Secondly I've got a question for you:

Now I try to do some simple remote activate alarm with ESP Easy.

unfortunately switch don't show any state change on devices site, and also Events are not activated.

Can you help me please?



Hardware:

ESP with switch connected to gpio 16 and GND



Configuration:

Config -> Protocol Standalone

Hardware ->GPIO 16 as Default Value

Devices -> Switch

|-> Device - Switch Input

|-> Name - Lewy

|-> Delay - 0

|-> IDX -> Value not 0

|-> 1St GPIO -> 16

|-> Pullup -> no (yes also checked)

|-> Inversed -> no (yes also checked)

|-> Switch type - Switch

|-> Send boot state - no (What do this option?)

|-> Send Data - match (What do this option?)

|-> Value Name - Switch

Rules ->

On Lewy#Switch =1 do

SendToHTTP 192.168.1.160,80,/control?cmd=event,A //Activate event on remote ESP

endon


Any Ideas why button doesn't work?
Thanks in advance :)

paxi
Normal user
Posts: 121
Joined: 02 Feb 2017, 00:48
Location: Germany

Re: Switch doesn't work?

#2 Post by paxi » 19 Feb 2017, 11:13

Don't forget a current limiting resistor(1k) in line with the switch.
Your post isn't clear, you write switch at first and later button. For a momentary pushbutton configure the switch type accordingly.
Then the pin isn't set as input but anyhow - gpio 16 is somewhat special, I'd try to pull it high instead of low or simply use a different pin.

More info on gpio's: https://blog.falafel.com/programming-gp ... h-nodemcu/
tl;dr: gpio 16 can be used as input but it has an internal pull down (opposed to 0-15 with pull ups). ESPEasy doesn't reflect this and still presents the "pull up" option. Maybe you've found a bug. ;)

Trocin
New user
Posts: 3
Joined: 18 Feb 2017, 20:29

Re: Switch doesn't work?

#3 Post by Trocin » 19 Feb 2017, 15:27

Thanks for quick response.
I will try your suggest and let you know.

Trocin
New user
Posts: 3
Joined: 18 Feb 2017, 20:29

Re: Switch doesn't work?

#4 Post by Trocin » 20 Feb 2017, 22:43

Thanks it works now :).
By the way is possible to define and condition on rules eg.
if gpio12=1 and gpio10=1 then...
?

paxi
Normal user
Posts: 121
Joined: 02 Feb 2017, 00:48
Location: Germany

Re: Switch doesn't work?

#5 Post by paxi » 20 Feb 2017, 23:49

Mind to share your solution? ;)

Sadly no AND. From rules tutorial:
Also simple if ... else ... endif statements are possible, but nesting and Boolean logic are not supported.
But there's a workaround:

Code: Select all

... 
if condition1 
    event checkAND
endif
... 

on checkAND do
    if condition2
         desired action
    endif
endon 
GPIO is a command, not a value so you can't check directly for that. Instead create a switch device with the respective pin as input and use

Code: Select all

if [devicename#valuename]=1

Post Reply

Who is online

Users browsing this forum: Google [Bot] and 23 guests