DIY Raspberry Pi Drone Part 3 – FPV Setup Guide

DIY Raspberry Pi Drone Part 3 – FPV Setup Guide

Raspberry pi quadcopter

Raspberry pi quadcopter

This is the last part of our Raspberry Pi quadcopter series. For the previous articles, please refer back to DIY Raspberry Pi Drone: Mechanics – Part 1 and DIY Raspberry Pi Drone Part 2 – Naza-M Lite Guide. In this tutorial, we’ll show how to setup FPV. After successful setup, a live video stream from the quadcopter to will be delivered to a mobile device from Raspberry Pi over WiFi. Android phone is required for this tutorial so please make you have one available. We’ll also install propellers for the drone and provide a pre-flight checklist at the end of the article for safe & successful flight.

 

Test flight video:

 

Aerial video (taken from quadcopter):

 

Hardware

Software

Tools

  • Propeller tightener included with DJI Flamewheel 450 Kit
  • Computer running Windows

Setup Android phone for FPV

Step 1: Choosing how to accomplish FPV with the Raspberry Pi

The video from the drone’s Raspberry Pi is sent over a WiFi hotspot to an Android phone. Currently, I have only worked out how to setup FPV streaming to an Android phone. There are three ways that the WiFi hotspot could be hosted

  • Router on the ground that both the phone and quadcopter connect to
    • This solution allows you to use a very powerful WiFi router which means you can reach a much longer range. The biggest drawback is that the router is another object that you have to have with you when you fly. The router also requires a separate power supply which again adds to the amount of gear that you have to take around when flying.
  • WiFi hotspot hosted on Raspberry Pi that the phone connects to
    • This solution seems ideal because it will work with any viewing device regardless of whether it can host a WiFi hotspot or not. The downside to this approach is that in my experience it rather difficult to enable Access Point mode on a WiFi dongle.
  • WiFi hotspot hosted on the phone that the Raspberry Pi connects to
    • Hosting the WiFi hotspot on your phone both removes the need to carry around a WiFi router and an extra power source, and makes it really easy to host a WiFi hotspot. On most Android phones you can create a WiFi hotspot in a few minutes in your settings.

 

Step 2: Setup WiFi hotspot on Android phone

For this example a Nexus 5 phone running Android 6.0.1 was used. However, any phone running at least Android 2.2 (basically every modern phone) should support running WiFi hotspots.

Note: Depending on your phone manufacturer the exact steps and/or appearance of menus pictured in the following steps might differ.

To setup the WiFi hotspot first open your settings app. You should see a similar menu as the one in the picture below.

 

raspberry pi quadcopter

Figure 1. Android settings menu

 

Under Wireless & networks click on the More option. Again you should see a similar menu as the one in the picture below.

 

raspberry pi quadcopter

Figure 2. Network settings

 

Enter the Tethering & portable hotspot menu and you will be presented with the following menu. From this menu click Setup Wi-Fi hotspot to begin configuring the WiFi hotspot.

 

raspberry pi quadcopter

Figure 3. Hotspot menu

 

We will now fill out the presented fields to configure the name, security, and band of our phone’s WiFi network. For Network name you can enter whatever value you like.

We want to make sure our network can only be accessed by our drone and ourselves, so we will set the Security to “WPA2 PSK” and the Password field to “deviceplus”.

 

The last field Select AP Band is very important. This field specifies what frequency band the WiFi hotspot will use. We have two options for this: 2.4 GHz Band, and 5 GHz band. It is very important to use the 5 GHz band. This is because our RC receiver (which we installed in Part 1 of this series) uses the 2.4 GHz band and running both the hotspot and the RC receiver on the same band increases the chances of interference that could cause you to lose control of the drone.

 

raspberry pi quadcopter

Figure 4. WiFi hotspot configuration

 

After you have finished entering the values in each field, click SAVE, and you have just configured the WiFi hotspot! Now whenever you wish to turn on the WiFi hotspot you can tap the slider to the right of Portable Wi-Fi hotspot (see Figure 2) to enable the hotspot.

Step 3: Install Raspberry Pi Camera Viewer app

We need a special app for our phone that will receive the incoming camera stream and display the video on your phone. The app we will be using in this article is RaspberryPi Camera Viewer by EffiSoft. Download and install the app to your phone off the Google Play Store here: https://play.google.com/store/apps/details?id=pl.effisoft.rpicamviewer2.

raspberry pi quadcopter

Figure 5. RaspberryPi Camera Viewer on Google Play

 

Step 4: Setup Raspberry Pi Camera Viewer app

After the Raspberry Pi Camera Viewer app has been downloaded to your phone it is time to configure it. Upon starting the app for the first time you will see a fairly blank interface like the one pictured below.

 

raspberry pi quadcopter

Figure 6. First time opening live streaming app

To begin setting up the app for our needs, click on the (+) button near the top right corner. By pressing this button we are creating a new settings profile. After clicking the button you will see a menu to edit the pipeline.

raspberry pi quadcopter

Figure 7. Edit pipeline interface with default values

We need to change a lot of options. To start tick the box beside Enable advanced mode to gain access to more settings. Then change the name to QuadcopterFPV or some similar descriptive name. Now we have to configure the most important setting, the pipeline description. The pipeline description basically tells the app how to decode the incoming stream (for those who are more curious, look into GStreamer pipelines).

Replace the text field containing:

tcpclientsrc host=0.0.0.0 port=5000 ! gdpdepay ! rtph264depay ! avdec_h264 ! videoconvert ! autovideosink sync=false

with the following string:

udpsrc port=9000 ! gdpdepay ! rtph264depay ! avdec_h264 ! videoconvert ! autovideosink sync=false

The only difference between the two pipeline descriptions is that our new one uses UDP instead of TCP. We use UDP because there is less of video delay and the video stream can better handle dropped frames/missing information.

The last option we have to configure is Enable application extra features. Simply check the box beside it. This will allow us to take screenshots of the video during flight which is a useful feature.

 

raspberry pi quadcopter

Figure 8. Final settings

After adjusting all the settings, simply scroll to the bottom of the app and click the SAVE button to save all your changes. In the next few steps we will setup the Raspberry Pi to connect to our hotspot, use the camera, and stream the video.

Setup Raspberry Pi for FPV

To ease the Raspberry Pi configuration I created an Raspbian Image that you can easily install on your Raspberry Pi for FPV. You can download the latest version of my custom Raspbian image here: https://github.com/brenton311/drone-files/releases/download/v0.1/image.zip.

To install this image you must extract the zip file, and then follow the most up to date instructions for your operating system on the Raspberry Pi website here: https://www.raspberrypi.org/documentation/installation/installing-images/.

Once installed, your Raspberry Pi will stream video to your phone when you plug in the battery (the Raspberry Pi takes about ~40s to boot and thus the video will not appear immediately on your screen).

 

Test flying/How to fly a drone

Step 1:  Learn the purpose of each control stick and switch

raspberry pi quadcopter

Figure 9. Transmitter with relevant control sticks labelled

 

  • Throttle (control stick #1: vertical axis)
    Throttle controls the speed of the motors. The higher the throttle is, the faster the motors will spin, the lower the throttle is, the slower the motors will spin. In general placing your throttle half way up (50%) from the bottom will make your quadcopter hover (not move up or down). Any throttle lower than 50% will cause your quadcopter to descend; any throttle higher than 50% will cause your quadcopter to ascend.
  • Rudder/yaw (control stick #1: horizontal axis)
    The rudder stick controls the rate at which the quadcopter spins among the yaw axis. When the rudder stick is at its center the quadcopter will not rotate. Move the rudder stick to the right and the quadcopter will spin CW; move the rudder stick to the left and the quadcopter will spin CCW.
  • Elevators/pitch (control stick #2: vertical axis)
    The elevator controls what angle your quadcopter will lean along the pitch axis. Pushing the elevator stick away from you will make the drone lean forward; pushing the elevator stick towards you will make the drone lean backwards.
  • Ailerons/roll (control stick #2: horizontal axis)
    The aileron controls what angle your quadcopter will lean along the roll axis. Pushing the elevator stick to the right will make the drone lean to the right; pushing the elevator stick to the left will make the drone lean to the left. When the elevator and aileron sticks are centered the quadcopter will level.
  • Orientation lock (control stick #3)
    This three position switch toggles between the three orientation lock modes (Off, Course Lock, and Home Lock) we discussed in the NAZA configuration step.
  • Flight mode switch (control stick #4)
    This three position switch that sets the flight mode. We configured the NAZA to switch between three flight modes: GPS ATTI, ATTI, and FAILSAFE. The function of each flight mode was discussed in the NAZA configuration step.

Step 2: Create a pre-flight checklist

When flying quadcopters there are a lot of things that can go wrong. To prevent simple mistakes I recommended to make a preflight checklist. The list below includes the checks that I run through before flying the drone.

  • Make sure your propellers are tight and installed in the correct direction
  • Make sure your battery is fully charged
  • Inspect your drone for any physical damage (e.g. cracked frame, disconnected wires)
  • Make sure your transmitter battery voltage is not low
  • Ensure you are in an area where you can legally and safely fly your quadcopter
  • Always make yourself completely familiar with the quadcopter, it’s flight characteristics, how to control it, and what to do when a problem occurs
  • Wait for the NAZA LED indicator to flash green before you take off the quadcopter

Step 3: Learn basic flight tips

  • Keep the front of the quadcopter pointed away from you at all times (use orientation lock if you want): Without orientation lock enabled, all roll and pitch commands are performed relative to the direction the quadcopter is pointed. Getting confused about what direction the quadcopter is pointed may result in crashes because your inputs will not do what you expect them to do.
  • Hover at about 50% throttle: Ideally a quadcopter has a 2 to 1 thrust to weight ratio and thus will hover at approximately 50% throttle. If you find that your quadcopter hovers at a significantly higher throttle (e.g. > ~70%) then you may have made your quadcopter too heavy—try reducing the payload or using more powerful motors.
  • Don’t overreact: The controls on the quadcopter are sensitive, and a quadcopter can move very fast. If your quadcopter is not heading in the direction you intend, make small adjustments to the roll and/or pitch sticks to bring it back under control slowly and safely.

Step 4: Always fly your quadcopter safely [IMPORTANT!]

  • Always follow all the applicable laws related to drones (unmanned aerial vehicles) in your area! DevicePlus and the author of this article series is not responsible to any damage to person or property that results from the construction or use of this drone. Drones can be very dangerous! Please operate your drone legally and safely.
  • If you are a new pilot you will probably crash, prepare for crashes
  • Don’t over discharge your battery
  • Fly in an open area (field, large park) away from people, cars, or other buildings.
  • Do not fly close to airports (consult the applicable unmanned aerial vehicle laws for the radius from an airport where you can not fly)
  • Do not fly your quadcopter beyond your line of sight or at night

Step 5: Charge your batteries

Before attempting to charge your batteries, refer to the important information about the specifications and proper care of batteries in part 1 of this series: DIY Raspberry Pi Drone: Mechanics – Part 1. You could also check out a guide on LiPo Batteries here.

The exact steps to configure and use a LiPo battery charger vary with each charger but, in general, you must:

  • Make sure your charger is set to LiPo mode (many chargers support multiple battery chemistries)
  • Set the battery voltage to 3S (change if you used a different battery)
  • Set the battery capacity to 3300mAh (change if you used a different battery)
  • The charging current can be left at it’s default (usually 1C)
  • Connect the battery leads to the charger with the right polarity
  • Connect your battery’s balance lead to the balance charger
  • While charging your battery keep it away from any flammable materials (it is advisable to charge your battery outside)
  • Monitor your battery while it is charging to make sure it doesn’t expand, smoke, or drastically heat up. If you notice any of these signs immediately stop charging and move your battery to a location outside far away from flammable materials.

Step 6: Install propellers

Much like our quadcopter has CW (clockwise) and CCW (counter-clockwise) motors, we have CW and CCW propellers. Each CW motor must be paired with a CW propeller, and CCW motors must be paired with CCW propellers. You can determine the direction of a motor by looking at the arrow on the side of the motor. You can determine the direction of a propeller by looking at the colour of its center. Propellers with black centers are for CW motors, and propellers with silver centers are for CCW motors.

raspberry pi quadcopter

Figure 10. CCW propeller (top) and CW propeller (bottom)

To install a propeller on a motor simply place the bottom of the propeller’s center (you will see a threaded hole) on the shaft of the motor. Then hold your motor using your propeller tightener, and spin your propeller in the opposite direction it is intended to be spun until you feel significant resistance. At this point use two fingers to hold the propeller at its center and keep it from rotating and then tighten the propeller my rotating the motor with your propeller tightener.

Step 7: Remove the Xiaomi Yi camera from the gimbal

As a new pilot, you are likely going to crash your quadcopter. And when crashing your quadcopter you can damage components. Hence why I recommend removing the gimbal and camera to prevent damaging expensive components during crashes.

You can remove the camera from the gimbal by loosening the two screws holding the camera on the gimbal and then sliding the camera out of the bracket.

 

raspberry pi quadcopter

Figure 11: Xiaomi Yi Camera installed in gimbal (note the position of the two screws)

Step 8: Remove the gimbal from the frame

To remove the gimbal from the frame remove the nuts from the four bolts that secure it to the frame. When doing so make sure that the gimbal does not fall, hold the gimbal in one hand and loosen the bolts with the other hand. After removing the four nuts the gimbal should simply slide out of the frame.

Step 9: Calibrate compass

Calibrating your compass is an optional step that may make your quadcopter more stable when in GPS mode.

Please refer to step-by-step guide for calibration below [in GPS mode].

Calibration Procedures – DJI Wiki

  1. Switch on the transmitter, and then power on autopilot system!
  2. Quickly switch the control mode switch from Manual Mode to GPS ATTI. Mode and back to Manual Mode for 6 to 10 times, The LED indicator will turn on constantly yellow.
  3. Hold your quadcopter horizontally and rotate it around the gravitational force line (about 360 degrees) until the LED changes to constant green, and then go to the next step.
raspberry pi quadcopter

Figure 12: Holding quadcopter horizontally / ©DJI Wiki

  1. Hold your quadcopter vertically and rotate it (its nose is downward) around the gravitational force line (about 360 degrees) until the LED turns off, meaning the calibration is finished.
raspberry pi quadcopter

Figure 13: Holding quadcopter vertically / ©DJI Wiki

  1. If the calibration was successful, calibration mode will exit automatically. If the LED keeps flashing quickly in Red, the calibration has failed. Switch the control mode switch one time to cancel the calibration, and then restart from step 2.

Note: You don’t need to rotate your multi-rotor on a precise horizontal or vertical surface, but keep at least 45° difference between horizontal and vertical calibration.

When to do re-calibration:

  1. The flight field is changed.
  2. When the multi-rotor mechanical setup has changed:
    a) If the GPS/Compass module is re-positioned.
    b) If electronic devices are added/removed/ re-positioned (Main Controller, servos, batteries, etc.).
    c) When the mechanical structure of the multi-rotor is changed.
  3. If the flight direction appears to be shifting (i.e. the multi-rotor doesn’t “fly straight”).
  4. The LED indicator often indicates abnormality blinking when the multi-rotor spins. (It is normal for this to happen only occasionally.)

Step 10: Getting ready for your first flight

We will use the first flight of the quadcopter both as a way to test that every component of the quadcopter is performing normally and for you to get familiar with the quadcopter’s controls. Before flying, make ensure that:

  • You place your drone at least 10 meters away from you in a large open area
  • Ensure you are following all the safety precautions mentioned above
  • Run through your preflight checklist
  • Point the front of the quadcopter away from you.
  • Connect your battery

Step 11: The quadcopter’s first flight

For your first flight arm the quadcopter (by holding both transmitter stick in the bottom corner closest to the center) and then slowly increase the throttle until the quadcopter takes off. Gingerly manage (don’t make quick movements) to the quadcopter’s throttle until it reaches a height of about 10 feet. When the quadcopter reaches a height of 10 ft put the throttle back to its midpoint.

You can get familiar with the elevator and aileron controls by slowly moving your quadcopter forward and backwards; right and left. As your piloting skills increase you will realize that all movements of the quadcopter are the result of elevator, aileron, and yaw commands.

After a few minutes, you can use the aileron and elevator sticks to direct the quadcopter towards where you want to land. Then slowly lower the throttle until the quadcopter is at rest on the ground. As the quadcopter is descending you may need to make small adjustments with the elevator and aileron sticks to keep the quadcopter over your intended landing location.

Step 12: Learn more quadcopter flying techniques

This is the point of the article where we will leave you to learn on your own. The purpose of this article was to show you how to configure a drone so that it is ready to fly, not necessarily to teach you how to fly a drone. I would recommend that you consult the excellent guide here as you develop your quadcopter piloting skills.