we can control a DC motor using L298N module with NodeMCu d1 mini esp8266
over the Wi-Fi. we were going to have two buttons to increase the speed the motor
will speed up or we will slow it down
very responsive. you can get the code for this by clicking at the link below the
video in the description which will take you to www.robojax.com/leran/arduino
let's get started with this
I've seen a lot of requests and demand for controlling DC motor speed of DC
motors over Wi-Fi with esp8266 so I'm using this L298N module I've written
library for this so it will make make it very easy to control this you have to
watch the introduction to this module l298N with my library the link
will be below this video make sure to run and control a DC motor (without wifi) before coming
to this code so you should be able to control a DC motor with the code with
this module once you're successful then make sure to run a simple hello world (over Wifi)
with this module only without a motor and once that is successful if you have
issue with that I've separate video explaining how to get started I have two
version video one is like three or four minutes just show you immediately to
connect and use this (ESP8266) the other videos false detail of node MCU and also a
separate video for d1 mini so make sure to watch this video and make sure that
you succeed with connecting it over the Wi-Fi after that then you can then come
here and combine both these codes so you will be able to control that motor. I
have created this interface with two push buttons here or two switches when
it's called faster when you press it it increase in increment of 10 and in the
code you can also change it so you can go an increment of five and also also
you can set the minimum because some motors at certain percent of speed will not run
this is a percent of speed of motor not the pulse width modulation value so don't
worry just put zero means stop hundred mean hundred percent speed because the
library will take care of the conversion so you can set the minimum also in the
code let's say your motor starts at fifteen percent so set management of
fifteen and when you press this it will never go below that value now right now
it is 0 so it can go to zero as you can see if you
this is adjustable according to the screen if you have a smaller screen like
say a mobile phone it will perfectly fit in the mobile phone as well
Wiring explained
if you need a wiring diagram for this the wiring diagram will be available as
part of my Arduino at udemy.com the link to my course is below this video. let me now
explain the wiring I've connected this positive at this point these two wires
are my battery the positive is connected here the negative we've connected here
these two wires go to my battery and the voltage that I'm connecting for
the battery determines by this motor if the motor is 12 volts connector wolf if
it is 24 volt connect 24 volts it will work with up to 35 volts and a separate
video explaining that so I'm not going to go through that then from the
negative at this point this is connected to the negative of the this module or
the negative of this module to the ground so you have to connect it to the
ground you must correct otherwise otherwise it will not work if you're
connecting is very USB that's fine if you remove it from USB then you can use
this five volts here this will give you 5 volts out let's say you and you enter
here you connect 6 balls after 35 volts in any case you will get always 5 volts
here and this 5 volts can feed to this module both of these have vu vu so you
can connect external power where the end from this but you can't correct VIN let
me show you first a voltage 5 volts of this I've separate video explaining how
to connect the voltage of different ends the link will be below this video this
motor is connected to this point v motor 1 if you're connecting motor 2 it will
be here so this code is for murder one this is the enable pen enable pin is
connected to d8 this is IN1 is connected to seven and IN2 is
connected to then fix and if you're using this exactly the same way of the
D8, D7, D6 same way if you're using this type of d1 mini again we have the
D8, D7 ,D6 accordingly this will be connected to
the eight d7 and e6
Code Explained
his explanation of the code this will be available as part of my course at udemy
because it takes a lot of time and I have step by step I will explain
everything that you need to know about this code and the HTML page so you can
control the motor and also be able to customize it. the link to my
courses below this video. Let me explain quickly the connection of the code IN1
IN2, IN3 these are the pins I have defined them here as a mapping so you don't
worry whatever is written on the module you just type it here
D6, D7, D8 this is a enable pin and these are the values internally used
here is the important one that you set it either CW you just type CW capital C
W or capital CCW motorDirection and because we are connecting it to motor one this
is one this is displaying the debugging you have to watch my introduction video
to the motor if you don't want the debugging all those text information
just remove it like this this is the URL the add to access the control page.
before even getting the IP so this will make it very
easy and this 5 is the step of increment every time you press this button it goes
in increments of 5 if you put here 20 every time you press it it goes in an
increment of 20. output value this 40 initial value if you want the motors to
run a certain if you want at a zero just type 0 and if you want it 50 whatever
just put set that and motor start with that speed. minimum is the minimum of the speed of
motor where it starts running and this file is needed I will provide you you
just put it in the same folder as the motor (arduino) file for example this is the DC
motor and this is the file put it together in the same folder and as you
can see it and here once you download and have it it will just work fine you
don't worry about it it's already there
Demonstration
let me now demonstrate it I've connected it now to this d1 mini this is the same
chip the code will work absolutely with all. I'm gonna demonstrate it with the
other one and here from the serial monitor we see that this is IP address
that where you can access our module and here if we come here at the browser and
we type that IP address 192.168.1.100 you will see that we are
getting this but this you need to know it every time that you run it you have
to check it here and make sure sometimes the DHCP server or your router will
assign different IP and it will be bothering you for that reason we don't
need to use that so we will use the word here whenever you type that will be
available so in this case robojaxESP8266 I'm just copying it and let's
type it here and as you can see it didn't work because I did not put HTTP
colon slash slash and then if I put that now we can access that this is a serial
monitor that shows that the motor speed is at 40 percent
it also prints it here at 40 percent and here I'm gonna speed this up
now it's a 50% you see the bar graph at 50%
now hundred percent
now it's a 20% I've set the minimum for this at 20% the minimum speed is set
here if we want to set it at 0% you can do so so this is now at 40% let me
refresh the page or reopen it it's a 40% as you can see so if I speed it up it
speeds up 50% slow it down 30% now I'm going down
below 20 as you can see I knew that at 20% this motor will stop but we can go
absolutely to zero
Demonstration with NodeMCU (sorry for spilling mistake)
and now I've connected this NodeMCU you there are different version the
number of pins are different but the chip is exactly the same esp8266 so do not
worry even if you get this for a different version all of them will work
have slowing it down
Twp or maybe just keep it at 80% now it's continuously running at 80% the
direction of rotation is set in the code it's in only one direction
Demonstration with mobile phone
And here is the administration of controlling it from the mobile phone
very responsive
100% present
Demonstration of changing the speed step
now I'm going to change the step increment and make it 5 meaning that
every time you press the steps and here instead of ten it will go five let me
upload the code edit the demonstration of step of five I've changed it and code
now if I increase this you will see it will go in an increment of five
I'm going 65 70 to 95% here it shows in the serial monitor
let me press it continuously zero and the motor is totally stopped now as you
can see at 10% it's not rotating 15 20 barely move 25 starts rotating so you
can go inside the code and perhaps change you tell the minimum if you
change it let's say 20 percent and to never go below that 20. library is
loaded and we are connected now we got connected so if I increase this
forty you see the jump because the previous value was a initial value that
you said in the code was 40
you
Demonstration of full motor control
and here is a demonstration that I have clockwise counterclockwise buttons and
also start and stop if I press the start the motor will start rotating stop it
it will stop if I start the motor I can do that direction change the
direction to clockwise counterclockwise and also
this will be available for my Patrons on Patreaon.com and here is a demonstration using a mobile
phone I'm in the same Wi-Fi network as this one
stop it started change the direction
speed it up
the explanation and codes of video for this will be available as part of my
Arduino course at Udemy.com. The link will be below also this will
be available for people who are my Patrons at patreon.com. account the link for
Patreons.com is available below
I would like to thank my Patrons from Patreons.com
you
Subtitle typed and corrected by Ahmad Shamshiri on May 12, 2020 in COVID-19 Era.
I did my part to help you learn. Now it is your turn.
You can simply thumb up 👍 the video. Subscribe to my channel
and type a word or two in the comment section below. Don't forget to subscribe.
I have also PayPal account if you want to send cash donation. Thank you.
thank you for watching this or how to control the DC model using ESP8266
over the Wi-Fi with L298N module. if you liked this video and
learned something please thumb up 👍 as this will help my video in the search
algorithm of YouTube if you have comment or question posted a comment section
below I try to answer and reply if you want to get updates of my upcoming
videos make sure to subscribe. because this one stop it started change the
direction