Making Connected Drones A Reality
Have you noticed that more and more of your life is now connected to the internet in some way or another? First it was computers, then it was phones and tablets, now virtually everything can be connected to the internet. There are connected cars, TVs, refrigerators, watches, trains, thermostats…..even light bulbs! The explosion of connected devices is commonly referred to as the Internet of Things. Why connect these devices to the internet? The idea is that with them connected to the internet they can make our lives easier and more convenient. For example, my colleague Mark has a hot tub and he would like to connect it to the internet so that when he is on his way home from the office he can turn it on from his phone so he can enjoy it as soon as he gets home. Or better yet the app on his phone automatically turns on the hot tub as soon as he is a certain distance away from his house. (For all the benefits of connected devices, there are certainly some concerns as well.)
So what other kinds of devices can be connected to the internet besides devices we encounter every day in our lives? I had recently been looking at connecting drones to the internet of things in an effort to show an interesting example of how to control devices remotely. At first, connecting drones to the internet and controlling them remotely might seem far fetched, even dangerous, but if drones are going to see large scale practical use, than this situation is going to have to become a reality at some point.
At IBM we have the perfect combination of cloud technologies to build applications for the IBM Internet of Things Foundation and IBM Bluemix. Let me first explain what they are. The IBM Internet of Things Foundation (or IoT Foundation) is a cloud based solution for connecting any device to the internet. It offers a messaging hub allowing you to gather data and control devices remotely and securely from any type of application. Typically IoT applications involve lots of devices, require a large amount of compute power, and have a large number of users. Most enterprise data centers don’t have the resources to handle those types of applications so they are often run in the cloud. This is where IBM Bluemix comes in. IBM Bluemix is IBM’s cloud platform, offering not only cloud hosting solutions for your applications but a wide array of cloud services allowing you to quickly and easily build out your ideas.
For my drone based IoT application I used a Parrot AR Drone. I chose this drone because there is an open source Node.js library that can be used to control the drone. The library works by connecting to the WiFi hotspot from the drone and using the underlying protocol from Parrot to issue commands to the drone. With the library you can tell the drone to take off, land, hover, take a picture, and pretty much anything else you want.
To get started, I needed to connect the drone to the IBM IoT Foundation. The IoT Foundation uses a messaging protocol called MQTT to issue commands to devices and transmit data. There are a number of open source MQTT client libraries to choose from, but since I was already using Node.js to control the drone, I chose to use the Node.js library. It is quite simple to build a Node.js app to connect to the IoT Foundation, you can follow this “recipe” to get started.
The first challenge I encountoured though was how to actually make the drone communicate with the IoT Foundation. The drone does not have an internet connection, but does have a WiFi hotspot. In other words, you can connect to the drone’s WiFi hotspot from any WiFi enabled device but there is no internet connection. To solve this problem I needed to use what is called a gateway device. A gateway device is a device that sits in-between the device you want to connect to the internet and the internet itself. Gateway devices are typically low cost hardware like a Rasberry PI or something similar. In my case I utilized my laptop as the gateway device. My laptop can have two simultaneous network connections, one to the drone and one to the internet. Therefore I can run the Node.js code to connect to the IoT Foundation while at the same time communicating with the drone via its WiFi hotspot and the Node.js library! Now, in the real world that is not how it would work. Ideally the drone would have an internet connection itself and we could load some code onto the drone to have it connect directly to the IoT Foundation, but since this is a just a proof point, using my laptop as a gateway device should do.
After writing a small amount of Node.js code I had the drone connected to the IBM IoT Foundation. Next I needed an app to issue commands to the drone to control it. For this I decided to write a small set of REST APIs in Node.js that would run on Bluemix. I chose to create some REST APIs because that would allow me to control the drone from a number of different clients. The REST APIs would run on Bluemix and again use the MQTT Node.js library to connect to the IBM IoT Foundation.
Now to the clients used to control the drone. I had a number of clients in mind that I wanted to use to control the drone. The first, and most obvious one, was a web app. However, I wanted to do something more interesting that just a plain old web app, so I also wrote and iOS application that used the same REST APIs to control the drone. I figured why stop at an iOS app, when I could also build an Apple Watch app. Now I had the ability to control the drone right from my watch!
At a high level this diagram explains how all the components and technologies fit together.
Here is a short video where I demonstrate how this all works.
And here is another video from my colleagues David Barnes and Mark VanderWiele talking more about the concepts behind connecting the drone to the Internet of Things.
With the technologies provided by IBM there is an endless possibility of IoT applications you can build and the cloud makes it very easy to get started. If you are interested in building out your own IoT applications in IBM’s cloud sign up for a FREE Bluemix account. This will give you access not only to Bluemix but to the IBM IoT Foundation as well. Enjoy!