The project's idea is to use my newly received (thx Santa) Pebble time smartwatch to send commands to a drone from your wrist, via a telemetry (mavlink). Accesorily, the objective is also to play with dronekit (mavlink communcation library) and SITL (APM vehicles/drones simulation tool).
As a summary, Pebble runs an HTTP client app to connect to an ESP8266 WiFi web server, which in turns transmits the received commands to the serial port of mission planner (or any other mavlink compatible ground station), running a dronekit python script to remote control the drone.
The chain of command from the Pebble watch to the drone is the following:
1.Pebble watch <=> 2. ESP8266 WiFi/UART device <=> 3.Dronekit python script <=> 4.Telemetry mavlink radio link <=> 5.Flying Drone
1. Pebble time smartwatch:
From the Pebble app store, the free "Send message" app is used as an HTTP client; The app is used as a kind of REST control, by getting (http GET) a different URI associated to different command. In this project, I decided to code three vehicle mode changes : RTL, LAND, POSHOLD.
2. Web Access Point for the Pebble - ESP8266 module:
This Pebble app needs to connect to a Web server. For that I use an ESP8266 module. As described on Sparkfun : "The ESP8266 WiFi Module is a self contained SOC with integrated TCP/IP protocol stack that can give any microcontroller access to your WiFi network. The ESP8266 is capable of either hosting an application or offloading all Wi-Fi networking functions from another application processor.". It contains a microcontroller which is twice as fast as a basic Arduino board (80 Mhz or 160 Mhz), up to 2MB of flash memory. it exposes a number of GPIO PINs for digital and analog input/ouputs and two UART ports ! So it is possible to use this device to make a UART-WiFi bridge, which we are using in this project.
Such an ESP8266 module costs between 5 and 15 dollars according to the manufacturer & version. There are more than 12 different versions (ESP-01 is the basic standard module, ESP-02, ..., ESP-12 exposes all GPIO PINs, etc...)
For this project, I used the Sparkfun "Thing" version, which provides an integrated 3.3V regulator, Lipo battery input and a micro USB port.
The module is programmed with the well known Arduino IDE.
I programmed PebbleArducopterControlAP.ino as a web server to run on it, waiting for a Pebble smartwatch connection.
This ESP8266 converts and transmits the Pebble watch received HTTP GET commands to the serial (FTDI USB) port of the computer running a dronekit python script.
3. Dronekit python script:
The ESP8266 module forwards the smartwatch commands to a computer on a serial port (could be a computer board such as RPi or Odroid, etc).
For ease of development & testing, the well known SITL APM simulation software is used to simulate an APM:Copter version 3.3. In the SITL copter simulation, the vehicle's mavlink communicates by default via a TCP link (127.0.0.1:5760)
A quick and simple test script listens on one side on the ESP8266 web server (serial port) and , if it recognizes a programmed command, sends it out to the (SITL simulated) drone via MAvlink on the telemetry link (TCP port).
My source code of this python script here (Vehicle_SIM.py).
4. Mavlink links:
I wanted to run Mission planner in parallel to my dronekit script, to have an easy and familiar visualization of the Pebble command's results on the drone. However in order to run in parallel, on the same drone mavlink link, both the dronekit script and mission planner, you need to run MavProxy to split the mavlink channel on two different UDP ports. Full details on how to use SITL and Mavproxy is given on the dronekit.io site.
5. Flying drone - Results:
See attached video. Had lots of fun to see the magic happen : a press on one of the three Pebble watch buttons triggers a drone mode change (RTL, LAND, POSHOLD in this demo example);
Although the real practical use of such a project is doubtful, I can tell you it is a lot of fun and a good learning experience on different topics : Pebble, ESP8266 modules, Dronekit, SITL !