That looks like that should work. The common grounds just serve as a reference for the voltage sources so tying them together is good. These lines say 12V, but I assume they’re 24V in your case? I’m still not convinced you need separate power supplies as shown here, since the L298N (the higher voltage versions of the L298 chip) typically seem to come packaged with a voltage regulator capable of handling up to that input voltage. Without the datasheet for your particular module, however it is difficult to say for certain.
Thanks Peter_K,
Yes, my mistake, should be 24V in (and out), not 12V.
To be honest, not sure either about the external 5V, but the nodemcu becomes unavailable if I use the 5V from the relay, whereas it stays on if I power it through the USB. So I assume it (the nodemcu) will also work if powered with 5V through the VIN - hope so as I would not want to have both a USB for the nodemcu and then a separate 5V for the relay.
I can’t imagine it would have an issue with 5V in on the input terminal vs the USB connector unless it’s been damaged or defective. I would definitely be curious on what the 5V regulated output from the driver board is when the nodemcu stops working, but if you can get it working with 5V external, then at least you can move on to the next steps. Good luck and let me know how it goes.
Peter-K, the regulated output from the driver board drops from 5V to 2.3V, guess that’s insufficient for the nodemcu. As to why I don’t know, but guess it’s to do with the regulator getting more than it’s max of 12V.
I will try to test it all tomorrow and let you know how it goes. Thanks for now.
And the plot thickens. I got it to work, almost.
Tried if the VIN by any chance would by VOut if the Nodemcu was powered via USB. It is. Read a bit about, and should be ok, at least for Nodemcu V2, which is what I have. Seems V3 does not do it, and for V1 I am not sure. So far so good. Connected it as per the below. Powering it through USB makes for an easy 5V power supply.
And it works fine with controlling the relays from Hassio. Regardless if I connect it to pins D1 and D2, or to pins D5 and D6.
BUT. I am having a problem with the buttons. Regardless if I connect them to D1/D2 or D5/D6 there is no reaction. I do NOT get 5V between the pins and GND when I press the buttons, but measure the resistance it drops to 0 when button pressed, so there is connection. Sometimes, when I fiddle around with it to measure if there is connection, the relay kicks in. But I can not figure out any system to it. Guess it has to do with the pins being somehow capacitive.
Does it have something to do with the pull-down resistors? Any way I can measure if they are there/are needed?
I somehow guess/assume not, most likely related to the fact that I do not get 5V between the pins and GND. But why is that?
Could it be something related to the command “inverted: true”. Should that be false instead?
Who would know that using nodemcu instead of Wemos D1 mini and using 24V would be so much more complicated…
And to complete the picture or for others: read about the power requirements of the nodemcu and the logic circuit of the relays. Very limited requirements, I understood it as if the nodemcu could go up to 400mA, and the relay up to 36mA. So 5V 0.5A should be good. So that is what I have.
The input pins have internal pull-up resistors, which means that with no buttons connected, you should measure a logic high on the input pins (between each pin and ground)
You need to pull the pin low to activate it, in other words, one side of the button to the pin, the other side to ground.
Since they are active low, it’s correct that the inputs are inverted in the code.
Thanks Simon,
That is also how I thought should be, and how I did it for the Wemos D1 Mini with 12V.
But here, I just can not get it to work. I tried it, but would say that the pins are floating, sometimes a signal is registered when my fingers are close to the pins, and sometimes nothing happens when I press the push button.
I then thought that I would need a pull-down resistor, so inserted a 10K Ohm resistor gnd and the pin as shown in the picture in my first post above. It somehow helped as it seemed that I could at least now activate it, pull it low I guess, by connecting the pin to the 3.3V pins on the board. But I could not stop it again, eg could not pull it high again I guess it means.
Then I saw your post above, and thought I would try again to get rid of the resistor and simply connect the pin, but then I get very erratic behavior.
It seems most websites are talking about a pull-down resistor as eg 10K Ohm, but one website actually suggested 10K for pull-up and 100 Ohm for pull-down. Could that have something to do with it?
If we assume for a second that there are no internal resistor, could that explain it? And if that is the case, should I then connect one of the 3.3V pins on the Nodemcu to a 10K resistor, then connect that to the pin on the nodemcu, and from there to the button. The other side of the button should then go to GND. Would that make sense/potentially help?
Ok, tried with a pull-up resistor. Did not work.
And now tried measuring between pin and GND = 0 volt. Between pin and one of the 3.3V pins on the nodemcu the results varies, ranging from nothing or 1 V or 2.3 V (often it seems). Can anybody deduct anything from that?
Edit: with pull-up resistor it might work, please wait. I am a bit too tired to continue right now, but I might have connected the resistor wrong the first time around.
Ok, it works with pull-up resistors. I do not know why. The Wemos D1 mini did not need resistors. Different possibilities:
- The nodemcu in general does not have built-in resistors
- This specific brand of nodemcu does not have built-in resistors
- I have somehow managed to fry the built-in resistors that were there.
- Something else is going on.
Here is, for others’ use/inspiration, the updated schematics:
Thanks for the guidance from especially Peter_K and SimonPth whom took the top of some of the uncertainties and whose suggestions led me to try various options.
Good work, well persevered.
And just wanted to add for future references:
Here it is mentioned how one can activiate internal pullups:
I have not tested it, so can not vouch for it.