Placeholder Image

Subtitles section Play video

  • please go to the line, the computer guy dot com, and failed normal dot com to see the videos that are too dangerous for YouTube.

  • Welcome back.

  • So in today's video, we're going to be using our we know you know, a WiFi and L 298 in motor module, a fan and an analog temperature sensor to be able to create a wireless sensor that will be able to give you notifications and you'll be able to manually trigger a fan.

  • So a lot of the projects that we do, we have some type of sensor.

  • And then that sensor is what automatically triggers a physical event happen.

  • What's going to happen in today's project is we're gonna have the analog temperature sensor.

  • Basically, the Arduino, you know is going to continuously read from the analog temperature sensor, and then it's going to give an output that we can see in a Web browser, so it will show us a very big number for the temperature.

  • If the temperature is within the cool level, that number will be green.

  • If the temperature is in the yellow like the medium level, it will be yellow.

  • And if the temperature is in the high level, the temperature will be read.

  • Then, under that, there will be a manual links so that you can click and manually turn a fan on or manually turn a fan off.

  • So this is an important thing to be thinking about when you're administering systems.

  • Now it is great, and it is amazing to be able to have physical events happen automatically.

  • That is just an awesome thing to have happen, but there are.

  • Sometimes there are.

  • Sometimes you want to know that there is a problem, but you don't want systems to automatically try to rectify the problem.

  • You simply want to know that there's a problem and then be able to trigger a physical event to happen.

  • So what this is going to d'oh is this is going to continuously read from this analog temperature sensor.

  • Provide that in a format that you can use in a Web browser, and then if the temperature gets too high and you decide to turn on the fan, then you can click on a link and turn on the fan.

  • So with that, let's go over the work bench so I can show you the components that are involved in this project.

  • Then I'll show you the code and then I'll show you how it all comes together.

  • So here is the project as it's been built.

  • Unfortunately, this looks a little bit of like a mess, but I'll try to explain everything going on here.

  • So the important components for this basically what allows all of the actions of the outputs that take place is we have our art.

  • We know you know why.

  • Five board here and we have the l 298 in motor module here.

  • So these are the two main components that will give us the intelligence and the ability to actually trigger things such as the fan being turned up.

  • Now, if we're going to take a look at this l 298 in a motor module, one of the things I have talked about in the past with these models is that there are multiple ways in order to power the module and a power the whole system.

  • When you're using one of these models, one of the ways that you could do it is you can actually use the ven the pen on the Arduino board in order to power of the module.

  • Another way that you can power the module is simply by connecting it to a to a 12 volt or up to a 35 will power supply and connecting the yard.

  • We know on its own circuit.

  • Or you can connect this with up to a 35 hold power supply and then connect the Arduino to the L 298 and module.

  • What I've decided to do today is just keep this on two separate circuits.

  • So the l 2 90 in module is being powered by this 12 01 connector power supply.

  • And then the Arduino currently is simply being powered off of the computer.

  • So realize power is coming in from two different sides.

  • Now, One of the reasons that I did this is that we're having a weird problem with the analog temperature sensor.

  • The M L.

  • A temperature sensor was acting really quirky when I actually connected the power supplies and these things were trying thio power each other when nothing was connected, it would work fine.

  • But when I would connect the 12 volt power supply to the Arduino board, power would come in power would come in to the analog temperature sensor, but the output that would come out would get all wonky.

  • I'm honestly not sure why that occurred, but it was a problem that, frankly, I couldn't get around.

  • So the way to get around it was by simply putting these these two devices on different circuits.

  • So this is what the l 298 and is getting powered off of.

  • And then you could have the Arduino board be powered off a computer USB battery pack something like that.

  • Now, one of things you'll notice I have the power connector here.

  • He uses a normal barrel connector, and what I've done is I've used one of these cool little adapters.

  • So these air nice adapters, you could buy a whole pack of five for about $6.

  • And what this allows you to do is it allows you to take a normal barrel power connector into one side and then be able to split that out to normal wires on the other side.

  • So that's what I've done here.

  • So this is a normal power adapter with the barrel connector that comes into this adapter.

  • This adapter that allows me to screw down your ground and your VCC wires in the ground vcc wires, then going through the l 298 model.

  • So this is a great valuable little thing, then passed that as far as the L 298 and Margo goes one side, I've connected the fan s o.

  • The positive is into, uh, I am one the ground, isn't it?

  • I to ports on the l 298 and module and that goes the fan.

  • And so this allows me to power the fan and turn the fan on and off from the Arduino board.

  • Then for the Arduino board we have, they're doing a boar connected in a so the e n a wire.

  • This is what controls the speed of the motor or the fan.

  • So we have the wire, we have the eye and one wire, and we have the eye and to wire those come over to the digital side on the art, you know, you know, with WiFi then past that.

  • So all of this, all of this is what's required for the motor.

  • But then again, we also have the temperature sensors.

  • We have our analog temperature sensor over here again.

  • As always, we have 50 for VCC power.

  • We have the ground and then the the centre.

  • The centre wire goes for the analog sensor.

  • And so that comes over.

  • And I have that plug into a five today.

  • So basically, this is how everything is set up compared to how we've dealt with the l 298 in motor module before.

  • The really only difference here is that we are putting it on its own circuit.

  • And again, this is an important thing to understand.

  • Whenever you're dealing with Arduino projects is remember the artery No board itself.

  • It can always support upto 12:01 a.m. So if you try and put a more power through, you most likely blow it up, which is bad.

  • And so when the questions is well, how how are you going to control motors?

  • How are you going to control electrical devices that require far more power than 12 volts?

  • That's where you could use something like this motor molecule.

  • So this motor module is able to support up to 35 holes.

  • Some of these motor modules, depending on whether specific specifications are may be able to support up to 45 golds.

  • So what, you could d'oh!

  • As you can have your old wino board on one power, surf it and then just have the control wires coming over to the other electrical stuff that you've set up and then these air able to run off of more voltage.

  • So again, think about this for things like water pumps.

  • Again, fans remember, fans will basically spend as much powers you put through there, although spend faster and faster, that type of thing.

  • And so this is a reason why you may want to have everything on separate electrical circuits, but this is basically what we have set up for here.

  • I hope that makes sense.

  • I know it's getting a little confusing.

  • There's a lot of stuff going on, but really, if you just, you just go through and look at the code and you look at everything, you realize that it's actually not that complicated so that let's go over and take a look at the code.

  • So here's a code for this particular project.

  • It may seem a little bit complicated at first blush, but what you'll notice if you take a look at it is really We're just doing a lot of copy pasting a little bit of modification and add on to all the projects that we have done in the past and again.

  • That's really what any project is.

  • You take all the little components you created before blew them or duct taped them together to get something a lot larger.

  • So the first thing that we're going to do is we're gonna have to include the libraries for the WiFi communication SP I not H and WiFi Naina.

  • So this will allow us to communicate with yard.

  • We know board over wifi.

  • Instance, we have that analog temperature sensor.

  • We have to define the temperature sensor pen.

  • So to find a temp sensor a five so the temperature sensor is going to connect to analog pan five.

  • Then we have to define the pins that are going to be required for the motor module s o on the motor manual.

  • E n A.

  • There's a pen called e n A and that is for speed.

  • There's I in one, and I and two I, and one is the first power pen on the motor module.

  • Ianto is the second.

  • And so speed is going to go to digital pen eight on there.

  • We know born I and one will get a digital pin nine and Ianto, go to Dick.

  • It'll pan 10.

  • They were gonna go down.

  • We're gonna set up everything for the WiFi.

  • So P r s s I d equals test.

  • I have a guest WiFi network set up on my network.

  • I have simply put the s s i d to test we have a car password.

  • If you have a password for your your network.

  • This is where you would put it in.

  • I have left mine blank.

  • Yes, I don't have to troubleshoot crappy password things while I'm doing all of this.

  • Then we have end key index.

  • If you're using multiple keys on your wife, I You would put something in here again.

  • 012345678 We don't have anything to worry about.

  • So it's just said it.

  • Zero then passed that we're going to create a variable for the status for the WiFi connection or just don't set that w ell idol status.

  • Then we're going to have a WiFi server and we're going to set the server to port 80.

  • So if there's a reason you want to be on a different poor, let's say you're doing pork forwarded from the outside world.

  • So maybe you want to do it on a different port.

  • For some reason, this is where you would change that port number.

  • Then we're gonna have a variable string and read a string.

  • This is going to be the variable that we're going to use to actually be able to turn the motor module on and off.

  • We'll deal with that later.

  • And then we create to an integer variables for temperature.

  • So high temperature equals 82.

  • So it's 82 or above.

  • It will be considered a high temperature here and good temp.

  • So good temperature is we're just going to say, 76 or below.

  • So this gives us the variables for the temperatures so we can come back to this one place and modify the values for those variables.

  • If we need Thio, no, we're gonna do is we're gonna come down here.

  • I'm going to Southie Environment that this sketch is going to run in, so we do pin mode e n a I and one eye and two and we all set those two output those air digital pins so on, they're going to be sending information to the motor module, so we send them to output.

  • Then what we're going to do with that E and a pen is we're gonna analog right in a 2 55 So basically, we're writing to the e n a pen, and we're saying what speed we want the motor to run at.

  • We're setting it at 2 55 so you can change the speed with the motor.

  • Michael, between 022 55 0 is the slowest 2 55 is the fastest.

  • So you can modify that depending on what you want to dio.

  • I just sent it to the highest speed to make life easier for me.

  • Then we're only serial dot began.

  • So this, of course, starts the serial monitor so we can get some output from the cereal monitor while we're doing troubleshooting that such then pass that we're going to do what's required in order to set up the WiFi, actually connect to the WiFi.

  • So while status does not equal w l connected, it's going to print, attempting to connect to network named That's gonna be SS.

  • It's gonna be a test.

  • So it's gonna be attempting to connect to network name test.

  • Then status equals and he uses dysfunction.

  • WiFi not begin as this.

  • I d pass this passes this S s I d passes the password, tries to connect your WiFi delays for 10,000 milliseconds or 10 seconds.

  • So while that's little being this is what you see.

  • Once it is finally connected than we do server dot Begin, and then it will print out that the s s I d.

  • So you are connected to the S S I d.

  • And it will print out your I p address all on the serial monitors, A serial monitor.

  • You can take a look with the I P addresses, and then you can use that to get into the Web browser and be able to access the Arduino.

  • Then we're going to get down the meat and potatoes the actual loop of this particular sketch.

  • The first thing within this loop is all the math that is required in order to figure out what the temperature is.

  • So this is again copy and paste from all of our other analog temperature projects Reading voltage temperature, See temperature f This just this just pulls in, pulls in the information from the analog a temperature sensor on, then turns that into something that we can actually use for this.

  • We actually care about temperature after bitter Fahrenheit.