Software apps and online services
Ever get your drone stuck wayyy up in a tree? Or in some tall grass? In a pile of leaves, or even *cringe* snow? You haven't? Yeah neither have I, uhh yeah! ;)
It's easier than you might think for your little four-winged buddy to go missing. Getting low on juice, encountering interference or high wind, there are a number of reasons you might lose control and ultimately, track of your drone. Especially if you're flying line of sight, it's bound to happen eventually. Moreover, things can go wrong during a crash. Lipo batteries used to power drones often don't have circuit protection, which can result in damage or even fire during trauma like a short circuit. These are a couple areas where DroneHome can help!
DroneHome makes use of the Particle Electron 3G and its' GPS Asset Tracker Kit to home in on your Drone (or Wallet, or Backpack, or anything else you bolt it onto). The Electron's low power and cellular capabilities allow it to periodically broadcast its' location up to the cloud for extended periods of time - days even. From the ground, you can load up a map on any web browser to take a look. Satellite View is especially helpful in tracking down runaway airships :)
On top of location, it will report back the 3-axis angle values from the included accelerometer, and battery status on the Electron itself. When a screaming buzzer is attached, you can use one of several methods to activate it and send an audio SOS beacon, helping you find it quickly!Software Features
DroneHome does a few things out of the gate right now, but is being improved, and can be customized to be capable of more too... Quite a bit more actually!
Out of the gate, DroneHome can already:
- Track your flight path live on a map, and let others watch from anywhere. If your drone went astray, see where it ended up.
- Monitor your GPS coordinates, battery, angle, and speed as often as you like!
- Sound an SoS buzzer on your drone such that you an find it when it's stuck in a tree or downed in high grass.
- If you install a relay in front of your battery, you could kill power to the entire drone in the event of a crash, potentially preventing damage to batteries, your drones, or even a fire!
Soon (within days) even more will be added to the base feature set. Since the Asset Tracker GPS unit itself is capable of reporting position, altitude, and angle at minimum, with some added logic you could determine more, such as speed, distance from takeoff point, distance to a destination waypoint, etc.
That's not all though, DroneHome will be tied into IFTTT, which is easily customized simply from a website, and will also be able to accept instruction from your transmitter (TX) controller. This is where things get interesting. Whether manually flicking a switch on your controller, or using data conditions to fire, your drone can send a command to IFTTT over the internet, along with data, and trigger actions to happen anywhere in the world, even from way up in the sky! Some examples are:
- Set an altitude alarm! Accidentally go too high? Sound the alarms back on the ground and keep your flight legal!
- Keep logs of your flight time and paths.
- Trigger audio cues on the ground for drone heading or direction!
- Text you GPS coordinates on demand!
- Alert you if you breach a geofence, such as going outside an acceptable range, or inside a geofence like an airport!
- Trigger an IFTTT action from a switch on your TX! You could map virtually any Trigger->Action combination you can imagine.
- Almost all of these can be used for non-drone applications as well - cars, keeping an eye on your kids or your stuff, the applications are endless.
Lastly, I've also done quite a bit of research in getting the Electron to communicate with drone flight controllers directly (for some common controllers like CC3D and Naze32). When that research is complete, it will be posted here and would expose even more information and features, such as:
- Monitor your drone's power level, and trigger audio alarms if it's too low, even when you're out of earshot!
- Depending on drone features, issue a "come back home" or "go to waypoint" command to the drone based on any of the previously mentioned data!
- Keep track of flight log history, battery usage, etc. Compare with local weather and windspeed to calculate potential flight time or issue warnings if bad weather is approaching.
So how do you make and customize this thing? Let's get to it!Let's Make a DroneHome Tracker!
So you've got your Electron, and you've got your GPS Asset Tracker Kit, awesome! Let's get rockin.First Time Electron Setup
First thing's first, set that sucker up and get it talking to the cloud. Particle will lead you in a slightly different direction, but I recommend installing the Particle CLI on your computer first. Here's how.Set Up your Computer
1. Unless you have it already, download and install Node.JS.
- Don't be tempted to download the LTS version, download the latest Stable version instead (5.9.1 as of this writing). Download the 64-bit for your OS - on Windows, be sure to use the .MSI installer, NOT the .exe! On OSX, you should use the .pkg installer.
2. If you're on Windows, download and install the Electron Driver as well. (For OSX, skip to step 3.) Unfortunately this is a little painful at the moment - hopefully Particle can improve on this in the future and make an installer. For now,
- Unzip the downloaded Particle.zip to a known location.
- Connect the Electron's USB to your computer. Ignore any errors.
- Click the Start button in bottom left, type
Deviceson the keyboard, and hit Enter. In Windows 7, you should hopefully get the Devices and Printers window, rather than Device Manager. Windows 10 might be a bit different.
- Find Electron in the list. Right-click it and select Properties.
- Click the Hardware tab, then the Properties button.
- Click Update Driver, then Browse. Find the Particle_Windows_Serial_Drivers folder that was inside Particle.zip you extracted. Choose it, then click Next.
- The driver should install. When finished, cancel all windows until back at Devices and Printers. Right-click empty space and hit Refresh, or press F5.
- Your Electron should now show a COM number. Remember this number, it might be useful later.
- (If you encountered any issues, you might check this article for info.)
3. Install the Particle CLI software. You'll need to open a console for this.
- If on Windows, press the Windows Key+R, then type
cmd and hit Enter. Once in the console, type
npm install -g particle-cli and hit Enter.
- If on Mac, press Command+Space, type
terminal and hit Enter. Once in the console, type
sudo npm install -g particle-cli and hit Enter. Type your administrator password, and hit Enter once more.
4. You should now get a little spinny indicator, and a progress bar. When it's finished, leave this console window open, we'll need it in a bit.
(If you had trouble following this section, more advanced instructions are here.)Set Up your Electron
Conversely, this part's so easy I won't patronize you by leading you through it :) Once you reach the black Build IDE page (after clicking the Let's Get Building button at the end), come back here and we'll continue.
Whew, you finally made it! Your Electron should have gone through the steps as shown above, and should now be "breathing" light blue. At the end, this black thing they dropped you in is the Build IDE, an online coding platform where you can send new code to your Electron.
At this point, go ahead and mount your Electron into your Asset Tracker Kit's shield if you haven't already. Make sure the labeled pins align with the labels on the shield. (A0 -> A0, etc.)Flashing "Firmware", aka Apps
Sometimes with new hardware, it's been in the box for a while and you need to flash the firmware as a first step to get it up to date. Particle's a little confusing with the terminology here, as when they talk about flashing "firmware", they typically mean both your app you've made /and/ the low-level Electron firmware. This is actually done at the same time via their Build IDE you saw - your app is wrapped into their firmware, and both are flashed at once.
As you might have seen on the setup wizard, it's possible to flash your Electron project/firmware from over the air (OTA) using cellular. However, even if your app is small, the firmware can be big (around 24KB or more in my testing), and you only have 1MB per month to work with (not much at all). For this reason, you should always update firmware via serial over USB if possible. Much like an Arduino, the Electron creates a virtual serial (COM) port when you plug it into your computer, and this can be used to flash the device.
One reason you might want to flash OTA is the GPS - it's the same as the Adafruit Ultimate GPS Breakout (if I'm not mistaken), and will behave similarly and is even compatible with their libraries. Because the GPS can take minutes, even hours to achieve a "fix", and bringing it inside and/or powering it down can possibly undo the work it's done to hone in on its' location, there might be times you want to remotely reprogram your Electron while it's outside. Luckily, the online Build IDE does have an option for pushing only your project code to the Electron too, which will help with saving data as you don't have to flash the full firmware. (There are also some advanced commands on the CLI for pushing and compiling individual files to the Electron, though I only used them over serial.)
Enough talk, time to flash. Particle provides a good guide on how to do this, which you can find below, but here are the basics.
Note: For this section, you should be familiar with basic commandline / bash commands, such as cd, dir or ls, etc. If you're not comfortable with these, I recommend watching some intro youtube videos on Bash or the Windows Console / "DOS". These are some of the first commands they would teach you.
1. Put your particle in "Listening" mode, by holding the MODE button for 3 seconds until it blinks dark blue as shown above.
2. Go back to the console, or open a new one. Type
particle login and hit Enter, then follow the prompts to log in.
particle list to see a list of available devices. You should see your named device in the list.
4. Below this article, find the DroneHome.ino file, and copy its' contents to your clipboard. (You can select everything with CTRL+A, or Command+A on Mac.) Return to the Build IDE we had open in the browser.
5. Click Create New App, and title it
DroneHome. In the DroneHome.ino file that is automatically created for you, paste in the code you copied from this article.
6. Switch to the Libraries tab at the bottom left. (It looks like a bookmark flag). On the Libraries tab, in the Community Libraries field, type
asset. The AssetTracker library should appear. Click it, then click Include in App. If asked which app, select DroneHome. (This is illustrated below)
7. Back on the < > (Code) tab, click the Cloud-Shaped button next to DroneHome to compile and download the firmware from the cloud. Download the firmware.bin file after it compiles, and save it to the folder shown in the console you have open (Usually this is your user folder. On Mac, inside the console you can type "pwd" then Enter to see the full path.)
Firmware.bin is the binary (compiled) copy of your DroneHome project, plus the Electron's firmware in one.
8. Back in the console where you listed your devices, navigate to the path where you downloaded firmware.bin, using cd (change directory) commands, and ls or dir commands to find it. Once located, make sure the Electron is still flashing dark blue, then type
particle flash --serial firmware.bin and hit Enter.
You're done for now! The Electron should flash a series of colors while connecting, and the GPS Fix light on the Asset Tracker should start to blink red slowly. When blinking, this "GPS Fix" light is trying to home in on your location. Once it's reasonably homed in (within 3 meters or so) it will cease to blink. Don't worry, it's still on! The ceramic antenna needs a clear view of the sky (even should be away from buildings), and can take up to an hour or sometimes more to get its' inital bearings. Popping in a coin battery (or always keeping your Electron powered) allows the GPS to continually be aware of its' location, resulting in much shorter times to get a fix.
You can monitor what the Electron is doing by watching the Particle Dashboard. It's available at the link below, and will show you when the device boots up, when it successfully gets a GPS fix, how long it took, and finally its' coordinates. For right now, the dashboard does not keep track of events when it's not open, so be sure to leave it open on a browser tab if you want to "catch" the events coming from the Electron in real time. The published events are intentionally rare - this will keep your battery fresh and your data usage low.
By default, the location is published every 20 minutes, but you can change the timeout, as well as enable/disable automatic publishing using commands below. You can also manually check on the battery/charging status, and ask for the current location on-demand rather than waiting.
I've set up a web app (thanks to this example by Hypnopompia) that will track your position on Google Maps. It uses the particle API for logging in and selecting a device, so you can safely use this tool for your drone as well without any work! (Bravo Particle!)
Google Maps Tracker: www.rxp.me/projects/particle/dronehomeIssuing Manual Commands to DroneHome
As I mentioned, you can directly control DroneHome as well. If you hop back into your Particle CLI (console window), try the following commands to get information back from DroneHome on demand! You can use these commands in any other situation (like webapps) as well to do things with the information. See Particle API information for more details for your language.
In these examples, replace ELECTRON_ID with your device's id. It can be found on your dashboard here: https://dashboard.particle.io/user/devices
Get Status Overview (GPS Location, Battery Status, and Accelerometer Data):
particle call ELECTRON_ID status
Get Raw GPS Coordinates (for apps):
particle call ELECTRON_ID gps
Get Raw Battery Values (voltage, charge percentage):
particle call ELECTRON_ID batt
Get Raw Accelerometer Values:
particle call ELECTRON_ID acc
On top of these functions, variables are also exposed to the Particle cloud that you can monitor:
lastloc (String) = GPS coordinates last observed during a manual or auto scan
uptime (int) = Number of seconds the Electron has been powered on
lastFix (int) = Number of seconds since we successfully got a GPS fix
charge (float) = Charge percentage
volt (float) = Battery Voltage
chargeState (int) = 1 means battery is charging, 0 that it is Discharging
[ work in progress - coming in a day or so, check back! ]Links and Resources
Build IDE: https://build.particle.io
Electron Hardware Details and Datasheet:
Getting Started Guide:
Advanced Flash via Serial (USB) Documentation:
Asset Tracker Kit Information: