One more switch problem

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
Sturgeon
Normal user
Posts: 13
Joined: 23 Apr 2018, 20:18

One more switch problem

#1 Post by Sturgeon » 26 Oct 2021, 13:38

Hello!
I'm trying to make one more smart curtains.
I read several similar topics and tried to repeat it.
But something went wrong.
I have a curtain switch with two push buttons, Wemos D1 mini and two relays. I connect these push buttons to ground and to pins D1 and D2 with 20 cm wires. I also connected external 10k pull-up resistor to pins D1, D2 and 5V.
Settings for Switch1 and Switch2 shown in the picture below. The second switch has the same settings, but have GPIO D2.
switch.jpg
switch.jpg (97.17 KiB) Viewed 4868 times
And pin status
pin.jpg
pin.jpg (46.45 KiB) Viewed 4868 times
Relays control contacts connect to D6 and D7.

My rules. When i press the button, the relay should work for 10 seconds.

Code: Select all

On Curtains_open#State=1 do
  timerSet,1,10   //set Timer1  for 10 seconds
  gpio,13,1
  gpio,14,1
Endon

On Curtains_close#State=1 do
  timerSet,1,10 //set Timer1  for 10 seconds
    gpio,14,1
Endon

On Rules#Timer=1 do //when Timer1 expires, do
  gpio, 13,0
  gpio, 14,0
Endon
But there is a problem. From time to time, D6 and D7 turn on spontaneously. About once a minute. Or every two minutes. Or once every 10 seconds. Not periodically. If i delete the rules or disable the buttons on the "Devices" tab, then nothing happens.

On the arduino, I deal with noises/interferences by soldering the capacitor between the ground pin and the button pin.
If I solder a 1 μF (or 10 μF) capacitor to ground and button pins, then i need to press button two times for relay turn on.
I understand that somewhere I was mistaken. But I can't find my mistake.
Help me, please!

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: One more switch problem

#2 Post by TD-er » 26 Oct 2021, 13:58

First of all, pulling up to 5V is not a good idea.
There is still some uncertainty about how tolerant the GPIO pins on the ESP are to 5V.

Second, please refer to the pins by their GPIO nr, as the D-notation used on NodeMCU boards (and Wemos D1 mini too I think) is really confusing.
I always have to look them up to verify which GPIO it is.
You mention D6 and D7:
GPIO-12 (D6)
GPIO-13 (D7)
But those are not in your screenshots nor your rules. (at least GPIO-12 (D6) isn't)
So what is on GPIO-12?

What build are you using?
On the latest builds I added a marker in the GPIO selection comboboxes if there is a conflict with some other assignments, like I2C (the default pins for I2C are set to GPIO-4 & 5)
Do you have a conflict with the I2C assigned pins?

About the erratic behavior.
It looks like your switch does act as an antenna.
How do you intend to use the switch? As it is now connected, it should act as a toggle button.
Thus press it and it switches state, press it again and it switches state again.

What value as pull up resistor do you use?

Sturgeon
Normal user
Posts: 13
Joined: 23 Apr 2018, 20:18

Re: One more switch problem

#3 Post by Sturgeon » 26 Oct 2021, 15:09

TD-er wrote: 26 Oct 2021, 13:58 So what is on GPIO-12?
Sorry, relay control pins are D5 (gpio14) and D7 (gpio13).
TD-er wrote: 26 Oct 2021, 13:58 What build are you using?
Build: ESP_Easy_mega_20210802_normal_IRext_no_rx_ESP8266_4M2M Aug 2 2021
TD-er wrote: 26 Oct 2021, 13:58 Do you have a conflict with the I2C assigned pins?
I think no.
pin state.jpg
pin state.jpg (55.51 KiB) Viewed 4861 times
TD-er wrote: 26 Oct 2021, 13:58 About the erratic behavior.
It looks like your switch does act as an antenna.
I think so too. I try to use capacistor fo reduse interference and false push go away. But now i need press button two time for turn on relay. Any time.
TD-er wrote: 26 Oct 2021, 13:58 How do you intend to use the switch? As it is now connected, it should act as a toggle button.
Thus press it and it switches state, press it again and it switches state again.
I want use it as push button with low activity. Switch Button Type is "push button active low".
TD-er wrote: 26 Oct 2021, 13:58 First of all, pulling up to 5V is not a good idea.
Thanks, I try to change my pullup to 3.3v. I use 10k resistor.

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: One more switch problem

#4 Post by TD-er » 26 Oct 2021, 15:29

Maybe you should use a slightly lower pull-up resistor, like 4k7 and a high valued resistor over the switch (at the switch, not on the ESP side) to generate some current through the wires to the switch. (e.h. 47k)
Right now, you don't have any current flowing through the wires, so a very small signal can flip the logic level.

User avatar
Ath
Normal user
Posts: 3415
Joined: 10 Jun 2018, 12:06
Location: NL

Re: One more switch problem

#5 Post by Ath » 26 Oct 2021, 16:12

The 'Switch Button Type' should be set to 'Normal Switch', the label is actually somewhat confusing, as it expresses the way the switch behaves, not what (mechanical) type of switch is is.
A Push Button type means one press is on, and a second press is off again, where a 'Normal Switch' sets On when contact is made, and back to Off when there is no longer a contact.
/Ton (PayPal.me)

Sturgeon
Normal user
Posts: 13
Joined: 23 Apr 2018, 20:18

Re: One more switch problem

#6 Post by Sturgeon » 26 Oct 2021, 17:45

Ath wrote: 26 Oct 2021, 16:12 The 'Switch Button Type' should be set to 'Normal Switch'
TD-er wrote: 26 Oct 2021, 13:58 Thus press it and it switches state, press it again and it switches state again.
Yes! You are right! I set Switch Button Type to 'Normal Switch' and it work.
But... now i have another stupid problem. After power on or restart buttons (and relay) are "pushed".
I try to on/off "inversed logic" checkbox, but every start relay are turn on.

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: One more switch problem

#7 Post by TD-er » 26 Oct 2021, 18:06

It probably differs between a reboot and a power cycle.
The state of the tasks is saved and restored at boot. Thus depending on the state of the switches before the reboot (not power cycle) the behavior may be different.
You can also set a variable at boot (system#boot event) to indicate you're in the startup phase and thus ignore the switch changes.
Then after N seconds you can clear this variable.

Maybe also test with the "send boot state" flag to see if that may fix it for you.

Sturgeon
Normal user
Posts: 13
Joined: 23 Apr 2018, 20:18

Re: One more switch problem

#8 Post by Sturgeon » 26 Oct 2021, 20:49

TD-er wrote: 26 Oct 2021, 18:06 Maybe also test with the "send boot state" flag to see if that may fix it for you.
It is work!

Sometime i think that espeasy is not easy :)
Thanks a lot, guys! You are really genius.

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: One more switch problem

#9 Post by TD-er » 26 Oct 2021, 21:10

Sturgeon wrote: 26 Oct 2021, 20:49 [...]
Sometime i think that espeasy is not easy :)
Me too, so that is either a matter of making it easier, or ... document it ;)

Anyway, it is still a work-in-progress as it sometimes still needs some explaining and I do have so many new features in mind that it would take more than a decade to implement it all.

Post Reply

Who is online

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