So you're a Noob? Post your questions here until you graduate! Don't be shy.

User avatar
By Toft
#86698 Hi,

I am having a problem that I do not know if is for the esp8266 forum, or if it is for the newbie corner. If not, please advise and I will move it to where it belong.

I am programming a Wemos D1 mini, got it off amazon UK where it is no longer available, but its full name is IZOKEE D1 Mini NodeMcu Lua 4M Bytes WLAN WIFI Internet Development Board Base on ESP8266 ESP-12F for Arduino, 100% Compatible with WeMos D1 Mini (Pack), most likely the same as this: https://amzn.to/2SKRAvK

Now, I want to use it to control an H-bridge relay and want to connect it to push buttons as per this drawing:
Image

The drawing is from https://drzzs.com/diy-window-shades-mot ... automated/, Thanks to Dr. Zzs for that, and do let me know if I am not allowed to use the drawing.

Now, connecting the buttons to plus and minus /ground something weird, in my opinion happens: there is no reaction when I press the buttons. But, and here it comes, if I disconnect ground, and touch the other wire (the green ones in the drawing above), ie in reality simply touching the pin I get a reaction, ie it is triggered. Without it being connected to ground.

I do not understand how that can happen, and I am not sure I like it as I would not know how to trigger the pins with a button - at least they do not work with the push buttons. And touching it, it easily fires several touches (perhaps that can be dealt with in some programming though?), but I would also need a button for that kind of connection). The code I am using, if that is relevant, is this (for hassio):

binary_sensor:
- platform: gpio
pin:
number: D5
inverted: true
id: button_close
on_press:
then:
- lambda: |
if (id(my_stuegardin).current_operation == COVER_OPERATION_IDLE) {
id(my_stuegardin).close();
} else {
id(my_stuegardin).stop();
}

cover:
- platform: time_based
name: "stuegardin"
id: my_stuegardin
open_action:
- switch.turn_on: open_stuegardin
open_duration: 7s
close_action:
- switch.turn_on: close_stuegardin
close_duration: 7s
stop_action:
- switch.turn_off: open_stuegardin
- switch.turn_off: close_stuegardin

And then I have a similar code for D6.

So my questions are:
Is this really how the pins on the Wemos D1 can/should work, without ground connection? If not, what is wrong?
If it is correct, how can one connect a button to use to fire it? And what kind of code would be needed to have a delay between the touches?

I hope somebody can help.
User avatar
By Toft
#86734 And while I was waiting for this to be approved I continued searching and testing, and finally got to it, I think, seems to be working:
It matters which pins you use for the buttons. It has to be pin D1 and 2 (as Drzzs has). The way I understand it, it is because they have some built-in resistors. If you use other pins for buttons you would have to add a resistor, I think? (Would be relevant if I wanted to control two motors). Other pins are indeed acting like touch sensors, the explanation which I do not understand ;)

Just providing the above for future reference in case others should face similar challenges.
User avatar
By Luc Volders
#86753 Sorry I have no experience with hassio so can not say anything about that code.

You do not provide the C++ (Arduino) code for the ESP8266 so thats no help.

However I don't see any pull-up resistors on the switches.
That might help.