Hi Experts,
I am new to whole home automation scene. I have flashed my Nodemcu 1.0 with EspEasy 2.0.0 dev7. I have connected an led on gpio 0 and physical button to gpio 2. Then I wrote an automation rule in Home assistant that when physical button (gpio2) state update is received in mqtt server then toggle the state on gpio 0. So following is what works
physical button press ---> gpio 2 changes state and publishes to mqtt topic --> home assistant receives a state update in the subscribed topic ---> home assistant toggles the gui switch using automation rule ---> toggled gui switch publishes new state to topic associated with gpio 0 ---> gpio 0 changes the state based on payload received in the mqtt topic ---> led connected to gpio 0 gets turned on or off depending upon previous state.
Now the above scenario only works when gpio 2 is set to 1. If gpio 2 is set to 0 then pressing the physical button mapped to gpio 0 does nothing. No new state is getting published.
How can I publish the new state using push button when gpio 2's current state is set to 0.
Attached is my breadboard connecting photo
Change GPIO state using physical button
Moderators: grovkillen, Stuntteam, TD-er
Change GPIO state using physical button
- Attachments
-
- espeasy breadboard.jpg (3.33 MiB) Viewed 5937 times
Re: Change GPIO state using physical button
you are just confusing the gpios.kvjajoo wrote: ↑23 Apr 2017, 08:25 Hi Experts,
I am new to whole home automation scene. I have flashed my Nodemcu 1.0 with EspEasy 2.0.0 dev7. I have connected an led on gpio 0 and physical button to gpio 2. Then I wrote an automation rule in Home assistant that when physical button (gpio2) state update is received in mqtt server then toggle the state on gpio 0. So following is what works
physical button press ---> gpio 2 changes state and publishes to mqtt topic --> home assistant receives a state update in the subscribed topic ---> home assistant toggles the gui switch using automation rule ---> toggled gui switch publishes new state to topic associated with gpio 0 ---> gpio 0 changes the state based on payload received in the mqtt topic ---> led connected to gpio 0 gets turned on or off depending upon previous state.
Now the above scenario only works when gpio 2 is set to 1. If gpio 2 is set to 0 then pressing the physical button mapped to gpio 0 does nothing. No new state is getting published.
How can I publish the new state using push button when gpio 2's current state is set to 0.
Attached is my breadboard connecting photo
The physical button is connected to GPIO 2 --> This value is 1/0 depending on your settings in the switch device in ESP Easy (inversed or not, pull-up or not) and your cabling (GPIO to GND or GPIO to VCC). However as it is a momentary push button it only gets set to 1/0 for a short moment. There is also the option to make the ESP "remember" that a button was pressed (active high/active low). If you then press the button GPIO 2 will toggle as you press the button.
The LED is connected to GPIO0. So how must a state for GPIO0 get published as button press ??
I think that is your mistake
Domoticz on Raspi 2 -- 14 ESP units (hacked Sonoff,NodeMCUs, Wemos, self-built units) running with RC140- Mega 2.0.0 dev8
Re: Change GPIO state using physical button
@Toffel969
My only issue is that when gpio2 is set to 0 then it does not recognizes the button press. How to I make sure that when the gpio 2 is set to 0 it recognizes the button press ?
I am aware that this is a momentary button and it will set the gpio to 1/0 for short moment. For testing this is absolutely perfect for me. Currently gpio 2 settings are attached below ..The physical button is connected to GPIO 2 --> This value is 1/0 depending on your settings in the switch device in ESP Easy (inversed or not, pull-up or not) and your cabling (GPIO to GND or GPIO to VCC). However as it is a momentary push button it only gets set to 1/0 for a short moment. There is also the option to make the ESP "remember" that a button was pressed (active high/active low). If you then press the button GPIO 2 will toggle as you press the button.
The gpio0 is getting triggred using my home assistant automation rule. In other words button press (gpio2) is sending status to home assistant about status change and home assistant is triggering led on /off (gpio0). So there is no issue here and automation rule works fine.The LED is connected to GPIO0. So how must a state for GPIO0 get published as button press ??
I think that is your mistake
My only issue is that when gpio2 is set to 0 then it does not recognizes the button press. How to I make sure that when the gpio 2 is set to 0 it recognizes the button press ?
- Attachments
-
- esp button settings.JPG (53.74 KiB) Viewed 5915 times
Re: Change GPIO state using physical button
kvjajoo wrote: ↑23 Apr 2017, 15:22 @Toffel969
I am aware that this is a momentary button and it will set the gpio to 1/0 for short moment. For testing this is absolutely perfect for me. Currently gpio 2 settings are attached below ..The physical button is connected to GPIO 2 --> This value is 1/0 depending on your settings in the switch device in ESP Easy (inversed or not, pull-up or not) and your cabling (GPIO to GND or GPIO to VCC). However as it is a momentary push button it only gets set to 1/0 for a short moment. There is also the option to make the ESP "remember" that a button was pressed (active high/active low). If you then press the button GPIO 2 will toggle as you press the button.
The gpio0 is getting triggred using my home assistant automation rule. In other words button press (gpio2) is sending status to home assistant about status change and home assistant is triggering led on /off (gpio0). So there is no issue here and automation rule works fine.The LED is connected to GPIO0. So how must a state for GPIO0 get published as button press ??
I think that is your mistake
My only issue is that when gpio2 is set to 0 then it does not recognizes the button press. How to I make sure that when the gpio 2 is set to 0 it recognizes the button press ?
I don't thin "immitating" a button press by using the gpio as output works in the way you want. However there is a solution that will toggle the LED on button press . Local rules on the ESP in combination the HomeAutomation.
1. Activate Rules under Advanced Tab --> The Rule Tab appears
2. Rename the Switch input devices to button and LED
3. Create the Rules
Code: Select all
On button#Switch=1 do
if [LED#switch]=1
gpio,0,0
else
gpio,0,1
Endon
Domoticz on Raspi 2 -- 14 ESP units (hacked Sonoff,NodeMCUs, Wemos, self-built units) running with RC140- Mega 2.0.0 dev8
Who is online
Users browsing this forum: No registered users and 46 guests