Hi,
I am having a problem or a series of problems that I am not able figure out how to deal with.
I am using a nodemcu v2 (I believe/assume, it is using ESP-12F (so a higher number than ESP-12E which the v2 apparently use – here are more details: https://www.amazon.co.uk/dp/B07M8Q38LK/ref=pe_3187911_189395841_TE_dp_1).
Now, I wanted to use it to control an H-bridge relay (24V) and wanted to connect it to push buttons as per this drawing:
The drawing is from https://drzzs.com/diy-window-shades-motorized-automated/, Thanks to Dr. Zzs for that, and do let me know if I am not allowed to use the drawing.
That is for the Wemos, but the principle should be the same except that I use other pins (I will get back to that in a second). And I got it working fine on a Wemos D1 mini so thought should be the same with the nodemcu.
I connected the relay to pins D5 and D6, and used the ESPhome like this:
switch:
- platform: gpio
pin: D5
interlock: &interlock [open_windowopener, close_windowopener]
id: open_windowopener
- platform: gpio
pin: D6
interlock: *interlock
id: close_windowopener
And the push buttons I connected to pins D1 and D2 as per the below.
binary_sensor:
- platform: gpio
pin:
number: D1
inverted: true
id: button_close
on_press:
then:
- lambda: |
if (id(my_windowopener).current_operation == COVER_OPERATION_IDLE) {
id(my_windowopener).close();
} else {
id(my_windowopener).stop();
}
- platform: gpio
pin:
number: D2
inverted: true
id: button_open
on_press:
then:
- lambda: |
if (id(my_windowopener).current_operation == COVER_OPERATION_IDLE) {
id(my_windowopener).open();
} else {
id(my_windowopener).stop();
}
That worked fine, but only for a few minutes, then it became unavailable. I could get it going again after some minutes. I started looking into if I needed to have some pull-down resistors, and actually reached the conclusion that I should, but then struggled to figure out exactly how they should be connected. Being it a Sunday and it anyhow not possible to get hold of resistors, I thought I in the meantime would try to power the Nodemcy through its USB port. I disconnected all wires to the four pins (and to VIN and Ground) and connected it to USB. It worked like a charm, kept going and going.
Great, but then wanted to reconnect it to the relay. That is sort of fine, but the when pins D5 and D6 are triggered, the motor connected to the relay started making some small humming noise without really moving. Perhaps it is something to do with a missing ground on the nodemcu, although I do not see how that should impact the relay.
So, something is terribly wrong, and I could really use some very specific assistance in how to get this connected.
The first questions are:
a) Why would the nodemcu stay connected when connected to an external powersupply (the H-bridge can output 5V). If it is relevant, it is what I believe is referred to as L298N, can be found here: https://www.amazon.co.uk/dp/B07S1N97V2/ref=pe_3187911_189395841_TE_dp_2).
b) What do I do with ground, do I need to connect the nodemcu to the relays ground?
c) Why is the motor now only humming?
d) Assuming there are solutions to the above, would I need pull-down resistors for the buttons on D1 and D2?
e) If the answer to d is yes, how should it look like, my take it would be like the diagram below? But what is VCC? In my case I as of now have connection from the pin (D5 or D6) on the nodemcu to the input pins on the H-bridge relay. Would the VCC be the relevant input pin on the relay?
Confusion is total, not even sure my explanation and questions makes sense to others, and I am not able to google my way out of it. I hope somebody can help.