How to emulate push button switch to ground

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
bojan
Normal user
Posts: 11
Joined: 29 Aug 2018, 07:55
Location: Ljubljana, Slovenia

How to emulate push button switch to ground

#1 Post by bojan » 10 Dec 2018, 13:07

Hello!

I would like to emulate a push button switch to ground. I can do that with this :

pinMode(powerButton, INPUT);
digitalWrite(powerButton, LOW);
pinMode(powerButton, OUTPUT); // Pull the signal low to activate the power button
delay(100);
pinMode(powerButton, INPUT); // Release the power button.

BUT, can I do that with EspEasy?

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: How to emulate push button switch to ground

#2 Post by grovkillen » 10 Dec 2018, 15:25

What do you mean? Please explain more... :?
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

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

Re: How to emulate push button switch to ground

#3 Post by ThomasB » 10 Dec 2018, 17:49

I would like to emulate a push button switch to ground. I can do that with this : {snip}
Please review the GPIO commands explained here:
https://www.letscontrolit.com/wiki/index.php/GPIO

I see that you require the emulated switch to be Hi-Z when not active (driven low). So the built-in GPIO pulse command cannot be used. The workaround is to use discrete GPIO commands and a system timer. Unfortunately the system timer only has 1000mS resolution so the switch will be active for 1 second minimum.

Here is a set of rules that will activate GPIO14 by calling Event SendSwitch

Code: Select all

on System#Boot do
   GPIO,14,2  // Hi-Z GPIO 14
endon

on Rules#Timer=4 do
   GPIO,14,2  // Hi-Z GPIO 14
endon


on SendSwitch do
   timerSet,4,1
   GPIO,14,0
endon
My example uses GPIO-14, which is a unused pin on the Sonoff Basic. However, you'll need to specify a suitable GPIO for your ESP8266 hardware.

Important: Do not connect anything directly to a GPIO pin that could drive the pin higher than 3.3V. Otherwise the ESP8266 can be damaged.

- Thomas

bojan
Normal user
Posts: 11
Joined: 29 Aug 2018, 07:55
Location: Ljubljana, Slovenia

Re: How to emulate push button switch to ground

#4 Post by bojan » 10 Dec 2018, 19:25

Thank you Thomas, that will probably do the trick. Just to be clear: I would like to parallel connect the ESP GPIO to the LED controller push buttons.
2018-12-10 19.13.39.jpg
2018-12-10 19.13.39.jpg (469.63 KiB) Viewed 3825 times
Also, thanks for 3.3V tip. I will have to use the level shifter.
BR
Bojan

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

Re: How to emulate push button switch to ground

#5 Post by ThomasB » 10 Dec 2018, 20:17

Instead of a typical level shifter you could use a simple NPN or FET transistor buffer circuit. This would allow you to use the GPIO Pulse command which would simplify your rules and allow 100mS switch On times.

- Thomas

bojan
Normal user
Posts: 11
Joined: 29 Aug 2018, 07:55
Location: Ljubljana, Slovenia

Re: How to emulate push button switch to ground

#6 Post by bojan » 11 Dec 2018, 11:41

Yes, that is probably the simplest solution. Thanks a lot.
Bojan

Post Reply

Who is online

Users browsing this forum: No registered users and 93 guests