Page 1 of 1

Problems with push button , self activation

Posted: 23 Jan 2020, 01:40
by stefanru
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

Re: Problems with push button , self activation

Posted: 23 Jan 2020, 03:02
by ThomasB
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

Re: Problems with push button , self activation

Posted: 23 Jan 2020, 12:44
by stefanru
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

Re: Problems with push button , self activation

Posted: 23 Jan 2020, 13:43
by TD-er
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.

Re: Problems with push button , self activation

Posted: 23 Jan 2020, 14:27
by Shardan
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.).

Re: Problems with push button , self activation

Posted: 23 Jan 2020, 14:39
by stefanru
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

Re: Problems with push button , self activation

Posted: 23 Jan 2020, 17:38
by Shardan
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.

Re: Problems with push button , self activation

Posted: 23 Jan 2020, 17:51
by stefanru
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

Re: Problems with push button , self activation

Posted: 23 Jan 2020, 22:51
by stefanru
Ok,

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

Thank you for your help!
Stefan

Re: Problems with push button , self activation

Posted: 26 Jan 2020, 13:19
by stefanru
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

Re: Problems with push button , self activation

Posted: 26 Jan 2020, 23:30
by Domosapiens

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

Re: Problems with push button , self activation

Posted: 28 Jan 2020, 22:20
by stefanru
Oh yes, Thanks!