UPDATE 01/19/2022: I no longer have a DJI Spark but it looks like they have changed the commands for the DJI serial tools. My Air2 is working great so I haven’t had to use this yet but specifying –port before your COM port and -vv before your model will likely give the desired results.
First, special thanks to Brian Stigall and his video on YouTube showing how to do this. I figured it would be helpful to make the commands used easily accessible and to be copied and pasted.
Just an obligatory disclaimer that I am not responsible for any damages that may result to your equipment including PC, drone, or other devices that could be affected by these scripts. Please understand what you are doing and how these tools work before just running commands on your PC and/or your drone. This worked well for my DJI Spark and it should work for other drones that do not have Gimbal Calibration in their Go Fly App. Documentation related to the DJI Firmware Tools can be found on the github page here: https://github.com/o-gs/dji-firmware-tools/blob/master/README.md
If you find yourself with a tilted or drifting horizon or basically a gimbal that just won’t stay level this will be your fix. Below you will read what happened to me and the steps that were able to successfully fix the problem.
I recently lost a propeller (aftermarket set) about 3 seconds after take off and my Spark took off at an angle and lodged straight in a tree. I recovered my bird and upon inspection 2 of my other propellers had damage but otherwise appeared fine so I went to Amazon and ordered some Genuine DJI Spark Propellers. You can get them from Amazon by clicking here.. My current propellers at the time were an aftermarket set along with some aftermarket spares. I have seen other people have a lot of luck with aftermarket propellers, but it is no longer worth it to me to risk an expensive drone by saving $5 on propellers.
A few days later I received the new genuine propellers, installed them, and while I was doing my pre-flight checks I noticed that my camera wasn’t level. I adjusted the gimbal roll for my first time ever and it appeared level. After take off everything was still level however I quickly noticed after getting to my desired location to record some footage that my gimbal was out of level again. I adjusted it again and soon learned that after any yaw or roll movements that my gimbal was not going back to level and during extended roll movements I could watch the tilt grow more and more! I landed my Spark and returned to my place where I could do a good IMU calibration and compass calibration as those were some suggestions I found in my initial search. I then did some motions with the Spark in my hand and found the issue was still happening. I hunted the Go Fly App for the ability to do the gimbal calibration which some other model DJI Drones appear to have, but had no luck finding it with the Spark. I posted to Reddit asking for suggestions and was directed to the video by Brian linked to at the beginning of this post.
My Tilted Horizon
Needless to say it worked and wanted to give back and document in writing for those that like to follow written directions. Below you will find the procedure to calibrate the gimbal for a DJI Spark and likely other DJI drones that do not have the option in the DJI App. I don’t wish this problem on anyone, but if you happen to find yourself with it hopefully this will help. The DJI Firmware Tools are written in Python which is a high level programming language and can be used on any major operating system such as Windows, Linux, or even Mac. The instructions below are for Windows but they can easily be adopted for other operating systems.
After The Fix
What is needed:
- DJI Drone (Spark is used in this example)
- PC (Windows 10, Mac, or Linux)
- Micro USB Cable
- Python 3.7.0: https://www.python.org/ftp/python/3.7.0/python-3.7.0-amd64.exe (Windows Version)
- DJI Firmware Tools: https://github.com/o-gs/dji-firmware-tools/archive/master.zip
- pyserial: Download pyserial-3.4.tar.gz from https://pypi.org/project/pyserial/#files
- 7zip: https://www.7-zip.org/a/7z1900.exe (Any archive tool capable of opening .tar.gz files will work)
- A level surface for calibration
Download and Install Python
Download the Python 3.7.0 installation linked above. Any version of Python 3 should work, but 3.7.0 is documented and linked to for this tutorial. I chose to install Python with a ‘Custom Installation’ to C:\DJI\python\ and Add Python to environment variables which allows it be ran by just typing ‘python’ in the command line. Python is easy to run because you just type ‘python’ however I used a short path C:\DJI for all of these extractions so that it is easy to navigate to from the command line which we will be doing shortly.
Download & Extract pyserial
The pyserial archive is a .tar.gz file. This is a tarball archive (.tar extension) with GNU Zip (.gz extension) which is basically a different type of zip archive that Windows does not natively support. Because of this you will need to use 7zip, which is linked above, or another compatible utility to extract the pyserial files. After installing 7zip or another compatible tool just open the pyserial-3.4.tar.gz file. Because of the way .tar.gz files are archived you will go through a few folder levels before you get to the actual needed content folder. I extracted the meat and potatoes of pyserial to C:\DJI\pyserial
Download & Extract DJI Firmware Tools
I extracted the DJI Firmware Tools folder dji-firmware-tools-master contents using 7zip to C:\DJI\firmware-tools Make sure you review the README.md file to understand what these tools do and how they operate!
Connect your DJI Spark and Find the COM Port
Place your Spark on a level surface, power it on, and connect via a Micro USB cable to the port beside of your SD Card slot. There is no need to connect the controller.
To find the COM port your USB connection is using press the Win+X keys (The ‘Win’ key or Windows Key is usually between Ctrl and Alt on the left side of your keyboard with the Windows logo on it) to open the Power Users menu and select Device Manager. Expand the Ports (COM & LPT) section and you should see USB Serial Device (COM#). If there are multiple devices you can disconnect and reconnect the Spark to see which device disappears and reappears. Note the COM port number because you will need it later. You can now close the Device Manager.
Now we need to open an Administrator Command Prompt or PowerShell Session. Press Win+X keys to open the Power Users menu and select Command Prompt (Admin) or Windows PowerShell (Admin) and accept the User Account Control warning about making changes to your device.
Once you are in Command Prompt or PowerShell we need to navigate to the pyserial folder we just extracted and install pyserial. to do this use these commands. If you extracted to a different folder you will need to substitute that folder in the commands below.
cd c:\DJI\pyserial python setup.py install
Calibrate the Gimbal
Now for the moment of truth! We need to navigate to the DJI Firmware Tools folder and execute the commands to get our gimbal recalibrated. Staying in the Administrator Command Prompt or PowerShell session we will now run the following commands to calibrate. The –port specification is new and I have not tested this syntax but it should work.
cd c:\DJI\firmware-tools python comm_og_service_tool.py --port com3 -vv SPARK GimbalCalib JointCoarse python comm_og_service_tool.py --port com3 -vv SPARK GimbalCalib LinearHall
During each of the the comm_og_service_tool.py commands your gimbal will bounce around and then hopefully finish with a Summary ending in “result: Pass”.
Test & Fly
Hopefully your calibration was successful. Disconnect the Micro USB and connect your remote along with your phone or tablet. Your picture should now be level. I attempted some motions with the drone in my hand and everything looked good. Next I preformed my pre-flight check and took it up for a quick test flight to verify everything was working as it should and let out a big sigh of relief.
Special thanks again to Brian Stigall and the kind folks on Reddit who pointed me in the right direction.
Last updated on 2023-11-29 / Affiliate links / Images from Amazon Product Advertising API