MAKE A 4G LTE RASPBERRY PI DRONE WITH LIMITLESS RANGE | The Ultimate BVLOS Guide

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
what's going on everyone caleb here with the drone dojo and another exciting video here we go so in a previous video i showed you how you could connect a pixhawk with a raspberry pi you slam together and you get a raspberry pi pixhawk drone aka a pie hawk drone i kind of teased you all the cool things you could do with a raspberry pi drone but didn't go into extreme detail on any particular project but that changes now so in this video we're going to go over one super awesome application so in this comprehensive video we're going to cover how you can empower your drone with [Music] 4g so there's a ton of stuff you can do with a 4g connected drone maybe you want to upload a video from an autonomous surveillance mission to the cloud maybe you want to upload a picture to the cloud and run object recognition on it i don't know you get the idea there's a ton you could do i could go on and on one huge benefit of 4g connected drones is your ability to access the drone regardless of your distance or proximity to it i mean think about that that's right you can interact with your drone from thousands of miles away as long as it's within range of a cell tower you can connect with it interact with it command it do whatever you want or need to do so this video is going to be a comprehensive guide on 4g drones from the theory you know what the heck's going on to the hardware the hardware how do we set everything up to the practical applications then we put this all to the test at the end of the video where we take a pyhawk drone kit and control it from 70 miles away quick note to the faa this was not a beyond visual line of sight beef loss mission i was remoted into a computer that was 70 miles away and was standing with the drone please don't uh don't hurt me don't find me don't hurt me anyways that aside this video is going to unlock all of the technical aspects of beyond visual line of sight beef loss control for you so we're talking limitless telemetry range we're talking limitless range to ssh into your drone on the raspberry pi you can do a ton of cool stuff and you're going to understand all the technical aspects of that in this comprehensive video this video is long enough so the starting point of this video is to have an already built raspberry pi pixhawk drone a pyhawk drone ready to go i have another video on that that shows you how to connect those two you can check out the blog post or link i have somewhere i don't know where but it essentially shows you all the parts you need to build your own raspberry pi pixhawk drone we also have complete raspberry pi drone kits that we offer at the drone dojo if you want the easier solution it even comes with a video instruction manual on how to put everything together and you get access to me if you have any questions but just to let you know the beginning point of this video is to have an already built raspberry pi drone so with that out of the way let's get into it so first thing we're going to look at here this is our setup to actually get 4g connectivity on our drone this particular setup is from six fab so this kit will come with the shield that you place on top of the raspberry pi this modem which will give you internet connectivity it'll come with this connector which will connect your hat to the raspberry pi a couple antennas and some jumpers now this sim card will not come with this kit so you can also get the sim card from six fab's website but just be aware that you'll have to order this separately i think it's like three dollars or something like that so i will link to all of this in the description below so you know where to get that next up we have a couple more hardware components we'll need for our build we'll look at this first so this is a ubec it basically inputs i think it'll input from this side actually inputs 12 volts or a higher voltage supply and outputs a constant 5 volts or 6 volts or 7 volts whatever you need we're going to be going with 5 volts on our build but we need this and some of you might be saying you know my esc's on my drone supply a constant 5 volt output well the problem is with the esc's that come with the pyhawk they output 5 volts at 2 amps but we need a higher current capacity to power our raspberry pi and our 4g shield so you'll want a more heavy-duty ubec that can have a higher current output this particular one can supply eight amps continuous at the output which is good because the recommended amperage uh current supply for the pi i believe is three amps and an additional three amps for the six fab so you'll want a heavy duty u-back like this and then how are we going to connect the pi to this couple different ways what we're going to do in this video is actually we're going to have this usbc that we're going to connect to the pi and then on this end we're going to just solder in line with our ubeck so that'll be powering the pi and this will be where we will connect that power supply then you're going to need some heat shrink i believe these are eight millimeter spacers some helping hands since we're doing soldering soldering iron saturn and a set of scissors all right let's get into it so the first thing we're going to do is attach this ubec to our drone so this side is going to connect to the power distribution board that plugs into the battery and this side is going to be in line with this connector which will plug in and power the usb the usb of the raspberry pi so let's look at our drone here now we will be needing to remove this top plate in order to do some soldering action here on the power distribution board so we know the power needs to be hitting here so i think a good place to mount this ubec is going to be on the bottom of the drone all right so here is the bottom of the drone so i think a simple but effective way to to mount this will be just to put some mounting tape on the back of the ubeck place it right there and then we can feed in the side that needs to be soldered to the power distribution board up that slot in the bottom plate and then these lines we can feed through this slot and the bottom plate and it'll look something like that so i have those the output of the u-back accessing the top but you know we're going to have a lot of extra wire if we don't trim this down so let's attach the usbc to the power port of the raspberry pi and we don't want all this extra wire and we'll trim down the length of the usbc power all right so we have that cut to the hopefully appropriate length all right let's solder these two parts together now as you can see i did have a little bit of an accident there i trimmed into the insulation of the white wire and the black wire which would create a short so we're going to redo that okay that looks better make sure to just take your time on this one you don't want to strip the insulation at the base of the two smaller wires but now let's trim insulation off the top portion of these two little wires now we have all of the wires we'll need exposed so let's go ahead and tie black to black and then white to red right now let's grab our soldering iron and solder and let's go ahead and just tin the tips of all four of our exposed wires all right now we have everything tend and we're ready to solder together but right before we do that let's put some heat shrink on each one of these wires all right now we're ready to solder everything together remember black to black and then we'll do white to red alright now with those connections soldered together we can slip up our heat shrink protect those connections and we'll just apply a little bit of heat to it if you have a heat gun that'll work if you don't if you just touch the butt of the soldering iron to your heat shrink that'll shrink it up make sure to definitely inhale those fumes that's really good for your health actually don't don't just that was a joke don't please don't inhale the fumes all right and there we have that side of the soldering done you back to what we will plug into the raspberry pi now let's go ahead and attach this ubeck to the bottom of the frame and solder this side to the power distribution board of the drone let's go ahead and remove this top plate of the drone all right now everything has been removed from the top plate so we can now take it off before we do that though make sure you know the orientation of the drone because that is informing us where we need to mount our ubec so here our raspberry pi the power side is in the back of the drone so that is the red legs the front of the drone is the white legs alright so let's take the input to the power distribution board wire it through that slot on the bottom plate [Music] make sure you got a little bit of slack there but again we don't want these excess wires here because we're going to be soldering to here and here so if we cut basically maybe halfway up the ubec line we'll have enough slack to still be able to tie into the solder points of this esc let's do what we just did let's expose a little bit of that wire here we go and let's tin that again so now let's solder to the power distribution board it's kind of hard to film and solder at the same time all right now that we have that ubec line soldered onto the power distribution board let's go ahead and reattach our top plate to the drone go ahead and actually fix that u-back to the bottom frame with some mounting tape so we're going to want to mount it something like that and remember this part the usbc that's going to the raspberry pi is going to slip in through this slot here in the bottom all right and then you just gotta press down a little bit on there to lock in that mounting tape and that will be good so let's flip this over and plug it into the raspberry pi all right so here is our u-back power supply and we'll just be able to plug that right into the raspberry pi just like that and we can test to make sure that that eubec is working properly by plugging in the battery and seeing if we get power to the raspberry pi and you see the lights here right there looks like we're good congratulations all right now that we got the power supply all sorted out for our raspberry pi and 4g hat we need to mount the actual 4g shield so on a typical pyhawk build you're going to have the pi or the pixhawk mounted directly above the raspberry pi but whenever you want to install the 4g hat from 6fab or whoever else you choose to use it's going to be mounting directly to the pi something like that so you can't have the pixhawk right on top of the raspberry pi so what we have to do is simply remove this mounting plate that is uh attaching the picks hawk set up our six fab 4g hat and then we're going to mount the pixhawk on top of the six fab hat and we're going to have some little standoffs here in order to do that so let's go ahead and get that set up all right now let's get that six fab 4g lte hat installed on the raspberry pi first thing we have to do the six fab kit will come with two of these pin out extenders one is a little longer so you can still access the pins on the other side of the shield we're going to go with the shorter ones here so just plop that onto the raspberry pi pin out there we go now that is installed now if you do have a ribbon cable like pi cam camera that you're using on your build i would suggest that you actually install it on the drone before you situate that 4g hat because it'll be it is possible to install it but it's pretty dang difficult so i would just install that now once you have that in the slot the ribbon cable slot and press down you should be good to go and continue on with the 4g hat installation now we can place our shield on top of the raspberry pi just press evenly across everything so the next thing we're going to do is install the modem this is going to actually give us internet access so these slots will plug in here on the board so you want to angle it up a little bit like that and then you'll just press down just like that and now this modem is secured to the shield all right now let's install the antennas here so you'll notice on here we have three little sockets on the modem on our six fab shield so with the first antenna we have two outputs the gps output is going to be what we plug in here to the leftmost socket and then the other antenna will plug into here so let's go ahead and do that and it should snap into place now we'll do that with the second attachment there we go those two are connected now let's attach the second antenna this is white and that just goes into the rightmost slot or socket all right and once those antennas are installed those flimsy little antennas we need to mount them onto the drone somewhere i think the most convenient place is going to be just parallel with the legs here you do have some 3m sticky tape here on the back if you want to remove that and apply that wherever you want to mount i actually have some zip ties here on each arm so i'm just going to actually slip that under the zip ties just in case i choose to you know mount them a little more securely in the future i'll still have that 3m tape so i'm going to do that on the left side as well alright so after we have those antennas secured let's go ahead and slot in this sim card so that we can access the mobile networks and that'll just go in just like that now the last thing we have to do is connect the raspberry pi to the shield and power it with this cable so this normal usb will plug into the raspberry pi and then the micro usb just plugs into the hat and there we go our six fab 4g hat has been installed to the drone now we can mount our pixhawk on top of this hat and just have a skyscraper of hats for the raspberry pi so we don't want to just mount this directly to the hat we're going to have our normal pixhawk mount here we're going to secure that to the standoffs here with these little guys i think they're like eight millimeter standoffs and those will thread right into the 11 millimeter standoff so let's go ahead and install these four there we go now we can install the pi hawk or the pixhawk mount right on top of those standoffs here i have pre-threaded in the screws that will connect to the standoffs there we go i have our pixhawk mount secured now we just have to apply some mounting tape and place our pick hock on there all right now we have the raspberry pi on the bottom the 4g mobile connectivity shield in the middle pick sock on top now let's just connect everything back to the pixhawk so on a typical pyhawk build you're going to connect the pixock to the raspberry pi with this cable it's going to be a uart connection but now with this hat we're using this pin out is no longer really available but we have another way to connect the pixhawk to the raspberry pi and that's going to be from the micro usb of the pixhawk to the normal usb of the raspberry pi now any you can make this connection with any micro usb to usb cable just make sure that it is not just a power cable that you can actually communicate data back and forth so we're going to install that real quick i mean you'll probably want a shorter cord than this there's surely some on the interweb somewhere you can get this was all i had in my room so i'm going to go ahead and install this unnecessarily long cable there we go now we should be done with the hardware install of our 4g modification to the pyhawk hey you yes talking to your face if you're liking this video press the like and the subscribe button but only with your non-dominant hand you know just to really show your appreciation so let's go ambidextrous on this mission on this like and subscribe mission lefties are righties writers or lefties also leave a comment below about a 4g drone project you are thinking about working on now what's going on in your head back to the video all right so we have the hardware set up on our drone now for 4g connectivity but the firmware has not been configured to actually use that network interface so we're not going to actually have 4g internet yet if we were to power up the drone so in this next step of the video we're going to set up our firmware to actually use that hat that we just installed but you know so that this video isn't 19 hours long i'm going to assume you already have a raspberry pi up and running that you can ssh into or get access to in some way if you are not at that step pause this video go on over to the youtube type in raspberry pi drone and you'll find the best video there ever was and follow those steps it's going to show you how to flash the operating system onto the micro sd card install all the dependencies ssh into it and all that fun stuff so here are the steps we have to take we've already done the hardware setup now we're going to go to connect.6fab.com and and this is basically like a dashboard to manage different sim cards and pay your your data plan that you're signed up for but you can sign up for an account i already have one so i'm going to log in with google that'll bring you to this nice interface so here we're going to go over to sim and register sim okay so the sim icc id that is going to be the code that is on your sim card it is on the sim card itself and also if you order it from six fab it's going to be directly underneath that barcode so it's a long number i'm going to type mine in right now so this is our unique sim card code and now we just have to name it something i obviously have buster one already set up so i'm gonna name minebuster2 go ahead and hit register okay then after we have set up that sim we'll see that in our list of sim cards here's buster 2 that we just created so now we're going to hit create device and then it's going to give us some options here we have global we have emea which i believe is europe africa and asia and apac which i believe is asia specific so i'm going to hit global here and that's going to give us some code that we have to copy and run on our raspberry pi so go ahead and get access to your raspberry pi i'm going to ssh into my pi okay and before we run that code we need to test to see if our internet is properly working so we're going to say ping 8.8 and that is google's name servers i believe so if it says destination unreachable what that likely means is your default gateway on the pi is trying to use the 4g interface let me show you what i mean type ifconfig so here are our four network interfaces the two we're worried about right now are wlan and wan zero wlan0 is the wireless network interface that comes standard on a raspberry pi and this is our ip address then we have wan 0 and this is our 4g interface what's happening is the default gateway is trying to go through our wireless interface and that isn't properly set up to connect to the internet yet so we're trying to communicate with the internet but nothing's happening because that's not set up so what we have to do is make a modification to our default gateway and we'll do that with a whoops take two there we go we'll do that with a command like this sudo ip route add default via ip address dev wlan0 so what we have what you have to change on your command everything stays the same except for this right here 192.168.0.1 so look at your wlan 0 network interface yours might be called something different and grab the first three numbers so 192.168.0 and then we're gonna just add a one to the end of that because that is almost always the gateway so if yours is 192.168.1.206 then down here you'll do 192.168.1.1 okay and then we'll do dev and then the name of your wireless network interface so mine is wlan0 yours might be something else now this is very very important before you run this command that six fab gave us that'll modify our firmware we have to unplug that micro usb cable from the six fab hat very important unplug the usb cable from the hat and then only after you have that unplugged should you run this command once we have that ready to go we'll copy in that command that we got from six fab and then we'll hit enter and we'll let it do its magic all right now that installation takes maybe about five minutes so after that is done you can go ahead and plug that usb back into the six fab hat and then we'll hit enter to reboot the raspberry pi all right then after we're done running that installation code and our pi is booted back up go back to sim list and look at the name of your sim card and now it should say device status online the sim status should be inactive so we can fix that by going to show details and here just flip the radio button from inactive to active we already named it networks we're going to stay on low cost networks monthly limit you can go to unlimited if you want i like to just keep this at 100 megabytes and the typical charge rate is going to be 10 cents a megabyte so right here we're limiting ourselves to 10 dollars a month of data now if you need more than that obviously you can switch unlimited but this is kind of just a safety feature the rest of this stuff you can keep it how it is and then we'll hit update now the stats we won't have much stats here because we just turned this on but you know over time you'll be able to see data usage and stuff like that but now we'll go over to device and here is where there's a lot of cool stuff going on so connectivity we see the active interface is our wi-fi interface which is good because you know wi-fi is free so we're connected to the internet with our wi-fi but available interfaces we also have the wan zero interface our cellular interface so that is active if we need it and then we can see other things like linux what architecture is it the host name you'd probably want to change that eventually and then this is the signal connection so we have a decent signal connection this is the really cool part about this area of the dashboard open remote terminal so as long as our raspberry pi is on it has the 4g hat on it's powered up and we have access to this dashboard which we can access from anywhere we could simply click this button open remote terminal and it's going to connect to our raspberry pi just like that and we're connected through the 4g internet so this is really freaking cool right you can say that again we can access our drone from wherever wherever we're at as long as we have internet connection we're within range of a 4g network for our drone we can access this ifconfig you know we can do all the normal commands so that's one really cool feature about this dashboard we can manage all of our sim connected devices here under my sims we can access a quick remote terminal if we wanted to run something but you know as as good as this is you wouldn't want this to be your primary method of connecting to your mobile network drone the terminal can be a little bit annoying some of the keys don't translate perfectly onto the terminal and that can be annoying so throughout the rest of this video we're going to show you two different ways that you can utilize the 4g connectivity in a much simpler fashion okay so now we know how to access the raspberry pi through the six fab terminal but that you know it's nice it's nice but it requires an internet connection and it's kind of inconvenient at times if you want to remote into your raspberry pi by going onto some internet interface so what we're going to do now where am i pointing now is use something called mavproxy and mavproxy is a command line based ground control station you should have learned about that and installed that in the raspberry pi pixhawk video that i mentioned earlier but that is going to allow us to port all of our drone telemetry data to our computer with the ground control station as long as our drone is connected to a mobile network so it could be 500 miles away and what i'm going to show you now is going to let you input telemetry data to your computer and you'll also be able to control the drone from your computer so that's pretty cool right so we're going to jump into that right now all right so as i just mentioned we are going to jump into math proxy now and what is that going to allow us to do well it's going to give us limitless telemetry range with a mobile network so you know normally on a drone setup you're going to have physical telemetry modules you'll have one on the computer side that is going to have your ground control station and you're going to have one drone side those typically communicate through the 915 megahertz band in the united states and most other countries it's 433 megahertz now the problem with this is that this method of receiving telemetry data is limited uh to range so the 915 megahertz may only have you know a couple miles of range if your drone flies out of that then you're not going to be able to get telemetry data to your computer which as we know is very important right because you can receive data you can see what's going on with the drone and you can also control the drone from the ground control station so it would be very very helpful if you weren't bound by a particular radius to be able to interact with telemetry and that's exactly what mobile network telemetry does for us now before we jump into the nitty-gritty on what we have to do let's just take a quick refresher on what your local home network probably looks like you're going to have a router here and that is going to be something like 192.168. or 10.0.0 those types of ip addresses are reserved for local networks and your router is going to give ip addresses on that same subnet but to all the devices so your phone might be 0.117 your desktop might be 0.125 and so on so this is just half of the equation right so on the other end our router also has a public ip address now the public ip address is special because it is unique there is only one ip address like this on the entire internet now the same can't be said for the local ip address and that's why we use this on local networks because it can be reused over and over and over again and it wouldn't interfere with anyone else's internet so we have our public ip address here and you know just to make things simple we're going to say our router connects with the internet we're going to black box that it connects with the internet and communicates with the public i p address and all the other websites and servers connect to the internet right we have google that i think one of their ip addresses is this right here so let's say we're on our computer on our local network we say we want to go to google.com so we put that into our router we communicate with hey 192.168.0.1 i want to communicate with google and so then that traffic that request gets forwarded to the public i p address which connect to the internet connects to google we get the server information and then it comes back to the internet back to our router back to the device that we requested on so that's kind of like a high level look at how the internet works so now we're going to throw in you know our drone connected to the mobile network into the picture so here we have our drone buster 2 for me and it's going to with that hat that we installed communicate with the cell towers the cell towers connect to the internet and then through the internet we can communicate with any device we want and any device we want that could be our computer where we instead of forwarding the telemetry data through the physical modules we forward that through the internet so it looks something like this our drone is communicating data through the cell tower connects to the internet connects to our specific router and then connects to the device that we want to see receive coordinates on and then we would even see our map update with the drone's location and we could also send commands to the drone after we have this connection established and we could get it to fly we could arm the drone tell it to fly to a particular altitude so this is what we're going to be setting up right now we're going to set up mav proxy to connect the ground control station to the drone now are there are some things we have to do first we have to find the ip address of the modem it's modem slash router then we have to allow something called port forwarding on our router and i will show you guys how to do that then we have to remote into our drone's raspberry pi and start map proxy then we have to start mission planner and receive the mobile network telemetry so let's jump into it right so let's start with the first item on our to-do list so all we have to do is find the ip address of our modem router so you are going to go to a site called m ip4.me you're gonna go here i'm not gonna do it because it'll show my ip address and i don't want this video to have my router's ip address shown to the masses but you're gonna go to this site and it's going to display to you what your ip address is and make note of that because we're going to use that later on so write it down on a piece of paper or write it down somewhere because in a couple minutes we're going to be using that so the next thing we have to do is allow port forwarding on our router so before we do that i think it makes sense for us to actually understand what we're doing right because instructions without understanding it's just it's pointless so let's imagine you're on the east coast of the united states right there's a bunch of different bays that you could bring your boat into let's say this is boat or this is bay a so our we're the captains of our ship we roll into bay a well now that where the heck are we supposed to uh dock our boat this dock this dock this dock we don't know so we need further instruction on where to park our boat once we have the right bay and the right dock then we can go ahead and safely dock our boat well that same problem is actually present with our ip based communication so let's think of the ip address as the bay and then the port number as the dock so it gives us specific instructions on where we need our internet traffic to go so you might not know this but anytime you go to a website and you're using the https protocol you're actually using port 443 and if you're using http that's port 80 right so it's telling the internet or your browser to go to a machine in our case google and then add a particular port 443. okay now that we kind of understand ports and their relation to ip addresses let's jump into why we need to do port forwarding so our drone is going to be communicating with our router it's going to mention the ip address of our router again this is not my ip address but it's going to mention the ip address of our router so that we can communicate with it it's also going to be mentioning a particular port in our situation we're going to be using port 5000 just because that's a port that isn't used by many programs so we should be safe to use this port so our drone is going to try to communicate with our router at port 5000 now normally our our router is just going to drop this traffic right it's going to say i don't know where this traffic is coming from it didn't come from a request from me this is not a familiar port number so i'm just going to drop the traffic and there we go we call that a firewall but in our case we actually want to accept our traffic so let's say we're on this computer right and um we want the drone traffic to go to this computer so what we would do is set up port forwarding we would say on our router anytime you receive traffic to the port 5000 or whatever port that you're configuring anytime you receive traffic to that port number or that traffic to a particular machine our particular machine is going to be the computer running our ground control station so that way our router will receive traffic from our drone it'll say hey this is from port 5000 i've been instructed to forward this port this traffic to this computer and we can get a good connection so now hopefully you understand a little bit about what port forwarding is it both lets traffic through to your network and directs it to the ideal computer now we're going to show you how to set that up so it's going to be different depending on what kind of router you have but if you know your ip address and it's very simple if you just pull up a cmd if you're on windows type ipconfig you'll see the first three digits of your ip address we call that an octet so your ip address would be 192.168.0.1 it's typically typically going to be the first machine or ip number on your subnet so you would type in 192. 168.0.1 and it brings up your router so in my case um i can also edit my router through the internet and so i'm just going to jump over here but anytime you log into your router you're going to have the avail the ability to edit the settings so once you're on your router try to go to the settings editing option and you should see something called port forwarding so we're going to click on that and this is where we're going to set up our port forwarding so right now we're going to say add port forward and select the device you want to port forward so in my case my computer is this right here desktop with all this fancy stuff you might not have this option you might need to actually find the ip address of your particular device but in any case you're going to select your device that you want the traffic to be forwarded to okay now we're going to select the port number that we want to forward so my ours is going to be 5000 now mine is already in use because i've already set that up but go ahead and enter in 5000 here keep the tcp udp go ahead and do that and then hit next and it's adding a port forward and there we go now we should be able to receive traffic that is hitting our router at that port number so our destination is going to be remoting into our raspberry pi so we're going to be using mavproxy so if you have not done that yet go ahead and go back to the raspberry pi pixhawk video go to the installation portion of that video but we're going to turn our drone on and then remote into it there we go login as pi the password is resperry so if we type ifconfig we should see we have wlan up and running and we have wan up and running so now we're going to start mavproxy how do we do that and again this is going to forward telemetry data to our computer let's type mav proxy dot pi that's the command and then dash dash master this command is going to be connecting us to the pixhawk flight controller and that is it's connected through a usb cable which is dty acm 0. so that command right there is just going to connect us to the pixock that is running artipilot so once we have that connection we're going to type dash dash out so what is this this is going to be the ip address of our router i'm not going to type mine in here but it looks something like it'll have four different octets so let's say that was your ip address you would type that and you'd hit a colon so that's the ip address after the colon is the port number you would type the port number 5000 which is what we configured uh um to port forward on our router and then you would hit enter okay and then after you hit enter you should have access to this is a mav proxy ground control station it's a command line based ground control station but the primary reason we're using map proxy here is just to forward telemetry data to our computer so now that stream of data should be hitting our computer now now we have to open up mission planner but on the top right this is how we want to connect to our drone so normally we choose one of the com ports but now we're going to choose udp udp keep the baud rate at one one five two zero zero hit connect and now we're going to enter in the port we want mission planner to listen on and this is going to be the same port that we were forwarding on so port 5000 so we'll put that in and look at that we are connecting our ground control station to our drone via telemetry and it's all happening through the mobile network this is not through the physical telemetry modules and this is the location of my drone and it's all happening through the mobile networks and you know i'm right here it wouldn't matter if this drone was in wisconsin it would still work if it was in range of a mobile network and so this is really really neat right because you can actually we're getting data back to our drone we we see the state of the drone but we could also command it we could tell the drone to arm get the the props to start spinning we could tell the drone to take off and it would fly into the air we could tell it to fly to a particular waypoint and it would fly there so we can control the drone from mission planner and we can get telemetry data back to see its health and stuff like that so you can imagine how important this would be for things like fleet management let's you have a bunch of drones all over the world and you need a central place to manage them all and it can't be bound by your how close you are to the drone so this is a way to have a limitless means a limitless range for communicating with your drone so this last method is one of my favorites basically you know right from our computer or any computer you're on you know you can ssh into other computers well we're going to set up a way to ssh into our drone right from our computer now this is great for you know having a reliable terminal on your drone so think putty or bash if you have that enabled it's pretty difficult to set up so if you're happy with either one of these two methods you don't have to follow along here this is going to be just if you want long term command line level access to your drone so it and i'll show you why it is a little bit difficult to set up now so the mobile network interface won't have a public ip address we can access that is on the raspberry pi it does not have a public ip address so we need to set up something called a reverse ssh tunnel now thankfully from the mobile network interface we can communicate with our home router which this is not my ip address it's just a it's showcase one but from knowing our router ip address we can remote into our computer at home but you know what's that's kind of useless right because what if the drone's out in the field why would we want to remote into our ground control station computer from the pi it's that's reversed right we want to be able to ssh into the drone from our computer well that's what you have to do when you don't know the i p address of the raspberry pi that's the reverse ssh tunnel aspect of this see we don't know the ip address of the pi so what do we do to work around that we ssh into our computer and establish a connection and that connection might not even be used immediately it's just there waiting in the background and then since we have that connection from our computer now we can remote into the drone whenever we want we don't even need to know the ip address and we can also set up the initial part of the reverse ssh tunnel to start automatically right so every anytime the raspberry pi turns on it'll try to make this connection and that way whenever we want to remote into the drone we can do that there are a bunch of steps we have to do to configure this so let's just dive right into it so the first thing we have to do is if you're on a windows computer we need to enable ubuntu for windows and so you'll just pull up the windows store i'm sure there's a way to do this without umuntu on windows but if you're that advanced then you probably don't need to follow this tutorial at all so you'll just search ubuntu i'm using 1804 so you'll just click on that and install it and then you'll be good to go so next step is we need to after we install ubuntu on windows we need to enable openssh on the desktop on the desktop that we are going to be using as a ground control station so my computer so after you have ubuntu installed you would just open that up and another thing we're going to make note of whenever you install ubuntu you're going to create a username that you will use in this environment so mine is caleberg you'll need to keep track of what yours is for steps later on but what we have to do to um get ssh going on our windows computer is just type sudo apt get install open ssh server i need to enter there enter in your password okay then after that's installed all you would do to start that is type sudo service ssh start and then you would start that so now we can see the status of ssh on our windows computer sshd is running perfect because we're going to need ssh server on our raspberry pi and our desktop computer so that is step two step three is a little bit difficult or maybe not difficult to set up but conceptually difficult to understand we need to set up ssh keys for desktop ground control station which is my computer or whatever computer you're using to remote into your drone from and the raspberry pi now normally when you remote into a raspberry pi or anything you're going to be prompted with a password for the username you're trying to log into with ssh keys you don't need to put in a password just as long as the key is located in your environment you'll be able to log in without any password so basically we we have to do these steps for both our desktop computer and the raspberry pi so what do we do let's start on the desktop computer just open up an ubuntu terminal and you'll type ssh dash key gen minus t rsa and you would type that and that would generate a public and private key now those are stored in the dot ssh directory and the private key is actually stored on the machine you're remoting from we need to copy the public key over to the machine we want to remote into which is the raspberry pi so we would take a look at that public key id underscore rsa.pub so this is the key this entire thing we need to copy into the raspberry pi so pull up another terminal and log into your raspberry pi so remember we're trying to place the public key that we just generated into a raspberry pi so that we can log in without needing a password so we would do ls minus al and if there is an ssh directory we would go into that if there isn't just type mkdir.ssh and then you would cd into that okay now what we have to look at is authorized keys so this is where we're going to paste our public key we would go sudo the oops sudo vi authorized keys and i've already pasted my key in but all you would do is copy on in the public key that we just generated and then you would save that with colon wq and then you'd want to restart ssh so on the pi you would type sudo system ctl restart ssh there we go okay so now we have the ability to ssh into the pi without a password so we have the private key on the desktop the public key on the pi we need to perform the same operation now in reverse so we need to do the key generation and store the private key on the pi and place the public key on the desktop so you do the same thing and this is going to allow us to ssh into our desktop computer from the pi which is crucial so again ssh dash kegen minus trsa that would produce private and public key pairings you don't need to do anything with the private key you just go into the dot ssh directory and look at the public key here and then just like we did only in reverse we're going to copy this public key and we will place it in the authorized keys of our desktop so same thing sudo vi authorize keys and we would paste that in now again you would save that with colon wq all right and then once we have both of the sets of ssh keys set up so that we can log into the pi from our desktop without a password and from the pi we can log in to the desktop without a password it's time to move on to the next step and that is changing the default ssh port of the desktop computer to 5000 so it's very simple to do normally the ssh port is going to be 22 but we want to change that to 5000 for reasons i will go over in a second so if on your desktop computer or the computer you're going to be remoting from you'll just type sudo vi we're going to edit the sshd config file and very simple to do assuming you type your password incorrectly you're just going to find the place in this file where it says port now yours might be commented out like this but you're going to change the port yours will say 22 to 5000 and then you'll save that then you restart the service here on a windows ubuntu or a windows machine running an ubuntu terminal you type sudo service i believe ssh restart there we go now the default port on our desktop computer for ssh traffic is 5000 now as for the reason why we want to change the default port from 22 to 5000 well it's because we need to port forward traffic to our desktop computer and the problem is everyone in the world that can hack something knows that port 22 is going to be the ssh port so if they see that ports open they're going to try like crazy to try to ssh into it so if you change the port number it won't totally protect your computer but it's less obvious that that's the ssh port so now we're going to move on to the next step we're going to add the new port forward two two two two on the router so you just do that the same way we've already covered that right so we should have two open ports that aren't used they don't necessarily have to be these two ports just two ports that aren't in use then once we have all of that stuff set up correctly it's time to actually activate the reverse ssh tunnel done okay so how do you do that it's with this fancy command right here so open up a desktop terminal and your raspberry pi terminal and on the raspberry pi side we're going to enter in this command so what is going on here so essentially we're typing ssh a bunch of options and the 2 2 2 2 to 2 to 2 is going to be the port on the desktop that we're going to use to access the raspberry pi and i'll show you that in a sec port 22 is what port the raspberry pi is going to be listening to to see ssh traffic so port 22 that's standard caleb berg is going to be the username of the ground control station computer your desktop that you're going to be sshing from and then this is going to be the ip address of your router and then minus p 5000 that is the port on your desktop computer that is going to be listening to ssh traffic so we have to simply stipulate that that is going to be port 5000 and again we run this command on the raspberry pi side and then just a quick refresher on the reverse ssh tunnel once we have that first connection which is going to be what that command that we just went over is then we will whenever we want be able to ssh into the drone without needing to know the ip address let's run that command on the raspberry pi side so pull up your raspberry pi terminal and we're just going to paste oops no we're not we're going to type this command ssh minus f minus capital n and these are going to be case sensitive right so make sure that is all set up appropriately now i'm going to get this off screen a little bit because now i have to actually type in the ip address of my router and i don't want that to be on the internet on a hopefully super successful video so okay and once you have that typed on the raspberry pi go ahead and hit enter and then right after you hit enter it should return you to the terminal if there's if it's not immediately returning you here and it's sort of waiting that means that your there's probably something set up incorrectly but as long as that returns relatively quickly then you're good to move on if it doesn't review the steps that we just went over and see if you're missing something but once we have entered this command in we have accomplished the first half of the reverse ssh tunnel so now our drone has established a connection with our computer all right now on the desktop computer how do we ssh into the drone without knowing the ip address we type ssh pi at localhost and then the port number remember this is 222 for us so we're going to hit enter here and it should give us here we go access to the drone the drone's raspberry pi without needing to know the ip address so that's pretty cool right all right now we know how to start that reverse ssh tunnel and then ssh in from the desktop but there's one thing missing from our plan because we had to start the reverse ssh tunnel manually and that meant we already needed to have access to the raspberry pi but in the real world we're not going to already have access to the pi we're going to need the pi to automatically kick off that process for us so now we're going to set up that on our raspberry pi so every time it boots up it'll automatically initiate the reverse ssh tunnel so there's a couple steps we have to do here but i actually wrote some scripts for you that you can easily download that'll make this process easier to get access to those we'll just type git clone not klein you're going to want to type clone github.com dojo pi drone scripts hit enter there and you might need to install git if you don't already have it but that will download the pi drone scripts repository so let's go into there and then let's go into 4g drone and we should have two scripts in here let's make both of those executable by typing chmod plus x asterisk there we go so we have reverse ssh and we have set iptable.sh so let's start with the reverse ssh so there's only one modification or two modifications you'll need to make to this file now this script i'm gonna walk through it sort of from a high level but here this is one thing you'll have to change the home router ip this is not my ip address obviously but whatever your home router ip address is you'll put that in here whatever that is put that here then the other thing you have to change is right here okay whatever your username on your desktop is you will enter that here instead of caleb that'll be your username so let's walk through the script so while true we're going to run through this loop and this command here um it's going to grab the ip address of the mobile interface beca and we need to do this because that mobile interface ip address is going to change from time to time right now wan is set at 192.168.225.31 but if you reboot this a couple times couple days go by that might change just yesterday mine was.32 so we can't we don't want to put in a static ip address but we want to grab the um interface name and then grab the ip address there and that is what this command here is doing for us so let me show you what that command is doing we're first typing ifconfig and then we are grepping the interface name wan2 and dash a2 means take um two lines after we find wan2 in the command so before it was a bunch of text now we're getting wn2 now we we're trying to isolate this ip address so then what we can say is just find the line where it says inet but we can't just find inet we need to find inet and then a space because right here we have inet six so we'll type find the line that has an inet and a space now we have just that one line okay now each one of these items is separated by a space so we can use a command called awk and this is the delimiter between the fields we're just going to put a space here and then we want to print out the second column which is our ip address and we hit enter and there we go so this whole command is going to get us the ip address or this interface name so that's what we're doing in the script if we go into reverse ssh we're running this command and that's going to give us the script the reason why we have this in a loop is because we're running this at boot up so by the time we're running this ifconfig knight might not be ready to run so we're essentially saying run this command over and over until we find an ip address so that'll be this point here if this variable is not empty then we'll have an ip address if we have an ip address then we can initiate the reverse ssh tunnel and so we'll do this command that we already ran with one modification with minus b so minus b is allowing us to stipulate an ip address we want to do the reverse ssh tunnel from so we want to do that with the ip address associated with the mobile interface not our wi-fi interface so that's why we're fetching the ip address for our 4g interface here we're going to feed that into the reverse tunnel here and again change caleb to whatever the username of your machine is that you're trying to reverse ssh into and then here if the this command is successful then break out of the while loop and the script is done if the ssh was not successful then we're going to print out initiate ssh tunnel failed try again it'll just go start from the top of the while loop but once we have that connection established we'll enter out of the script and we should have a reverse ssh tunnel waiting for us now this other script here that we need to configure set iptable let's go in there and make some modifications the only thing you have to change here is your home router ip address that's the only thing the rest of the stuff will work for you this is going to add a routing rule to our raspberry pi so essentially the rule is going to be if we're trying to access the home router our home router ip address let's use the mobile interface let's use the wan 0 right here we don't want to use wlan0 okay so after we run set iptable we'll see that rule we'll type route minus n and here we go if the destination is this one two three whatever your home router ip address then use this gateway this is the gateway associated with your mobile interface okay and we need to do that because when we're out in the field um the default gateway is going to try to be used but that's not gonna work so we need to establish a new rule so then once we have an understanding of those two scripts we need these to run at the boot up on our raspberry pi so how do we do that well let's make note of this let's make note of this directory we're in okay and the names reverse ssh set ip so how do we run this at boot up very easy we'll type sudo crontab minus e and then we'll go to the bottom of the file and we'll say at reboot run or let's say paste in the script name that we want to run so we first want to run set iptable.sh and then we want to run the other script reverse ssh dot sh okay so every time we reboot these two scripts will get started for us so we don't have to manually enter these to start the reverse ssh tunnel there's one more thing we should do and in front here of the set ip table we'll type sleep 20 with two ampersands and this is just going to say sleep for 20 seconds and then run this command and then we'll say on the other one sleep 30 to ampersands and then run this command um and then once we have that we'll save this file all right then once we have put those two files into cron tab and we have put in our home router ip address and the username of your computer that you're going to be ssh into we'll type sudo reboot and we'll see if this worked so we'll need to let some time pass but after maybe a minute or so we can test to see if our reverse ssh tunnel automatically started by running that command again ssh pi at localhost with the port being 2222 and again i'm from my desktop computer right now so if i hit enter this should log us into the pi here we go we're logged into the pi now and this is over the mobile network interface not our wi-fi interface so now in theory we should be able to remote into our drone regardless of where it is and every single time the drone reboots it'll reboot the raspberry pi this command will be initiated which will automatically start the ssh tunnel to our ground control station computer and we'll have access to the pi it can be anywhere in the world as long as it is connected to the mobile network we can control it all right so now we have that reverse ssh tunnel all configured and we know how to do it so we're done with the video right now it's project time okay so the mission we are going to remote into the drone from our desktop computer that we set up to receive the reverse ssh tunnel from so we're going to have that desktop computer there and then 70 miles away we're going to have the drone so here in the red we're going to be driving to the bridge mcdonald's the world famous bridge mcdonald's and our drone is going to be there and our desktop the one we configured with reverse ssh will be here in yellow and the mission is going to be very simple like i said we're going to ssh into the drone from our desktop computer then once we have that ssh terminal we're going to run a simple python drone kit script it's an autonomous mini mission it's just going to take the drone off into the air at one meter and then land i've already covered this code in a previous video look through my videos for this thumbnail you can get an idea of the code but one quick note so since i need to be within visual line of sight so i'm not doing b loss type missions i'm actually going to be at the red waypoint i'm going to be there with the drone but the computer i want to be using is 70 miles away so from the drone waypoint i'm going to remote into my desktop computer with a laptop using teamviewer and then essentially i'll be controlling the drone from my desktop so effectively it's as if i was only at the desktop location but just to not have the faa go after me and and be legal i'm going to be with the drone at all times so with that said let's get into it okay uh it is 10 p.m on a sunday i couldn't wait i'm gonna do the mission where i control buster from 100 miles away here he is over here what's up bust bust a bus to rhyme but before we do that you know gotta fuel up with a little bit of wendy's you know get some spicy chicks spicy chicken sandwiches and then uh we'll hit the road can i get two spicy chicken sandwiches just that what you want to listen to buster oh poison out of my mind [Music] six and a half hours later all right here we are 70 miles away we got buster the drone here from one of our pie hawk drone kits and we're going to run a simple mission so we have our laptop and from this laptop we're going to access the desktop computer that is 70 miles away and from that desktop we're going to control the drone we're going to run a simple mission to take off under the air and land autonomously it's only going to go about a foot or three feet about one meter we have of course least buster because we may or may not be in a busy parking lot at 11 pm at night on a sunday so we have him leashed to about 10 pounds which buster cannot fly away with unless he's been doing some some gym time so we're gonna go ahead and remote into the desktop computer so that we can control the drone let's also power up the drone so that we can initiate that reverse ssh connection okay so now we're going to remote into the desktop computer so you know i'm out here 70 miles away with buster but essentially here i am on my desktop computer now so let's see if that reverse ssh tunnel successfully was set up i really hope so or else i drove 70 miles for nothing so again we're going to type ssh pi at localhost and then we set up port 22222 to be our reverse ssh tunnel port so we'll hit enter there and pray to god that it lets me get into buster oh my goodness oh my goodness please buster calm down please buster a lot of people watching me right now buster it's a little uncomfortable okay gotta try again sweet mother okay there we go we are remoted into buster from my desktop computer which is 70 miles away just to prove that to you we'll type ifconfig and we don't have a ip address for the wi-fi we are purely connected via mobile networks right now so now we're going to run a script we're going to go to pi drone scripts dk for drone kit we're going to run take off and land now this script is just going to take off into the air at a meter target altitude is a meter and it's simply going to land and we're going to trigger this script from 70 miles away and watch and see what happens all right we hit enter there buster should enter guided mode any second now here we go buster is armed flying into the sky about one meter and he's landing and we ran that script from 70 miles away let's do that one more time just because that was that was so pretty let's run that one more time run the script again we're on the desktop 70 freaking miles away and hit enter there and watch buster soar into the sky from 70 mile away control and it could be all right so there we go so that was successful i'm gonna play the victory song all right buster unborn buster let's get out of here before security calls us just knew you had it in your buster i knew you had it in your buster beautiful good work man good work all right so i'm back from 70 miles away gas station security didn't didn't take me in so i'm good but that's basically the end of the video so we covered a ton of material and now you know how to create a 4g connected drone you know how to control it so there's a ton of knowledge here so you might need to treat this video as a video textbook and just go over each section again this video is based on our pyhawk raspberry pi drone kits you can get your own drone kit at our website or by clicking a link somewhere i don't know the blog post i'm linking will recap all the hardware you need to finish this project drone dojo members will have access to buy the ubec pre-soldered to the usbc power cable and they'll also be able to schedule zoom calls with me or another drone dojo coach if any questions come up if you found this video to be ridiculously awesomeness to let's say the cubic power do me a huge favor conquer the like button make it your home like it and tell it this is your house now it pays rent to you be nice to the subscribe button it's it's old and frail on its way out but let me know in the comment section below what our next drone dojo project should be and until next time it's your drone dojo sensei signing out
Info
Channel: The Drone Dojo
Views: 38,222
Rating: undefined out of 5
Keywords:
Id: IokyotAGbJI
Channel Id: undefined
Length: 84min 34sec (5074 seconds)
Published: Mon Aug 23 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.