Problems with push button , self activation

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
stefanru
Normal user
Posts: 14
Joined: 29 Jul 2017, 00:48

Problems with push button , self activation

#1 Post by stefanru » 23 Jan 2020, 01:40

Hi,

i have a problem with the switch plugin.
Connecting a push button works, but i get strange self triggerings.

To get a unwanted event it is enough to connect a 20cm wire to the gpio i where the button is configured.
When i take the wire in my hand and move it a little bit or rub on it, a event is triggered.

My plan was to use Push Button active Low setting, but i get this self triggerd events.
Using pushbutton active High i have the same problem.

I tried several gpios and all settings. I always get this self event triggering.

Do i need to connect a resistor to the wire for the push button?

I have really no idea why this happens. I hope someone can help me.

Thanks and best regards,
Stefan

User avatar
ThomasB
Normal user
Posts: 696
Joined: 17 Jun 2018, 20:41
Location: USA

Re: Problems with push button , self activation

#2 Post by ThomasB » 23 Jan 2020, 03:02

The push-button switch's two wires should connect to GPIO and GND.

Switch plugin Settings:
Internal PullUp Checked (Enabled).
Inversed Logic Checked (Enabled).
Switch Type: Switch.
Switch Button Type: Normal.

If the problem persists then you should add an external 1K ohm PullUp resistor. That is to say, install the resistor with one end connected to 3.3VDC and the other end directly to the GPIO pin. And shorten all GPIO wire leads as much as practical.

If the external PullUp does not help then try a different DC Power Supply.

- Thomas

stefanru
Normal user
Posts: 14
Joined: 29 Jul 2017, 00:48

Re: Problems with push button , self activation

#3 Post by stefanru » 23 Jan 2020, 12:44

Ok, thanks Thomas.

From the place where i want to install the switch i have to use 30cm wire :-(

I will try with another power supply and with the 1K ohm PullUp resistor.

One question to the 1k PullUp resistor.
Isn't this exactly the same as "Internal PullUp Checked (Enabled)"?

Thanks and best regards,
Stefan

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

Re: Problems with push button , self activation

#4 Post by TD-er » 23 Jan 2020, 13:43

The internal pull-up resistor of the ESP is having a way higher resistance value.
That one is more in the order of 20 - 100 k.
So you need a lot less interference to trigger false pushes.
Simply checking the pull up resistor may be a nice test to see if it already is some improvement.

You can also twist the wires to the push button so it will act less like an antenna.

Shardan
Normal user
Posts: 1156
Joined: 03 Sep 2016, 23:27
Location: Bielefeld / Germany

Re: Problems with push button , self activation

#5 Post by Shardan » 23 Jan 2020, 14:27

Use an external low pull-up/pull-down Rrsistor, around 10 KOhm.
The internal resistors of ESP are "weak" and due to my experience sometimes not sufficient.

Connect a capacitor of about 47nf...100nF from GPIO to ground (May slow down very fast switchings, usually it has no effects.).
Regards
Shardan

stefanru
Normal user
Posts: 14
Joined: 29 Jul 2017, 00:48

Re: Problems with push button , self activation

#6 Post by stefanru » 23 Jan 2020, 14:39

Thanks a lot for the help.

I will try the different options.
Twisting the wires is a good idea.
Also using an external pull up resistor sounds good and i understand why.

What i do not understand, what is a capacitor doing? ("Connect a capacitor of about 47nf...100nF from GPIO to ground")

Thanks and best regards,
Stefan

Shardan
Normal user
Posts: 1156
Joined: 03 Sep 2016, 23:27
Location: Bielefeld / Germany

Re: Problems with push button , self activation

#7 Post by Shardan » 23 Jan 2020, 17:38

A capacitor "slows down" a connection. The capacitor needs a specific amount of time to
load or unload, the time depends on the resistor you use. This combination just has a few
miliseconds changing time.

So if for examples spikes from the mains voltage line come across to your wire - it works like
an antenna for that - the capacitor makes the circuit too slow to give a reaction to these spikes.
More technically resistor and capacitor build a low pass filter, the filter frequency should be
low enough to cut off spikes, high frequency from CB, amateur radio and such.
Prefer a ceramic capacitor or a X5R or X7R type.
Regards
Shardan

stefanru
Normal user
Posts: 14
Joined: 29 Jul 2017, 00:48

Re: Problems with push button , self activation

#8 Post by stefanru » 23 Jan 2020, 17:51

Ok, now i understand.
Thank you very much for the detailed explanation!

I will try to get it working with all your hints how to do it.

Thanks,
Stefan

stefanru
Normal user
Posts: 14
Joined: 29 Jul 2017, 00:48

Re: Problems with push button , self activation

#9 Post by stefanru » 23 Jan 2020, 22:51

Ok,

i drilled the cables. This already did the Job.
Crazy.

Thank you for your help!
Stefan

stefanru
Normal user
Posts: 14
Joined: 29 Jul 2017, 00:48

Re: Problems with push button , self activation

#10 Post by stefanru » 26 Jan 2020, 13:19

Ok drilling the cabel did not really help.
So i inserted a 1k ohm resistor between 3.3V and my pin.
But this also did not work.

Now it seems that my ESP is damaged.
It works at long as it is cold.
After plugin it in it gets warm.
When resetting when warm it does not work anymore. No Wlan, no flashing.

Is it possible that my connection with 1 k ohm destroyed my esp?

But perhaps it was also faulty at the beginning. I will try with a new one but without 1 k Ohm.

P.S.:
used a new ESP without resistor and it seems to work.
Perhaps my ESP was broken.
Strange thing was that my old rules to get the button state with a if for LongPress and DoubleClick did not work anymore.

I had to do it with on now.

Code: Select all

//On Boot, Fan off
on System#Boot do
 pwm,12,0 
endon

//Dim Value from FHEM
on dim do
  TaskValueSet 1,1,%eventvalue2% //Set Dim Dummy
  event,setFanSpeed
endon

//Button handling
On Button#State=11 do //Longpress
    TaskValueSet 1,1,1023 //Set Dim Dummy 
    event,setFanSpeed
endon

On Button#State=3 do //Doubleclick
    TaskValueSet 1,1,500 //Set Dim Dummy   
    event,setFanSpeed
endon

On Button#State=1 do //Switch always 0->1
    TaskValueSet 1,1,0 //Set Dim Dummy  
    event,setFanSpeed 
endon

On setFanSpeed do
 pwm,12,[dim#dim] //Set speed of Fan
 let,1,1023-[dim#dim] //Calculate brightness of onboard LED
 pwm,2,%v1% //Set onboard LED
enddo


Best regards,
Stefan

Domosapiens
Normal user
Posts: 307
Joined: 06 Nov 2016, 13:45

Re: Problems with push button , self activation

#11 Post by Domosapiens » 26 Jan 2020, 23:30

Code: Select all

On setFanSpeed do
 pwm,12,[dim#dim] //Set speed of Fan
 let,1,1023-[dim#dim] //Calculate brightness of onboard LED
 pwm,2,%v1% //Set onboard LED
enddo
Without further comment, ...

Code: Select all

enddo 
is wrong.
Must be

Code: Select all

endon
30+ ESP units for production and test. Ranging from control of heating equipment, flow sensing, floor temp sensing, energy calculation, floor thermostat, water usage, to an interactive "fun box" for my grandson. Mainly Wemos D1.

stefanru
Normal user
Posts: 14
Joined: 29 Jul 2017, 00:48

Re: Problems with push button , self activation

#12 Post by stefanru » 28 Jan 2020, 22:20

Oh yes, Thanks!

Post Reply

Who is online

Users browsing this forum: No registered users and 18 guests