Hi, I have been trying to run a dc motor on my raspberry pi3 through homeassistant, So can anyone please tell me how to do so? I have created a ciruit for my dc motor involving external power supply module and L293D. I am not sure how to configure the dc motor on homeassistant to make it run clockwise and anti-clockwise. Thanks
Assuming you are using a raspberry pi and have the L293D configured like this:
You just need to define two GPIO switches to control it (1A and 1B). Tie the EN pin High. Turn on switch 1A and turn 2A off to go one direction or turn on 2A and turn off 1A to go the opposite direction.
The 3.3V logic of the Pi is compatible with the electrical input specification of the L293D without further level shifting or buffer circuitry.
e.g.
switch:
- platform: rpi_gpio
ports:
6: 1A
13: 2A
As well as connecting the two control pins to the PI GPIO, connect one of the Pi’s GND pins to the L293D GND.
Once you have that working a more intuitive user interface might be to use an input_select called DIRECTION to define FORWARD and BACKWARD. Use an automation that triggers on a change of the input_select to set the 1A and 2A switches to the correct values. Then have a third GPIO switch connected to the EN input and call this switch RUN MOTOR.
Thank You for the speedy response @tom_l. I am very new to home assistant and I was not sure of how to do this. I tried following what you said but my motor did not work when I turned on 1A but not 2A and vice versa. I have a feeling that something is wrong with my circuit.
I followed this video to do my ciruit: https://www.youtube.com/watch?v=9vOtwiIV2V0
Could you please check if the ciruit is correct as I am not sure about it (i am only 14 lol). Hope I am not asking for much. Thanks!!!
Yep that is the circuit. However it uses GPIO port 27 for ENABLE, GPIO 17 for 2A and GPIO 18 for 2A. So your Switches should be defined like this:
switch:
- platform: rpi_gpio
ports:
18: 1A
17: 2A
27: EN
Hi @tom_l. I tried following what you told me to do but the motor did not work. I thought the motor was faulty but it is working when attached to a battery and I also checked the two end of the circuit that go to the motor with an LED light and the circuit is complete. I think there is not sufficient current reaching the motor and therefore the motor is not working when attached at the end of the circuit. Any suggestions?
@tom_l. I found the problem. There was not enough current reaching the motor therefore I had to increase the amount of input voltage so that enough current reached the motor. So, I increased the input from 5v to 7.5v and i think that anything between 6.5v and 12v should work. So, now I am able to control the dc motor with pi and able to make it go forward and backwards. Thank you for your help @tom_l.
Glad to hear you got it working. Good effort.