Controlling 2 DC Motors using ESP32 and L298N Motor driver

Ғылым және технология

Using Robojax L298N ESP32 Library learn how to control 2 DC motors with PWM features of ESP32. This is the basic code where later it can be used to control motor via WiFi
**** Free Arduino Course worth $200***
Arduino Step by Step Course (over 150 lectures) Starts here robojax.com/L/?id=338
The best thank you for me is to not to skip ads and Subscribe 🔔 to my channel, like 👍 the video It is greatly appreciated. 🔔 😊.
I will reply to all Subscriber's 🔔 questions. So make sure to Subscribe and enable the bell 🔔.😊
**** Purchase L298N Module from **
Amazon USA: amzn.to/3jDvgS5
Amazon Canada: amzn.to/2TuKa2C
All other Amazon: amzn.to/3hOGFRJ
Banggood: www.banggood.com/custlink/GKG...
AliExpress: s.click.aliexpress.com/e/_A6NEWO
** Purchase ESP32 WiFi Bluetooth MCU **
from Amazon USA: amzn.to/3jOW5ob
from Amazon Canada: amzn.to/3rJONVq
from Amazon Europe : amzn.to/3jOW5ob
AlExpress: s.click.aliexpress.com/e/_9iy3MO
Banggood www.banggood.com/custlink/3vm...
Jump to different section of video by clicking on the time:
00:46 Introduction
04:07 Wiring ESP32 with L298N
06:10 Preparing Arduino IDE to work with ESP32 boards
08:15 Arduino Code explained
15:00 Demonstration of single motor control
16:00 Demonstration of controlling 2 DC motors
17:00 Demonstration of Powering of ESP32 from L298N and external power
Download code and resources for this video: robojax.com/L/?id=110
in TB6612FNG chip (have not been tested but it should work. Pleas post comment if it works)
PWMA is ENA in L298N
PWMB is ENB in l298N
Learn Arduino in 30 Minutes (video): robojax.com/L/?id=135
Tutorial by Ahmad Shamshiri form Canada
****************************
Learn Arduino from a proven instructor with 100s of projects, code, wiring diagram in structured course in one place. Purchase Arduino Course at Udemy.com : robojax.com/L/?id=153
****************************
If you found this tutorial helpful, please support me so I can continue creating contents like this. Here is PayPal link paypal.me/robojaxTV
Get early access to my videos by becoming my Patreon and and have your name mentioned at end of very videos I publish on KZread: robojax.com/L/?id=97
If you want to learn Arduino from proven instructor on **Udemy**: bit.ly/rj-udemy
Follow me on Facebook robojaxTV
Follow me on Twitter: / robojaxtv
Follow me on Instagram: / robojax
Tutorial by Robojax.com
Get other projects code and learn Arduino
robojax.com/learn/arduino
#robojax #robojaxL298N #robojaxESP32

Пікірлер: 115

  • @Clarence_13x
    @Clarence_13x11 ай бұрын

    I feel like you are truly the best, I have learned everything from your videos. YOU are the person they were talking about when they said that it's the information age.

  • @jaslarja
    @jaslarja2 жыл бұрын

    could you connect 2 L298N to 1 Esp32 for 4 motors?

  • @shafagh_projects
    @shafagh_projects3 жыл бұрын

    You are a genious. so great tutorial and thanks for t=sharing this with us.

  • @robojax

    @robojax

    3 жыл бұрын

    You are welcome. Here is $200 Arduino course for free Arduino Step by Step Course (over 100 lectures) Starts here robojax.com/L/?id=338

  • @nathanbinene9306
    @nathanbinene93062 жыл бұрын

    hope to hear from you soon

  • @adamelkoumy5141
    @adamelkoumy51414 жыл бұрын

    Thank you Ahmed for such a great video

  • @robojax

    @robojax

    4 жыл бұрын

    You are welcome.

  • @adityaravindran8942
    @adityaravindran89422 жыл бұрын

    I am trying to send a message from a python code over wifi using sockets. but when i do this, the motor isnt running. can someone help me?

  • @nathanbinene9306
    @nathanbinene93062 жыл бұрын

    Hello Ahmad thank you for the video I would like to know what should I have to do for both Motors to run simultaneously in clockwise or anti-clockwise cause I am designing a robot which will have 2 DC Motors however the robot has to move Forward , Backward, Turnleft and Turnright. I am using ESP32 and L298N

  • @robojax

    @robojax

    2 жыл бұрын

    Hello, I believe I have explained every line and what they do. so I would suggest watching the video 2 or 3 times until you understand it. Just see which line in the code makes the motor to run make copy of the same line in the line below it and change the value to make the other motor rurn. or may be watch this video kzread.info/dash/bejne/qaJpppmjYdzIqLw.html and learn which line controls a motor.

  • @gauravtambe6899
    @gauravtambe68994 жыл бұрын

    Hello Sir, Will the program be same for Node Mcu Esp8266??? Liked this video but I need it for esp8266.

  • @robojax

    @robojax

    4 жыл бұрын

    I did not make the video for ESP8266. Here is the video showing how to control it over WiFi. if you learn this (ESP32) video you should be able to use it with ESP8266 from this kzread.info/dash/bejne/mYOBqrdpgZvboKQ.html

  • @chiragshah6873
    @chiragshah6873 Жыл бұрын

    Hi thank you for the video, and all works perfect with a 12v input adapter for my l298n and a microusb 5v laptop power for esp32s. However, if i pull a cable from my l298n 5V to esp32s, the esp32s works but the motor no longer spins. Can you help how i can power both with same source, do i need a bigger adaptor. Adaptor output - 12V DC Current - 2000MA Motor - 12V, 150RPM

  • @robojax

    @robojax

    Жыл бұрын

    supply 5V to ESP32.

  • @chiragshah6873

    @chiragshah6873

    Жыл бұрын

    @@robojax you mean external right.. ?, cant pull from l298n??

  • @kritikaprasan7591
    @kritikaprasan75914 жыл бұрын

    Sir i have lolin nodemcu module ...wat shd I give for preference and which version of nodemcu shd I install

  • @robojax

    @robojax

    4 жыл бұрын

    Hi, here is the video to control motor using NodeMCU kzread.info/dash/bejne/mYOBqrdpgZvboKQ.html

  • @chimpofm
    @chimpofm4 жыл бұрын

    good afternoon Sir. will your L298N code work with a TB6612FNG?

  • @robojax

    @robojax

    4 жыл бұрын

    I have not tested it but it should work. In your hip PWMA is ENA in L298N is and PWMB is ENB

  • @MegaBCAD
    @MegaBCAD4 жыл бұрын

    Can you do a video controlling two 200 watt motors for track steering /differential drive steering with forwards and reverse with a joy stick

  • @robojax

    @robojax

    4 жыл бұрын

    So you wan to control DC motor with joystick? 200W

  • @MegaBCAD

    @MegaBCAD

    4 жыл бұрын

    @@robojax yes like on an electric wheelchair

  • @robojax

    @robojax

    4 жыл бұрын

    Sure I will do the video. I will put in on my list. But the motor controller is of your choice. Because there 100s of types of motor drivers.

  • @k.v.saimadhav4251
    @k.v.saimadhav42513 жыл бұрын

    What is the external power supply you used ?

  • @robojax

    @robojax

    3 жыл бұрын

    there are millions of power supply. You can use $2V module of $500. Here is one kzread.info/dash/bejne/poWYt8iyYNjfhbQ.html that works directly from AC but I have tones of videos showing to get voltage from DC

  • @aadc8173
    @aadc81733 жыл бұрын

    thankyu

  • @bbjodel3778
    @bbjodel3778 Жыл бұрын

    Hello Ahmad how to synchronize two motors with same rpm with a L298N ?

  • @robojax

    @robojax

    Жыл бұрын

    Just use the same value for both motors immediately after one another.

  • @000ahmet
    @000ahmet2 жыл бұрын

    Hi, can nodemcu drive a brushless motor without using esp?

  • @robojax

    @robojax

    2 жыл бұрын

    Hi, brushless motor has three wires and needs Electronic Speed Controller or ESC. that is totally different but yes it can. you just need to feed PWM signal to ESC.

  • @phillipneal8194
    @phillipneal81944 жыл бұрын

    Thank you

  • @robojax

    @robojax

    4 жыл бұрын

    you are welcome.

  • @mattrichardson4351
    @mattrichardson43512 жыл бұрын

    Hi Im doing Up my sons ride on car and need to run two motors off the back and one motor for steering.. I have the ESP32 and the Dual L298N Motor driver model too .. any pointers would help

  • @robojax

    @robojax

    2 жыл бұрын

    Hi, this should work. just identify the pins. check or test be lifting the car and turning it ON. using whatever controller you have try going forward and se which wheels rotate. then turn left and check which motor rotate and the same for right turn. I am not sure if the car has servo to physically turns the wheel or just by controlling the each motor it rotates. My point is to see if 4 motor is used when running the car or just two sets run together. this can be checked to see if two L298N is used or 1. here an one of 4 videos on a smart car kzread.info/dash/bejne/fHibsbuEn8LggZs.html using L298N. Search my channel on more on car. Here is how to find Specific KZread Video in a channel bit.ly/findKZreadVideo

  • @mattrichardson4351

    @mattrichardson4351

    2 жыл бұрын

    @@robojax you absolute legend 🤟🏼I’ll check all the pins and make sure what’s running what .. I know I have two differently on the back but could possibly have a servo motor up front for the steering.. I’ll have to pull it off and have a look and follow your guild more .. will report back later 😀

  • @Kub_43
    @Kub_437 күн бұрын

    Hi, i have a problem with the librery, is not working, im ussing the arduino IDE 2.3.3 and if i run the esp32 2dc motors example, without touching anything of the code, it display errors about "'ledcAttachPin' was not declared in this scope; did you mean 'ledcAttach'?" and 'ledcSetup' was not declared in this scope

  • @Kub_43

    @Kub_43

    7 күн бұрын

    For anyone that faces the same problem, the library is compatible until version 2.0.17, beacause espressif made changes in version 3 to the pwm functionallities. it would be cool to see this library in versions > 3 tho, it simplifies everything

  • @offon8781
    @offon87814 жыл бұрын

    is there a way to use this library to run the motors with rotations instead of speed?

  • @robojax

    @robojax

    4 жыл бұрын

    You made me watch the video to what is wrong. this is for Speed and Direction of rotation.

  • @offon8781

    @offon8781

    4 жыл бұрын

    @@robojax is there more documentation of this library, such as a list of commands?

  • @robojax

    @robojax

    4 жыл бұрын

    I am replying now after 14 hours. you could just click on our channel name "Robojax" and then search for L298N . So 14 hour waiting is very long. here is kzread.infosearch?query=L298N

  • @srimansingaravelan
    @srimansingaravelan2 жыл бұрын

    hi robojax my esp32 is written in d series and pin 17 16 not available please help, and i want to write code for two l29n for four motor through wifi

  • @robojax

    @robojax

    2 жыл бұрын

    Hi, please watch this for WiFi kzread.info/dash/bejne/gaClmrCRl7Hfg6Q.html Here is how to find Specific KZread Video in a channel bit.ly/findKZreadVideo

  • @philippeantonietti
    @philippeantonietti4 жыл бұрын

    thank you has worked fine with my esp32, i would just suggest some kind of schematics showing the pin connection suggestion for a new video: have you tried to do this with the "Blynk" mobile app ? I'm trying to do this as they have a nice interface with joystick thanks !!!!

  • @robojax

    @robojax

    4 жыл бұрын

    You are welcome. the wiring diagram is available at my Arduino course at Udemy.com so anyone who purchase the course, gets wiring and more. I have seen 3 or 4 more people mentioned the word "blynk" and when I checked it I did not like it . They should offer some free option for limited access for students . I am search ing for other option and until then, I will not participate with this operation. they should offer free or limited device like 5 device or 5 project . Then they should charge for commercial projects.

  • @philippeantonietti

    @philippeantonietti

    4 жыл бұрын

    @@robojax yes I agree that makes sense, the free option which they offer is very limited! you won't be able to get much done. Try to email they, as a digital media 'influencer' you may be able to get some extra benefits to your followers, best regards

  • @robojax

    @robojax

    4 жыл бұрын

    someone should offer like 2 to 5 device full feature for free.

  • @TN-qr1cm
    @TN-qr1cm Жыл бұрын

    I tried the same experiment but I cannot get both motors to run at the same time they run interchangeably: one runs and the other is not then they switch. do you know why is that?

  • @robojax

    @robojax

    Жыл бұрын

    if you have not changed the code, then wiring is wrong. check it.

  • @mewiipk
    @mewiipk4 жыл бұрын

    Hello, I run your code and it says that "... Arduino/libraries/robojax_L298N-DC-Motor_library/Robojax_L298N_DC_motor.cpp:157:34: error: 'analogWrite' was not declared in this scope analogWrite(enPin, toPWM(value)); ^ exit status 1 Error compiling for board ESP32 Wrover Module." What should I do?

  • @robojax

    @robojax

    4 жыл бұрын

    Hello, It means you have escaped the video and not fully watched it. Please watch and follow the instruction.

  • @alexandruflorea4764

    @alexandruflorea4764

    7 ай бұрын

    @@robojax you are saying the same thing for each issue, let's be honest, you don't know. With my issue, I watched your full video 10 times and didn't solve anything. Very bad library.

  • @fawahziwah
    @fawahziwah3 жыл бұрын

    Hello Ahmed, great video you have there! But can i ask a question. Why do i get this error whenever i tried compiling the codes? Hope u can help, thanks! no matching function for call to 'Robojax_L298N_DC_motor::Robojax_L298N_DC_motor(int, int, int, int, int, int, int, int)'

  • @robojax

    @robojax

    3 жыл бұрын

    It means you did not watch the video fully and skipped. I have mentioned and shown to install library. So follow the instruction and install the library.

  • @fawahziwah

    @fawahziwah

    3 жыл бұрын

    @@robojax i watched and rewatched your video for countless time. Already install the library from the zip files as u did. Did exactly the same. But still getting the same error. My friends who used this library last year also have the same problem this year, last time it was fine. Mind to tell us where we did wrong?

  • @alexandruflorea4764

    @alexandruflorea4764

    7 ай бұрын

    this is top secret, I have the same issue and couldn't solve. Watched the video many times, not sure what I'm doing wrong.

  • @bendenoooo3025
    @bendenoooo30254 жыл бұрын

    Nice

  • @robojax

    @robojax

    4 жыл бұрын

    Thanks

  • @zarrougahmed1949
    @zarrougahmed19494 жыл бұрын

    Can you make a video about sending messages using two ESP32 please.

  • @robojax

    @robojax

    4 жыл бұрын

    sending messages from one to the other you mean? with Router or without Router?

  • @zarrougahmed1949

    @zarrougahmed1949

    4 жыл бұрын

    @@robojax Without a router. Can we send it for example using the serial monitor?

  • @thealked2674
    @thealked26743 жыл бұрын

    Hello Is there a way to control the motors via the serial port?

  • @robojax

    @robojax

    3 жыл бұрын

    Hello, I've shown how to control a 360 servo in this video kzread.info/dash/bejne/lJOs2Ndvp7rHlqQ.html and you can use the same method to control DC motor. But you have to understand the this DC motor .

  • @thealked2674

    @thealked2674

    3 жыл бұрын

    @@robojax Thanks, it helped me I have a question if I wanted to control 4 motors, how should I configure this line of code? or what should I do?Robojax_L298N_DC_motor robot2(IN1, IN2, ENA, CHA, IN3, IN4, ENB, CHB);

  • @robojax

    @robojax

    3 жыл бұрын

    watch the video carefully in the code section. I mentioned "we create object" called motor. then you create another object called motorB. So the object motor will be for motor1 and motor2 but motorB will be for motor 3 and 4. Or watch my other videos so you learn the meaning of object . See all my videos on L298N kzread.infosearch?query=L298N

  • @martijncuijpers-ww1vs
    @martijncuijpers-ww1vsАй бұрын

    Is it possible to use 2 L298N modules to control 4 DC motors using ESP32? I tried to modify the code but i really get stuck. I want to control them by wifi. With 2 motors and you library works really good, but we always want more :) thanks in advance!

  • @robojax

    @robojax

    Ай бұрын

    Yes if you have enough pins. Just define different ping and different object name.

  • @martijncuijpers-ww1vs

    @martijncuijpers-ww1vs

    Ай бұрын

    Do you have any code for this?😇. I managed to modify the .ino file, but both .h files and the cpp file are more challeging. Maybe you have some tips how to easy modify those files? I am a beginner in programming....😂

  • @highfacility9200
    @highfacility92003 жыл бұрын

    How can i install progtam to esp32 ? I need pin links pls.

  • @robojax

    @robojax

    3 жыл бұрын

    which link? have you watched the video? int the first 40 seconds I said "you can get the code by clicking on the link below the video in the description". Please watch it fully without skipping, you will have no questions left. I have not wasted time. it is about learning.

  • @kenadams4246
    @kenadams42464 жыл бұрын

    Thank you Ahmad for a very nice video. I am very excited to get started on this project but I'm having issues. Please help me find out what I am doing wrong. After using the Board Manager to install files for the ESP32, I downloaded the Library you provided a link to, "Robojax_ESP8266_DC_motor_speed.zip". After adding/installing the library, I closed the Arduino IDE, restarted it and found there were 2 issues: 1) After looking through File>Examples, these were no examples listed as Robojax (i.e. no Robojax ESP L298N DC Motor or anything Robojax). 2) I did go ahead and open the sketch that was in the Library file you provided. I attempted to compile it and got the error message, "Robojax_ESP_L298N_DC_motor.h: No such file or directory". Thank you in advance for pointing me in the right direction.

  • @robojax

    @robojax

    4 жыл бұрын

    You are welcome. Thank you for letting me know. I had updated the library and forgot to update this page. Now you can download and try it. Thank you for not skipping the ads and keep watching it. This will help me a lot.

  • @kenadams4246

    @kenadams4246

    4 жыл бұрын

    @@robojax Thanks for the updated info. I will give it a try. On a related note, based on everything I have read, I am surprised the L298N works with the ESP32. It is my understanding that the L298N requires a 5 volt signal on the logic inputs while the ESP32's output is 3.3V. Would it be more reliable to use a logic level shifter to take the 3.3V up to 5V? Just curious. Thanks again for the tutorial!

  • @robojax

    @robojax

    4 жыл бұрын

    I have tested it and it works without any issue. For 3.3V and 5V logic, the LOW is up to 0.8V so this module works fine.

  • @kenadams4246

    @kenadams4246

    4 жыл бұрын

    I gave the updated code a try and it works great! Thanks again Ahmad for an awesome project and video! I hope you continue to post amazing projects like this!👍👍

  • @viveksharma_23
    @viveksharma_234 ай бұрын

    Can we connect 4 bo motors to motor driver plz reply ?

  • @robojax

    @robojax

    4 ай бұрын

    Please watch and get the answer

  • @viveksharma_23

    @viveksharma_23

    4 ай бұрын

    Watched downloaded too I am constructing a automatic firefighting robot with 4 bo motorz

  • @polycrusAct
    @polycrusAct3 жыл бұрын

    make with one servo motor and with dc motor 😺😺i'm from brazil, 🇧🇷 sp

  • @robojax

    @robojax

    3 жыл бұрын

    Welcome from Brazil. Sorry I did not understand. you want to have both servo motor and dc motor? this is very unusual. I have so many servo related videos. if you watch them, you can combine both together. ***** Free Arduino Course worth $200**** Arduino Step by Step Course (over 100 lectures) Starts here robojax.com/L/?id=338

  • @malalatianarajaomason518
    @malalatianarajaomason5183 жыл бұрын

    Hi Ahmed, I tried your tutorial on my esp wroom 32. But after compiling, I got this message " Leaving, Hard resetting with RTS pin". And I'm stuck there. Do you have an idea? Thank you in advance

  • @robojax

    @robojax

    3 жыл бұрын

    Start with this kzread.info/dash/bejne/ZoODqM6MZ5jVp6Q.html make sure you can turn ON and OFF LED. then come back to the motor.

  • @malalatianarajaomason518

    @malalatianarajaomason518

    3 жыл бұрын

    @@robojax Thank you Ahmed.

  • @robojax

    @robojax

    3 жыл бұрын

    You are welcome.

  • @lassemikkelsen3687
    @lassemikkelsen3687 Жыл бұрын

    i tryed your code but one motor is driving faster than the other one how?

  • @robojax

    @robojax

    Жыл бұрын

    the code is fine. you may have two different motors. if you are using it for the same project, get identical motors.

  • @sssedo1573
    @sssedo15732 жыл бұрын

    Do you get a code without your library?

  • @robojax

    @robojax

    2 жыл бұрын

    Please watch the section where I explained the code and do exactly as I have mentioned

  • @sssedo1573

    @sssedo1573

    2 жыл бұрын

    @@robojax hmm but I wanted to make it on my own with pwm and control 2 motors. Is there any possibility maybe you look up my code and tell me what I did wrong?

  • @khansarh4444
    @khansarh4444 Жыл бұрын

    what the controler ?? theacer ? pliss

  • @robojax

    @robojax

    Жыл бұрын

    What? Do you mean the microcontroller? Learn here kzread.info/dash/bejne/X2F6zJqKdM-tpbQ.html

  • @phillipneal8194
    @phillipneal81944 жыл бұрын

    I am getting the 'analogWrite' error message. It comes from the robojax library

  • @robojax

    @robojax

    4 жыл бұрын

    I have tested this many times. please post the error here

  • @phillipneal8194

    @phillipneal8194

    4 жыл бұрын

    @@robojax Arduino: 1.8.10 (Mac OS X), Board: "ESP32 Dev Module, Disabled, Default 4MB with spiffs (1.2MB APP/1.5MB SPIFFS), 240MHz (WiFi/BT), QIO, 80MHz, 4MB (32Mb), 921600, None" /Users/pneal/esp32/libraries/robojax_L298N-DC-Motor_library/Robojax_L298N_DC_motor.cpp: In member function 'void Robojax_L298N_DC_motor::rotate(int, int, int)': /Users/pneal/esp32/libraries/robojax_L298N-DC-Motor_library/Robojax_L298N_DC_motor.cpp:157:34: error: 'analogWrite' was not declared in this scope analogWrite(enPin, toPWM(value)); ^ Multiple libraries were found for "Robojax_L298N_DC_motor.h" Used: /Users/pneal/esp32/libraries/robojax_L298N-DC-Motor_library exit status 1 Error compiling for board ESP32 Dev Module. This report would have more information with "Show verbose output during compilation" option enabled in File -> Preferences.

  • @robojax

    @robojax

    4 жыл бұрын

    It says "Multiple libraries were found for "Robojax_L298N_DC_motor.h" please delete the older one.

  • @phillipneal8194

    @phillipneal8194

    4 жыл бұрын

    @@robojax HI ! Ok. I did as you said and now it compiles, loads and runs. Thank you very much.

  • @robojax

    @robojax

    4 жыл бұрын

    You are welcome. I am glad you resolved it.

  • @ailefy9898
    @ailefy98983 жыл бұрын

    can you please make a Bluetooth car with esp32 and this L298N motor driver please, please I request you

  • @robojax

    @robojax

    3 жыл бұрын

    interesting. this would be very useful. But my list is full other projects.

  • @ailefy9898

    @ailefy9898

    3 жыл бұрын

    thank you for responding sir .any youtuber didn't respond to me till now except you!

  • @roscoe3dp470

    @roscoe3dp470

    3 жыл бұрын

    @@ailefy9898 Esp 32 and a PS3 controller via Bluetooth

  • @roscoe3dp470

    @roscoe3dp470

    3 жыл бұрын

    kzread.info/dash/bejne/i5x6yNSDppO7dNI.html

  • @bbjodel3778
    @bbjodel3778 Жыл бұрын

    Ok Ahmad, thank you, but i don't have a same rpm.....

  • @robojax

    @robojax

    Жыл бұрын

    You should get them same rom if enough power is supplied to the motor. Check thr motor w voltage while running and if it is too low it means your power supply can’t supply enough power (cut) power supply to the motors. Use different power supply

  • @user-nh5zh7ot5w
    @user-nh5zh7ot5w2 жыл бұрын

    Please give me the code of ESP32.

  • @robojax

    @robojax

    2 жыл бұрын

    Have you watch the video? I mentioned it in the first few minutes of the video.!

  • @viveksharma_23
    @viveksharma_234 ай бұрын

    My esp 32 has only 15 pins and your is having 20 how ?

  • @robojax

    @robojax

    4 ай бұрын

    ESP32 has fixed pins. it is offered as different board. if you don't see the required pins, then get the one that has 30pin .

  • @fusion-ux1zz
    @fusion-ux1zz4 жыл бұрын

    who els think he have a sexy voice , ty for video

  • @robojax

    @robojax

    4 жыл бұрын

    You are welcome.

Келесі