HOW TO BUILD A FULL FPV DRONE WITH A RASPBERRY PI FOR ABOUT $200

Build a cheap FPV drone, no remote needed.

HOW TO BUILD A FULL FPV DRONE WITH A RASPBERRY PI FOR ABOUT $200

20 May 2017/Ciprian/ Technology, Python, Tutorial, Raspberry Pi, Android

Drones are getting more and more popular (and expensive) so why not build your own? With less than 200$ you can build your own FPV drone, no remote needed, it streams video to your smartphone while also using it as a remote. Alternatively you can use a PS4 controller as a bluetooth controller by connecting it to your phone. This is an advanced tutorial, you are expected to have some linux/raspberry/python/android experience. So, let's get started.

In case you want to see the final result, here it is:

raspberry-pi-drone-final

And this is how the app looks like:

drone app

Parts list: 

  • Raspberry Pi (I'm using an old model 2 I had laying around)
  • Raspberry Camera - ~$20.00
  • MultiWii flight controller (with USB serial control support, I'm using 328P) - $30.16
  • TP-LINK TL-WN722N wireless antenna  - $12.00
  • X Drone Frame (I'm using HobbyKing X525 V3 Glass Fiber Quadcopter Frame 600mm) - 18.45$
  • Power Distribution Board - $4.26
  • ZIPPY Compact 2200mAh 3S 25C Lipo - $12.32
  • 4 x motors (I'm using TURNIGY D2830/11 1000KV) - $43.96
  • 4 x ESC (I'm using AFRO, 30A) - $55.32
  • 2 x CW propellers 9x4.7 - $3.22
  • 2 x CCW propellers 9x4.7 - $3.22
  • Plastic nuts, bolts and spacers, zip ties, old USB micro cable - ~$3.00

Total: $205.91 (assuming you had a raspberry already, else + about $35)

You can also buy cheaper and less performant parts, i just wanted it to look nice and have that extra oomph of power.

Ok, lets build it. Follow the assembly instructions of your frame and then mount the motors, the ESCs and Power Distribution Board (don't solder the ESCs to the motors if you didn't test the spin direction first!).

Flash the MultiWii firmware using the Arduino IDE: www.multiwii.com 

Calibrate your MultiWii using the MultiWiiGUI tool (also available on multiwii.com)

Mount the raspberry camera and power it on to check if it works, here's how:

ssh into pi:

ssh pi@<pi.local.ip.address>

on another terminal on your pc run:

mkfifo fifo.264

nc.traditional -l -p 5000 > fifo.264 | mplayer -fps 30 fifo.264 -cache 1024

then on the raspberry via ssh:

cat fifo.264 | nc.traditional <your.pc.ip.address> 5000 & /opt/vc/bin/raspivid -o fifo.264 -t 10000000 -b 2000000

If all goes well, you should now have a live video stream from the raspberry to your PC. Neat.

Now, your raspberry pi should act as a wifi hotspot, you don't want to be carrying around a router everywhere you want to fly the drone. So plug in the WI-FI antenna and set the dongle in hotspot mode and enable DHCP by editing /etc/network/interfaces to look like so:

source-directory /etc/network/interfaces.d 
auto lo
iface lo inet loopback
iface eth0 inet manual
allow-hotplug wlan0
#iface wlan0 inet manual
iface wlan0 inet static
#wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
hostapd /etc/hostapd/hostapd.conf
#iface default inet dhcp
address 192.168.1.1
netmask 255.255.255.0
dns-nameservers 8.8.8.8 8.8.4.4

Note: You may need to restart dhcpcd: sudo service dhcpcd restart

Then edit /etc/hostapd/hostapd.conf and add these lines at the top of the file:

interface=wlan0
driver=nl80211
ssid=XDRONE
hw_mode=g
channel=6
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_passphrase=<wifi.secret.password>
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP

You don't need to configure IP forwarding, there wont be any internet connections to share anyway :)

After you do this steps you wont be able to connect the raspberry to your WI-FI, so either connect to it's new WI-FI hotspot or plug in an ethernet cable to continue.
Next step is to clone the python app into the home directory of your raspberry, so login to it and do: git clone git@github.com:C1PR14N055/drone.git

To run the python app simply do: python x.py

You can also make it so it always starts on boot by editing /etc/rc.local and adding the line sudo -u pi /usr/bin/python x.py &

Now on your PC clone and compile the app in Android Studio: git clone git@github.com:C1PR14N055/droneapk.git

After that's done open the apps settings and set them to match the setting from the pi (file x-conf.json).

Pro tip: to pair a PS4 controller and use it with your phone enable BT and hold SHARE + PS buttons for about 10 second until the front light is blinking, then pair to it from your phone. Also make sure to check the "Use controller" option in the android app's settings.

So, after all this hassle, here it is flying :)