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 this video, we're going to use a 16 by two LCD screen.

  • We're going to use an analog temperature sensor, and for this we're going to create a temperature alert system.

  • So imagine we have a server room again.

  • So we have the server room.

  • And if the temperature is in the server room is a particular level or below a particular level, everything is good.

  • So let's say if the temperature is below, let's say 73 degrees, everything's good.

  • The servers are fine.

  • You have no problems.

  • But if the temperature gets between, let's say 73 degrees toe 80 degrees, maybe you want an alert to be notified to know that Oh, the temperature is higher than it should be.

  • Now, if it's below 80 degrees, your servers are gonna shut down.

  • Your networking equipment isn't gonna have a problem, but but you should be worried.

  • You should.

  • You should be a little bit concerned there.

  • Maybe you have to clean out the air conditioning filter something like that to get it back to the level that it should be.

  • So basically, we just wanted alert.

  • We just want Hey, the temperature is a little too high.

  • You might want to take a look at this, but then one of the temperature gets above 80 degrees above 80 degrees.

  • You gonna let the servers in there?

  • All the equipment in there.

  • That's a point in time that you may start to worry about your equipment either now working as well or actually thermal thermally shutting down and really causing a lot of problems.

  • So in that instance, not only do you wanna have award, you have what you want to have a warning, but you also wanna have an actionable notification.

  • What I mean by an actionable actionable about notification is not simply telling the end user that there is a problem, but also telling them what the hell to d'oh!

  • This is one of the biggest problems in I t world.

  • One of the biggest problems when people create user experience for notification systems is don't do things like no create right lights.

  • They'll create red lights.

  • So the end user knows there's a problem.

  • They absolutely No, there's a problem.

  • The problem is the end use.

  • It really doesn't know what to do about the problem, right?

  • So in this particular project we're going to do is once it gets to that warning level, once it gets about 80 degrees, it's going to show the temperature.

  • And then it's also going to flip and it's going to say, Call this guy Bob And here's his phone number.

  • So not only is there a major problem that has to be dealt with, but here is an actionable task you can d'oh!

  • Here's the thing.

  • It the temperature is too high.

  • Call this guy Bob at this particular number.

  • And so this is one of those things that you really have to start thinking about in the i o T world on your Arduino world, as you designed everything you're designing, the interfaces you're designing, how things will be computed.

  • You're designing the output.

  • And so one of the things that you need to think about is a kid.

  • You don't just tell the end user there's a problem.

  • You also tell him what the hell they should do about, even if all they should do is call somebody That's one of the biggest problems in the I t world is the end user.

  • They knew there was a problem.

  • They just didn't know who wouldn't tell.

  • So what we're going to do in this particular project is we're going to tell them who to call.

  • So with that, let's go over the work back.

  • Yeah, I'll show you the components we need for this project that will show you the code.

  • I'll show you it all put together and show you why this is really a pretty cool project.

  • So here, the major components that we're going to need for this project.

  • So of course, we're going to be needing a bread board.

  • We're gonna be meeting that 16 by two LCD screen.

  • We're using the yard, we know, you know, as we normally do with this particular project.

  • Now again, as with most projects, other other boards should work to be able to build this, have a project.

  • But in order to run this particular screen, you do need a lot of digital pens s.

  • So just make sure you have enough digital pins for whatever board that you're using.

  • Then we're going to be using a single single 220 0 resister that will be used for the LCD screen.

  • And then, of course, a potentially ometer.

  • Oh, again.

  • Whatever you think, Yama, you get this kind of a crappy one here that when I use a little bit better but you're gonna need a potentially ometer again.

  • This is just a variable resistor.

  • So we take put all that to the side, Then we can take a look at how this thing looks actually being built.

  • So I've done other videos talking about howto build all the circuitry for the LCD screen here.

  • And so that's been a painting again.

  • You'll notice you need a lot of wires.

  • You need a lot of campers you have resister in here.

  • So there's a lot that goes into building this LCD screen system.

  • So we're not talking about this in this particular project.

  • Go and look at the previous project I've done about that.

  • Basically, all we have here is this all this this way is the standard LCD screen project.

  • And then what we've added is we've added the analog temperature sensor down here again.

  • We have positive we have the negative and then we have the sensor pen, and that's an analog again.

  • Analog sensor pen goes to the analog pens that goes over a zero on the Arduino board.

  • And so this is what the project looks like when it's built.

  • Let's go over and take a look at the code, so this is the code for this project.

  • Now this code is starting to get a little bit long.

  • But if you go and you take a look at it line by line, you'll realize that it's really not that complicated.

  • And frankly, a lot of it is simply copy and paste from other areas.

  • So if you look at the if the l stiff and the else statement right here, you'll notice most of this is identical.

  • We've just we've just added, or we've modified a few different variables and things in there.

  • So let's go up and take a look at the top.

  • So we're using the LCD display the liquid crystal display, So in order to do that, we are going to need the liquid crystal, not age.

  • This is the liquid crystal alive, or it's a pound include the liquid crystal library.

  • The next thing we're going to do is where you wanted to find pound to find the sensor pen.

  • So this is for the analog a temperature sensor.

  • So the sensor pen we're going to put to a zero, Then we're gonna go down here, and we're going to write out a lot of stuff that's required for the LCD screen.

  • So we're gonna define all these different pens.

  • R S E n d 45 d 67 These air all pins actually on the LCD screen itself and then 12 11 543 and two.

  • These are pins that are on the Arduino.

  • Boards were going todo define those pins corresponding.

  • And then we're gonna do is we're gonna be the liquid crystal.

  • We're going tol CD function, and then we're going to tell the LCD screen where these particular pens are.

  • So this is required in order to make the LCD screen work more or less.

  • All of this right here.

  • It just is this You put it in there and you just leave it alone.

  • That's just how it gets right then.

  • One of things we're gonna do is we're going to create a variable and end for plus minus so we're going to be doing with this is we're going to read out the temperature and then beside that, we're going to show whether it's above or below, whatever the optimum temperature is.

  • So if the temperature is too high, not only will, let's say, 80 degrees and warning, but I will say 80 degrees like plus seven, So it's seven degrees above the optimal temperature.

  • It's at 60 degrees on the optimal temperature is 73 when it's going to say they'll say 60 minus 13 again, this gives you a little bit better idea about how the cooling is working, right?

  • Are you right at the limits?

  • Are you well above or below the limits?

  • Just gets a little bit of additional information that might be useful to the end users.

  • They were going to come down, and we're going to set up the environment.

  • The loop is going to run.

  • In order to do that, we're going to do LCD dot begin, and we're going to say what kind of LCD screen we have.

  • So it's a 16 column so 16 characters across Bye to row, two characters up and down, right, so 16 by two And so we use this in order to do, like, the cursor settings and all that, because you actually you actually have to tell the code where to start typing things out.

  • What could be a bit of a pain, But we're gonna go down here, and the first thing that we're going to do is we're going to do the standard code for temperature, Right?

  • So in standard code for Santa cure any kind of analog temperature sensor project basically copy and paste this in there, end reading equals that you're gonna analog read from the sensor pen to in order to get once you get that, you're going to be the voltage secret afloat a decimal point.

  • So 10.1 25 or whatever is what flotus so bolted equals reading times five voltage.

  • You will then take this.

  • That is what voltage will equal.

  • And then you will divide that number by 1024 and then set the value of voltage tow whatever the results is, that's what it means when you have something like this.

  • So it's plus equals minus equals, divided by equals.

  • Times equals what you dio is you.

  • You do that to this side, and then you set the value of the variable that.

  • Then we're going to create a float for temperature seat.

  • So temperature Celsius ball change minus 0.5 times 100.

  • But here in the U.

  • S.

  • We used temperature Fahrenheit.

  • So we're going to create a float temperature F equals temperature.

  • See times nine, divided by five plus 32.

  • Again, this is all your copy and paste, but going over a little bit just to just to make sure everybody remembers.

  • Then what we're gonna do is we're now going to go into the if l if else if else statement basically printing things out, this will be printing out the alert on Sunday.

  • So the first thing that we need to do is we need to use the LCD a not clear function.

  • So what this is going to do is this is going to clear the LCD screen.

  • Basically, think of this as this is turning all the characters too low, right?

  • So I thought about that before, when you're dealing with, like, LCD are led.

  • I'm sorry.

  • Led lights.

  • When you turn led lights on.

  • You also have to to remember to turn them off, right?

  • So if you if you turn one led light on in a certain situation and you forget to turn it off and then you turn another led light on in a different situation, then all the led lights are turned on and you never turn them off.

  • You can have the same problem with the LCD screen where, if you have, if you have text that takes up, a different amounts of space is on your screen.

  • Then, when you flip between different text, some of the characters won't reset, so you'll get some really weird issues.

  • So if you want to just see something curious, we just wanted to just want to play around, see something curious.

  • You may want to just delete this LCD, not clear function in your sketch.

  • When you do it and you'll see, you'll see a weird error.

  • You'll see if we like What?

  • What what the hell am I looking at kind of hair.

  • So the first thing that we have to do with LCD clear What that does is that clears a screen, basically turns all the characters on the screen off.

  • So then we're gonna do here is we're gonna start with if the temperature is too high.

  • So if temperature is greater than or equal 80 so if it's a template for Fahrenheit is greater, greater than or equal to 80.

  • Then what we're going to do first is we're going to take that plus minus variable, and it's going to equal temperature F minus 75.

  • So what is going to tell us is how many degrees it iss above the the temperature.

  • The temperature of that supposed to be 75 is the standard temperature here, so it's 75 is a temperature that it's supposed to be.

  • Then we're going to do is we're gonna go down here and we're going to say L C D doc set cursor.

  • So we're going to set where the cursor is going to begin writing from and that 00 to remember when you're dealing with an LCD screen.

  • Numbering starts at zero, not at once or the first position is zero.

  • So we're doing the first column of the first Rose were saying 00 and so what we're going to do right now is we're going to do LCD dot print warning so it's above 80 degrees.

  • It was warning.

  • Warning.

  • Will Robinson, Then what we're going to do is we're gonna go go to LCD dot set cursor.

  • So zero, So zero is the first column.

  • So it's 16 16 across, too.