Placeholder Image

字幕列表 影片播放

  • please go to the line the computer guy dot com In order to view schematics, code and Maur for the projects that you are learning about Welcome back.

  • So today what I'm going to show you how to do is I'm going to show you how to use the ping of function on Aren't we know, you know, with WiFi.

  • So this could be valuable because you can put this, aren't we know, you know, with WiFi on your network, and then you can have it ping different servers or different I P addresses to see if they are reachable.

  • If they are not reachable, then you can have some kind of alert functionality.

  • Or maybe you turn on a red led light.

  • Maybe you print something across an LCD screen, something like that.

  • So basically what we're going to be doing is we're gonna uses Arlena, you know, with WiFi, we're going to ping servers and then we're going to see what the results are.

  • This could be very valuable.

  • Imagine if you were in a help desk environment or some kind of desktops, a poor environment, and you simply need to verify that servers are reachable for your users again.

  • So I think about like, Salesforce or think about Google or some other kind of internal proprietary server.

  • A lot of times, you know, somebody unplugs a switch or something stupid happens with the network.

  • The cool thing is, is using the artery?

  • No, you know, with WiFi, you can it constantly pinging all of these different servers, and then it can take the results and put that as a value for variable.

  • And then you contest against that value with variable to do things again, such as turn on it Red led light sent off in the mail notification something along those lines.

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

  • I'll show you what's required for this particular project, as faras Hardware is concerned that I will show you the code and then we'll bring it all together to show you how this works.

  • So the only thing we need for our little project today is simply an Arduino, you know, with WiFi so you don't need any bread boards or or jumper wires or anything like that.

  • We're simply going to use this baseboard.

  • We're going to upload the code to it, and then we will simply be able to read through the serial monitor one.

  • It's saying so with that, let's go over and take a look at the code.

  • So here's a coat for this particular project, and there really isn't very much to it.

  • The first thing we need to do is we need to include our WiFi and Naina libraries were going to include that there.

  • This gives us the functionality of the WiFi stack on the Arduino, you know, with WiFi.

  • Then we need to give the information for connecting to our local WiFi networks.

  • We have char s s I d.

  • So I have a guest network set up as test, and for me, I have no password, So if you have a password, you plug this in and you will put your password here.

  • I don't have one.

  • So this is all that's required for my WiFi network.

  • Then we need to create a variable for status.

  • So this status is going to be used down here for trying to connect to the WiFi network.

  • We just simply need to creep basically copy and paste and just plug that in there.

  • The next thing that we're going to do is we're gonna be testing in this particular sketch, we're going to be pinging two different servers.

  • So one of the servers is we're going to new string.

  • So if you're going to be pinging a full fledged domain names such as www dot google dot com www dot eli the computer guy dot com www dot salesforce dot com.

  • For that, you're going to call it a string.

  • Do make sure you put that upper case s string and then you're going to say the name for the variable.

  • So for me, I just put this as host in a so strange host name equals.

  • Remember the double quotation marks, a double quotation marks and then plug in one of the domain name is here and then close the double quotation marks.

  • And, of course, to a semi colon.

  • Then we're gonna go down, and we're also going to be pinging a local I p address.

  • So my particular computer here, I'm going to have the Arduino, you know, pinging this and the reason we're gonna do this is I was going to actually show you when I turn off the network connection on this particular computer.

  • So you can see what the results are.

  • So opinion and I p address You're going to plug in this, so I p a dress.

  • So I p address space and then whatever you wanna call the variable for the i p address.

  • So this is simply going to a local server now realize there is no equal here, so basically just local server.

  • So this is this is the variable named local server and then we're going to put in the I p.

  • Address.

  • So local server open parentheses.

  • Then you put in the I p.

  • Address again.

  • One of the weird quirks with Arduino kicked you something simple Candies on example.

  • It's not periods.

  • For whatever reason, you can't do period.

  • So it's 1 72 comma 16.

  • 40 to come a five put periods in here, you're gonna run into problems.

  • So swap out the periods for commas and this should work for you close parentheses and then, of course, semi colon.

  • Then we're going to have create two variables for the results.

  • So these this is actually going to be what we contest against.

  • So when when the yard we know Ping's these two different servers.

  • What result, we're going to get back.

  • So the result that we're actually getting back is the millisecond of response times when you see the numbers tan or 300 or whatever else, that's the millisecond of response time.

  • Um, so when you're pinging and you're getting something back, you will get a number in the positive.

  • So 10 15 might be 700 Might be really high, but it'll be in the positives.

  • If you do not get a ping reply back, that's when you will get negative one.

  • So if you get negative one, then that means you're not getting a reply back.

  • If you're getting something on the positives, it means you are getting a reply back.

  • So we're gonna have an ent.

  • Basically, Google results.

  • So what?

  • The result for Google is and server result This will be the result for a local server Ping that, Then we're gonna come down.

  • We're gonna set up the environment as we always do.

  • Avoid set up.

  • First thing I'm gonna do is cereal about began in 9600.

  • So we're gonna be reading us from the cereal monitor.

  • So course meaning zero monitor to be up and running then we want to do the wild loop.

  • This is to connect us to our WiFi.

  • Never getting this basically copy and paste.

  • But we always d'oh!

  • While status is does not equal connected serial print attempting connector network named test and then status equals And the wife I doubt begin functions of this function feeds E s s I.

  • D.

  • And the password tries to connect to the WiFi network, wants it is able to come back to the WiFi network.

  • It then rocks out of the loop.

  • From that point on, it will then print out on the serial monitor.

  • S s I d what?

  • This the s s i d.

  • Is, and then we'll print out what the i p addresses again.

  • This is an important thing when you're doing any kind of work with, Are we know who knows with WiFi or any kind of Arduino, you know, with some kind of network connection is having it print out with the help its I P addresses could be a valuable thing for trying to do some troubleshooting.

  • So here we go and go into the loop for this particular what we're doing.

  • So we're going thio create a value for the variable Google results.

  • So Google result is going to equal WiFi, not Ping host name.

  • So the host name for Go Up here is www dot google dot com.

  • So it's going to WiFi Ping www dot google dot com.

  • Whatever the response time is in milliseconds and that value will be given to the variable Google results.

  • Then we have a server result y find, not Ping Local server.

  • Local server is again the i p address 1 72.16 dot 42.5.

  • So it will ping that and then whatever the middle seconds a response time and that will be given the value of server results.

  • They were gonna come down here, and we're simply going to print out to the serial monitor.

  • So google dot com colon space and then the value for Google result print lines of print lights.

  • It's gonna print this out on one line.

  • Then it will go to the next line local server, Cole and space.

  • And then the value for whatever the server result is there, and then it will delay for two seconds and then blue, blue, blue, blue, blue, blue blue, blue, blue, blue, blue up on an infant item So this is really all there is to go to the sketch.

  • The big things to remember here is again that string the upper case s for string host name equals double quotation marks.

  • So make sure you put the double quotation marks in and whatever the domain name you're going for and then I p address, whatever the name for the variable list.

  • So we're simply calling this local server.

  • There is no equal here.

  • You simply go to parentheses and to remember when you're typing and the i p address, you have commas.

  • So it is commas instead of periods.

  • Boy, that that's really the important thing for this particular sketch.

  • So let me connect the Arduino, you know, with WiFi.

  • Upload the code and I'll show you how this works.

  • Okay, so I've connected the art we know, you know, with WiFi it is connected to our computer or using our low USB cables.

  • That's giving power and connection for the serial monitor so that let us go to tools.

  • Let's go to serial monitor and see what it's pretty neck.

  • So this is that attempting to connect to network name tests is simply S s i d for a wireless network.

  • Eso this will take no right about 10 seconds for it to go through a process.

  • Okay, so we get s i d tests, we got the i P address and then here this is what we got.

  • So we got as we could see, google dot com is 210 millisecond response time of the local server is 290 response time.

  • Then you can see google dot com gets better.

  • A 10 local server is actually higher.

  • 1 40 Google is 10.

  • Local servers hire 1 40 That's one of the interesting things you can see again when you're looking at things like Response Times is actually saying that for whatever reason, the local server is significantly slower for response time.

  • Then Google's server.

  • So now I'm gonna show you what it looks like when I did disconnect the local server from the network.

  • Right?

  • So we can go up here and again for goto open and network preferences.

  • Well, you can see here is 1 72 not 16 not 42.5.

  • So this is the I.

  • P.

  • address of this computer, and that's what we're paying in here.

  • So what I'm gonna do is simply turn off wife eyes, turn off WiFi.

  • And as I turned off WiFi, you can now see that it's taking longer because it's timing out so we can see that google dot com is still with that 10 milliseconds.

  • But now local server is reading negative one.

  • So local server is negative one, and we just do it one more time just to show you.

  • So this will be the result that you'll be getting your beginning a negative one If a server is not reachable.

  • So then all we're gonna do is we're going to turn on the WiFi.

  • As you could see, the WiFi is turning on.

  • This will take a second or so.

  • My fines now on again, We just got negative one, and then we got the local server ridiculously high time.

  • But they're ago.

  • So now we're back to Google a 10 and a local server at about one for you, where it was before.

  • So again, this just goes to show you you can use this for anything that has an I P address.

  • Whether it's google dot com or whether it's just, you know, some Mac computer you have on your network, and you just want to verify that it is reachable from where you are in the network, and that's really all there is to it.

  • So there you go.

  • That's your Arduino, you know, with WiFi being able to ping servers with I P addresses.

  • So whether it's google dot com or facebook dot com or something up on the Internet, or whether it is some kind of local, you know, file server print server, some kind of a local server that you want, you want to make sure that it's up online.

  • You can use an Arduino, you know, with WiFi ableto to grab that time in milliseconds.

  • And then once you turn that into the value for a variable, then you contest against that variable again.

  • You know, as long as the number is positive, you can have a green led light on.

  • If the number goes negative, then you turn a red led light on something like that.

  • Or you could even trigger this to do something like send out an email.

  • So imagine, you know, if you wore company uses Salesforce significantly or Google significantly something like that, and then just simply having the art we know, you know, with WiFi.

  • It detects that Google or sales force is not reachable.

  • And then it sends you an email notification saying, Hey, you probably want to take a look at this because people are about to start complaining.

  • So it's simple tools like this, right?

  • You can use a simple just that simple.

  • You know, old ping utility use Ping.

  • You use Arduino.

  • You know, with that with WiFi, he adds.

  • A melody is, he adds, some bells and whistles, and all of a sudden you can get a valuable tool that could just make sure that your systems are working, how they're supposed to work.

  • So that's all there is to this particular project showing you how to use the wife.

please go to the line the computer guy dot com In order to view schematics, code and Maur for the projects that you are learning about Welcome back.

字幕與單字

影片操作 你可以在這邊進行「影片」的調整,以及「字幕」的顯示

B1 中級

用帶WiFi的Arduino Uno Ping服務器。 (Ping Servers with Arduino Uno with WiFi)

  • 1 0
    林宜悉 發佈於 2021 年 01 月 14 日
影片單字