Which Gpio pins you have unused?
What’s the voltage on your motor/switch circuit?
I am using GPIO0 and GPIO2
I am just not sure if i can use any others
As far as i tried to read through all the docs, GPIO1 is for receiving and GPIO3 is for sending…and that is about the amount of pins it has…
Could i just use GPIO3 and get info through that?
## START Test for logic in esphome
##########################################################################################
# Motor Control
##########################################################################################
sun:
latitude: 42.0931
longitude: -76.8054
on_sunrise:
- elevation: 1.87°
then:
- switch.turn_on:
id: relay1
- delay: 10s
- switch.turn_off:
id: relay1
on_sunset:
- elevation: -4°
then:
- switch.turn_on:
id: relay2
- delay: 10s
- switch.turn_off:
id: relay2
##########################################################################################
# End Stop
##########################################################################################
##
switch:
- platform: gpio
id: relay1
name: 'Relay 1'
pin: GPIO0
- platform: gpio
id: relay2
name: 'Relay 2'
pin: GPIO2
Other way around. Gpio1 is problematic, because if it’s low at boot, boot fails.
You can use Gpio3 to read one limit switch, if that’s good enough for you.
You didn’t answer for voltage…
Sorry, somehow i missed the voltage part…
The motor is 12 volt…and i have a step down in the feedline for the relay board/esp
So with the GPIO3 i would “just” solder a wire to the GPIO3 pin, run it to the NO contact on my door and bring it back to “where”?
Would GPIO3 provide power and i “just” ground the ohtee side to the negative of the esp or the other way around?
So you have 12V PSU directly to motor and to rest of the setup through stepdown converter? And limit switches are on 12V motor wiring?
So you need 3:1 voltage divider to drop 12V to 3V for Esp input.
If your motor is DC, then you don’t need relays at all. Use an ESP like the D1 Mini
(because you need more than the four available GPIOs on the ESP01), and an H-bridge motor driver. You need two limit switches in both directions. The first set, up or down, would go to a GPIO input to control the stop. The second set would physically be slightly beyond the soft limit switches. These would be fail-safe and hopefully never needed. The fail-safe would interrupt power to the motor and could also go to a pair of GPIO inputs to alert you that something went wrong.
I have used the H-bridge driven directly from the Wemos D1 Mini in a Halloween prop. The motor was from a DC drill with the chuck removed. (Most chucks are held in place using a reverse-thread screw).I screwed in a capstan to wind a rope.
If you get a l298n then this can handle your 12V power, drive up to two motors forward/reverse, but can also supply 5V to power an esp, which is a nice compact package for this kind of project. You can also change motor speed via pwm.
If you stick with the relays and your esp01 then you are getting tight on gpios for this kind of project. I would upgrade to an esp32.
That all involves new hardware though (pretty cheap though).
Getting familar with this page which explains which gpios are safe to use will save many headaches.
I just found this on AliExpress:
AU$6.42 | Driver Board L298N Module 298N Stepper Motor Smart Car Robot Breadboard Peltier High Power L298 DC Motor Driver For Arduino
https://a.aliexpress.com/_m07euBI
Hello and thx for all the info…i will look into the ln298 thing…sounds great so far…i just used the 2 relay/esp01 combo since i have a bucket full of them, single and double relays…when i started with esphome i got a bunch since i got carried away I also have a bunch off wemos d1.
Hope the recent pwm speed controller purchase was not for nothing when i end up with this ln298…
L298 is pwm speed controller…
And very old (from 1970s) and inefficient one, with several volts voltage drop. Worst pick you can make for motor driver. Ok, fair, it’s the cheapest one as well.
What you bought instead?
It gets a bad rap for being inefficient but I think it’s the only one that has a 5v out on the boards that you can power an esp from? I went looking a few times for alternatives after reading similar comments to yours and couldn’t find something with that feature? The "mini"version doesn’t have that feature either.
It has always done the job just fine for my projects. Cheap and cheerful. It’s not like the motors are running for much time for this kind of project. I believe they are reasonable in idle/standby.
D1mini should be fine if you have a bunch. Enough pins there.
Don’t take me wrong. For the price and especially for availability L298 can be good option. And driving a motor for few seconds a day doesn’t ask a lot from driver. I use them. And I use relays as well. But it doesn’t change the fact that it’s not really comparable to modern drivers. Like 1990’s Nokia vs Iphone. For just making a call I even prefer Nokia.
5V voltage regulator on module is not related to the driver itself, but can be practical in some cases. The most important thing is to verify compatibility with motor used, for higher amps the voltage drop can be crucial.
So i ordered a ln298, a bts7960 and a l298n 5ad
The 5 volt i do have already from a step down converter for my current setup.
Right now my setup is made of thsi 5 volt reducer, a HiLetgo 12V~40V 10A PWM DC Motor Speed Control, two relay esp01 board and 2 microswitches.
And thx to the esphome logic hints from u guys, it is working the second day now successful.
As soon i have the other parts, i am going to try a setup with wemos d1 and retrun value if it closed or not.
Thx alot so far