Controlling a drone from a PC with an Arduino

Introduction

As some of you may know, I’m a huge drone fan [pun intended], and as such I’m always experimenting with these wonderful flying machines and finding new uses for them, as well as new ways to have fun with them.

I have always wanted to control a drone with a PC, and later have a camera feed from the drone to the computer, to be able to do some kind of pattern matching and follow objects, without a huge budget and large and dangerous drones.

In this post I will show you how to control the world’s cheapest (but not the smallest) drone, the Eachine H8 Mini, using an Arduino Nano (any Arduino will do), the nRF24L01+ 2.4G Wireless communications chip, and a PC running Windows with Python installed.

Here’s what you will need, and the approximate costs:

Prices subject to change without notice, links include refferal codes, supplier Banggood

  • Eachine H8 Mini – $12.99 – Banggood, 1 piece, RTF
  • nRF24l01+ Chip – $3.45 – Banggood – COUPON 10% off: 637ccc, 3 pieces
  • “Arudino” Nano – $2.39 – Banggood – 1 piece, Geekcreit brand
  • mini USB cable – approximately $1, buy it in a local shop – 1 piece
  • DuPont female-female cable – $1.49 – Banggood – COUPON 10% off: 15ACC, 40 pieces

You will need to solder the pins to the Arduino Nano clone, and maybe the nRF24L01+ clone, so you will need a soldering iron and some solder.

I linked clones from Banggood, as those were the ones I bought, but as far as I know they are fully compatible, and there are no datasheets for them implying they are compatible with the original components.

Reference guide for Nordic Semiconductors nRF24L01+ (and Semitek SI24R1) pinout

Meaning Pin Pin Meaning
GND 1 2 VCC
CE 3 4 CSN
SCK 5 6 MOSI
MISO 7 8 IRQ

Reference guide for connecting 2.4G wireless module to Arudino Nano

Meaning Arudino PIN nRF24l01+ PIN Notes
0V GND GND Ground
3.3V 3V3 VCC Please, Do not connect VCC to 5V, it will burn out the nRF24l01+ chip!
SPI CE D5 CE Special pin for nRF24l01+, control standby and RX/TX
SPI CSN A1 CSN SPI standard pin
SPI CSK D4 SCK SPI standard pin
SPI MO D3 MOSI SPI standard pin
SPI MI A0 MISO SPI standard pin

IRQ is intentionally left unconnected (floating). The Pinout is silk-screened (written) onto the board itself.

Step 1: Download Arudino IDE

To program the Arudino Nano, even though it’s a clone, you will need the official Arduino IDE. I used the version 1.8.4 on Windows 10.

Use the Windows installer (.exe) file, don’t use the online app or the Windows Store application, they will not work.

Download

Step 2: Install the Arduino IDE

Please refer to the video here for instructions, as I cannot go into details about the installation process, that is not the topic of this post.

Step 3: Connect the Arduino and nRF24l01+

Use the reference table above to know which is which.

Step 4: Plug in Arduino

Plug in the Arduino into the USB 2.0 port on your computer, preferably a back-panel one.

Step 5: Upload program code to the Arduino

Download my ZIP file and extract it to the Desktop. Enter the directory nRF24_multipro and double click nRF24_multipro.ino (you may not see .ino depending on your OS setup).

In the Arduino window, select Tools -> Board -> Arduino Nano, select the COM port (best to unplug your printer if you have one plugged in).

2017-09-24_174047.jpg

Then, go to Sketch and Upload.

Step 6: Test out your setup

Plug in the drone’s battery into the micro LOSI connector, make sure to get the polarity right, and set it on a flat level surface quickly.

Unplug and plug back in (or press the RESET button) the Arduino, and see if the LEDs on the drone start flashing quickly then stop flashing and stay lit.

If that happens, it means everything works. If not, unplug everything and retry.

Step 7: Control the drone

Install Python 2.7.x from here (I used 2.7.14).

Press Windows key on your keyboard and button R at the same time, and type in “cmd” without quotes.
Then run “cd C:\path\to\downloaded\files\” (put in the correct path, make sure there are no spaces in the path, if there are move the folder!) and finally run “python serial_test.py“.

You should see a screen similar to this one:

2017-09-24_164808.jpg

Controls are as follows:

  • W to increase throttle, S to decrease
  • A to yaw left, D to yaw right
  • Arrow keys to move foward/backward and left/right

Pretty cool! If you have any issues, let me know in the comments below and I will try and help you.

Disclaimer: This code is based on work by goebish and perrytsao. I am not responsible for any damage, injury, or death resulting from your use of this code.

Edit: Seems like I’ve forgotten to include the download link for the firmware, so here it is:

Download

How to get MP4 link from Google Drive August 2017!

Updated for end of August 2017: Nobody can play Google Drive redirector links anymore, but if you want to generate download links for files, look in this post here, and if you want quality links from Picasa look here.

Please regularly check back this article to find out the latest info!

Writing an IMEI to a Mediatek chipset Android phone

Introduction

This guide will show you how to write a new IMEI to a Mediatek Android device quickly and easily, and without damaging the device!

I recently purchased an Ulefone U007 Pro (in Serbia branded as the TESLA Smartphone 3.2 Lite), which is a pretty nice and very very cheap Android phone that has a 5 inch screen, a quad-core 64bit Mediatek MTK6735M/MT6735M chipset inside with the Mali-720MP graphics and is powered by Android 6.0.

By default it comes bloated with a bunch of Serbian-specific apps that I don’t use, as well as some spyware made by Mediatek themselves, which sends private information to a server in China over HTTPS.

To fix this, I thought “Hey, why don’t I put CyanogenMod on there?”. Stupid idea. After hours and hours of nudging things just the right way, I got my phone to boot properly, but it first showed Invalid Baseband version error and would crash when you insert a SIM card.

I realized that my OS build was bad, and I was in a hurry to get to sleep (it was 4am), I flashed the default TESLA firmware, which made things even worse and made the phone unbootable. I went to some chinese site and found a link to needrom.com with a Ulefone U007 Pro stock ROM (without Serbian apps and pretty stock but with some spyware included :/). I flashed it, I’m not going to go into details here how, and it worked, it booted, but the SIM card didn’t work and the Out-Of-Box experience crashed when it tried to Activate Cellular Service. In the top left corner it misteriously said “Invalid IMEI”.

After some googling and re-flashing the firmware, formatting, and flashing, I managed to get it to go past the OOBE screen and to let me dial. I dialed *#06# and saw an empty screen. What a shock, I started sweating and worrying I’d have to throw away a phone I just got because of my stupidity…

BUT… Don’t fear, if this has happened to you. I have a solution to writing an IMEI to newer Mediatek chipsets, like 6735M.

Step 0: WARNING

The steps below have only been tested with the TESLA SP3.2 Lite / Ulefone U007 Pro. Trying anything posted here is at your own risk. I (Milan Kragujević) am not responsible for any possible damage to your property including your phone, your computer, your cat, etc.

If you’re using this with another phone you need to obtain the AP and DB files yourself, DO NOT UNDER ANY CIRCUMSTANCES USE THE FILES I PROVIDED FOR ANY OTHER MODEL OF PHONE, YOU WILL DESTROY YOUR MODEM AND RUIN THE BASEBAND FIRMWARE!!!

Step 1: Obtaining the firmware

First, obtain the modem firmware file, available here.

If linking to this tutorial, do not hotlink the file, but instead link this page.

Step 2: Turn off your phone

Make sure your phone is turned off. For Ulefone / TESLA, unplug the USB and hold the power button for at least 20 seconds, or until the phone vibrates. If you get prompted by Android, ignore it, and force the phone to turn off itself.

Step 3: Extract the SN Write Tool and the firmware

After downloading the RAR archive, extract it somewhere on your desktop. Make sure that the full path is less than 200 characters, because if the path is too long the tool won’t run.

Step 4: Run SN Write Tool

Right click on the SN Writer.exe and Run as Administrator. In the popup answer Yes.

Step 5: Configure the tool

When launching the tool, a following screen will appear:

Select USB VCOM and Smartphone with C2K.

Then click System Config and fill in everything according to the picture below:

Click on MD1_DB, and select the “BPLGUInfoCustomAppSrcP_MT6735_S00_MOLY_LR9_W1444_MD_LWTG_MP_V79_P3_1_lwg_n” File.

Click on AP_DB, and select the “APDB_MT6735_S01_alps-mp-m0.mp1_W16.18” File.

If your phone doesn’t have two SIM cards, deselect Dual IMEI, otherwise select it (as is the case with the phone I have).

Click Save.

Step 6: Entering the IMEI

Changing the IMEI of a phone is illegal, so ONLY ENTER THE ACTUAL IMEI OF YOUR DEVICE FOUND BEHIND THE BACK COVER!!! I TAKE NO RESPONSIBILITY IN WHAT YOU DO TO YOUR DEVICE, THIS GUIDE IS ONLY INFORMATIVE!!!

In the screen above, enter the IMEI1 and IMEI2, and leave everything else to default.

Step 6: Flashing

Click OK, and quickly connect your phone via USB.

Make sure that the phone is off when connecting it.

Step 7: Success

If all went well, you should see this message:

If an error occurred, please try again, and if it still doesn’t work, contact the manufacturer for help.


This guide may not be reproduced in whole or in part on any medium, without writen permission from the author first.