This article is a translation from DevicePlus.com.
DIY Raspberry Pi Drone Part 2 – Naza-M Lite Guide
In the previous article, we introduced the individual hardware in the system and assembled a quadcopter. In this second part, we will introduce the software part of the quadcopter. We will configure the transmitter and receiver and connect them to the NAZA.
Through this project, we can assemble a quadcopter that can take high-quality aerial photos and stable HD videos using some ready-made components. This aircraft also comes with various safety features, allowing beginners to operate the quadcopter confidently. The real-time video stream from the quadcopter is transmitted via Wifi from the Raspberry Pi to mobile devices. This drone is also equipped with a Linux computer, which will provide you with many creative options—additional sensors, computer vision, etc.
Naza-M Lite Assistant (download at https://www.dji.com/naza-m-lite/download)
Transmitter and Receiver Configuration
Step 1: Configure Mode Type
When the transmitter is powered on for the first time, you will see a menu very similar to the one in the image below. This menu contains several useful indicators: the battery voltage of the transmitter is in the upper right; directly below the battery voltage is the flight mode of the quadcopter; to the left of the battery voltage is the signal strength between the transmitter and receiver; T1 and T2 are timers that can be activated by switches.Figure 1. Transmitter Main ScreenTo access the configuration menu, we need to configure the transmitter by simply pressing the Mode button. Use the wheel on the right side of the screen to select the MODEL TYPE option, then press the wheel to enter the menu. (From now on, I will define this operation as pressing the Enter key).Figure 2. Mode Configuration MenuAs you can see, our transmitter is configured to “HELICOPTER” by default. To make our transmitter work for the quadcopter, we must change the mode to “AIRCRAFT”. To do this, first select “TYPE”, then press the middle button, scroll to select “AIRCRAFT”, and press the Enter key to save your selection.Figure 3. Mode Configuration Menu After Changing Mode TypeAfter setting the mode type to AIRCRAFT, you will see the quadcopter icon as shown in Figure 3. Next, let’s configure the endpoint values!
Step 2: Configure Channel Endpoint Values
Figure 4. Channel Endpoint MenuEnter the END POINT menu. The first four channels remain unchanged. However, we need to change the endpoint values for channel 5 and channel 6. Use the wheel to select the fifth channel, then press the Enter key, and adjust the low point (L) and high point (H) of the channel to match the above image.
Step 3: Configure Channel Reversal
Figure 5. Channel Reversal MenuThe “ELEVATOR” channel and the “THROTTLE” channel of the transmitter are set to reverse by default. To correct this issue, we enter the “REVERSE” menu and reverse the “ELEV” channel and the “THRO” channel. Select the corresponding channel, press the Enter key, and use the wheel to change NOR to REV.
Step 4: Configure Auxiliary Channels
Figure 6. Auxiliary Channel MenuTo link the three-way switch to the flight mode and direction lock channel, enter the AUX-CH menu. On this page, simply set the CH6 switch to SwG.
Step 5: Configure Failsafe Mode
Figure 7. Failsafe Configuration MenuIf the connection between the transmitter and receiver is interrupted, we want the quadcopter to automatically enter failsafe mode. To do this, enter the F/S menu and set the values for the failsafe channels as shown in the image above. In fact, we will set the “AILERON”, “ELEVATOR”, and “RUDDER” to default values, set the “THROTTLE” to 50% (hover), and switch the flight mode to failsafe mode.
Step 6: Download and Install Naza-M Lite Assistant
To configure the Naza-M Lite, we need to install the Naza-M Lite Assistant on a Windows computer. You can click here to download it. Please follow the on-screen instructions for installation.
Step 7: Configure and Connect to Naza
Figure 8. DJI Naza-M Lite Assistant Home PageThe Naza-M Lite has various flight modes. Let’s take a look at three control modes.Control Modes – DJI Wiki
GPS Attitude Mode: Similar to GPS Cruise Mode. The only difference is that this mode controls the helicopter’s attitude. The center position of the joystick is 0° attitude, and the endpoint is 45°, which is a fixed limit. GPS Attitude Mode can be used for large flight maneuvers, providing you with an excellent new flight experience.
For Ace series, WooKong-H series, and Naza-M series, the endpoint is 45°.
For WooKong-M series, the endpoint is 35°.
Attitude Mode: Suitable for environments with no GPS signal or weak GPS signal. The Ace One can accurately control attitude stability and lock flight altitude; the center position of the joystick is 0° attitude, and the endpoint is 45°, which is a fixed limit. Attitude mode can be used for large flight maneuvers.
For Ace series, WooKong-H series, and Naza-M series, the endpoint is 45°.
For WooKong-M series, the endpoint is 35°.
Manual Mode: This is direct mechanical drive. Except for the lack of balanced wing function, the autopilot system cannot keep the aircraft stable. Therefore, manual mode is suitable for experienced operators.
Once the failsafe function is enabled, the quadcopter will no longer respond to your input commands and will automatically return to its takeoff position. This function is very useful when the quadcopter loses control or is too far away for you to easily bring it back (especially for novice flyers).
Step 8: Configure Direction
Figure 9. Frame Layout Selection InterfaceIn the Aircraft tab, we can select the drone’s frame layout. We should choose “Quad-rotor X”. The reason for not selecting the first option “Quad-rotor I” is due to direction. Do you remember the image below?Figure 10. Motor Number Definition for NAZA / Ⓒkenstone6.netPreviously, we connected the motors to the flight controller based on the rotation directions shown in the image. The red arms in Figure 9, which correspond to M2 and M1 in Figure 10, represent the front of the quadcopter.
Step 9: Configure GPS Mounting
Figure 11. GPS Mounting SettingsIn the Mounting tab, we need to input the GPS coordinates. First, you need to balance the quadcopter’s center of gravity so that it is in the center of the main board. Then, fill in the GPS coordinates for the X, Y, and Z axes (Figure 11) as well as the center of gravity of the quadcopter. The direction of the MC ESC port should point towards the nose direction.
Step 10: Configure RC
Figure 12. R/C TX and RX SettingsOn this page, you can see the values for each channel and the current flight mode. Make sure to set the Receiver Type to Tradition. Other options remain unchanged. The “Gain” page can be ignored.
Step 11: Configure Motor Idle Speed
Figure 13. Motor SettingsPlease set the Motor Idle Speed to RECOMMENDED and set the Cut Off Type to Immediately.
Step 12: Enable Failsafe
Figure 14. Failsafe SettingsThis is the page that occurs when we choose to enter failsafe flight mode. I chose “Go-Home and Landing” instead of “Landing” because when the failsafe function is activated, “Landing” will cause the drone to land immediately at its current position, even if it is not a safe landing point. Instead, the “Go-Home and Landing” option will cause the quadcopter to rise to a height of 20m (if the flight height is above 20m, it will remain unchanged), then fly back above the takeoff point and land slowly.
Step 13: Enable Direction Lock
Figure 15. Intelligent Direction Control (IOC) SettingsIOC is essentially headless mode, which is useful when you try to position the camera at a specific angle. There are two locking modes: return point lock (forward direction = recorded nose direction) and heading lock (forward direction = original point of the quadcopter). We will not use these locks. Please set these 2 channels to “OFF”.Please ignore the “Gimbal” configuration page.
Step 14: Configure Battery Failsafe
Figure 16. Battery Failsafe PageAs described in part 1 of this series, be careful when using LiPo batteries and ensure safety. During flight, we should pay the most attention to the battery voltage. To prevent over-discharging the battery, set the Protection Switch to “ON” to enable low voltage alarm, and change the battery type to 3S LiPo. I recommend setting the “First Level Protection” load voltage to 10.50V and the “Second Level Protection” load voltage to 10.00V.“First Level Protection” will only cause the NAZA LED indicator to flash red quickly. If you see this alarm during flight, you should safely land the drone. If you wait for the “Second Level Protection” to take effect, the quadcopter will automatically land to prevent battery damage.
Step 15: Calibrate IMU
Figure 17. IMU Calibration PageBefore the first flight of the quadcopter, be sure to calibrate the gyroscope and accelerometer. To do this, simply place the quadcopter on a level surface and click the “Basic Cali” button near the bottom of the page.Next, we will introduce how to set up FPV. This part is very important as it allows the real-time video stream from the quadcopter to be transmitted from the Raspberry Pi to mobile devices via WiFi. We will use an Android phone. We will also create a pre-flight checklist before flying the quadcopter.
FPV Setup Guide
Once successfully set up, the quadcopter’s real-time video stream is transmitted via Wifi from the Raspberry Pi to mobile devices. This tutorial requires an Android phone, so please prepare a usable phone. We will also install the propellers on the drone and provide a pre-flight checklist at the end of the article to ensure safe and successful flight.
Hardware
The quadcopter assembled in part 1
The propellers from part 1
Android phone
MicroB USB data cable
Software
Naza-M Lite Assistant (click here to download)
Github
Tools
DJI Flamewheel 450 kit with propeller tightening tool
A computer running Windows
Setting Up Android Phone for FPV
Step 1: Choose the FPV Implementation Method for Raspberry Pi
The video from the Raspberry Pi on the drone is sent to the Android phone via a WiFi hotspot. Currently, I have summarized three ways to set up an FPV video stream on an Android phone:
Both the phone and quadcopter are connected to the ground router
You can use a WiFi router with higher transmission power, which means a larger coverage area for the signal. However, the biggest disadvantage of this scheme is that you would have to carry this router while flying, and the router also needs a separate power supply, which increases the number of equipment you must carry during flight.
The phone connects to the WiFi hotspot hosted on the Raspberry Pi
This solution seems ideal because it can work with any observation device regardless of whether it can host a WiFi hotspot. However, based on my experience, the downside of this method is that it is difficult to enable Access Point mode on the WiFi wireless card.
The Raspberry Pi connects to the WiFi hotspot hosted on the phone
The WiFi hotspot on the phone does not require a WiFi router and extra power supply, making it very easy to establish a WiFi hotspot. Most Android phones can create a WiFi hotspot in a few minutes.
Step 2: Set Up WiFi Hotspot on Android Phone
The example uses a Nexus 5 phone running Android 6.0.1. In fact, any phone with Android 2.2 and above (almost all current phones) should support WiFi hotspot functionality.Note: The specific steps and menus shown below may vary depending on the phone manufacturer.To set up a WiFi hotspot, first open the settings application. You should see a menu similar to the one in the image below.Figure 1. Android Settings MenuIn the Wireless & networks menu, click on the More option. You should see a menu similar to the one in the image below.Figure 2. Network SettingsEnter the Tethering & portable hotspot menu, and you will see the following options. Click on Setup Wi-Fi hotspot to start configuring the WiFi hotspot.Figure 3. Hotspot MenuNow, fill in the appropriate fields to configure the phone’s WiFi network name, security, and frequency band. Please define the name yourself.To ensure that the network is only accessible to our drone and ourselves, we will set Security to “WPA2 PSK” and set the Password to “deviceplus”.The last field Select AP Band is very important. This field specifies the frequency band used by the WiFi hotspot. We have two options: 2.4 GHz and 5 GHz.We should use the 5 GHz band, which is very important. This is because our RC receiver (the device installed in part 1 of this series) uses the 2.4 GHz band, and running both the hotspot and RC receiver on the same band increases the chance of mutual interference, causing you to lose control of the drone.Figure 4. WiFi Hotspot ConfigurationOnce all fields are filled in, click SAVE to complete the WiFi hotspot configuration! Now, just click the slider to the right of Portable Wi-Fi hotspot (see Figure 2) to enable the hotspot.
Step 3: Install Raspberry Pi Camera Viewer Application
We also need a special application to display the video stream coming from the camera on the phone. The application used in this article is RaspberryPi Camera Viewer. Please download and install this application on your phone from the following URL (Google Play Store): https://play.google.com/store/apps/details?id=pl.effisoft.rpicamviewer2.Figure 5. RaspberryPi Camera Viewer on Google Play
Step 4: Set Up Raspberry Pi Camera Viewer Application
Once the Raspberry Pi Camera Viewer is installed on the phone, you need to set up the application. When you first start the application, you will see an almost blank interface as shown in the image below.Figure 6. First Time Opening the Live Streaming ApplicationStart configuring the application according to our needs by clicking the (+) button near the top right corner. This button allows us to create a new profile. Click this button, and a channel editing menu will pop up.Figure 7. Default Channel Editing InterfaceWe need to change many options. First, please check the checkbox next to Enable advanced mode to access more settings. Then change the name to QuadcopterFPV or a similar descriptive name. Now we must make the most important setting—the channel description. The channel description tells the application how to decode the incoming video stream (for more information, see GStreamer Pipeline).Please enter the following content in the field:tcpclientsrc host=0.0.0.0 port=5000 ! gdpdepay ! rtph264depay ! avdec_h264 ! videoconvert ! autovideosink sync=falseReplace with:udpsrc port=9000 ! gdpdepay ! rtph264depay ! avdec_h264 ! videoconvert ! autovideosink sync=falseThe only difference between these two channel descriptions is that our new channel description uses UDP instead of TCP. We use UDP because it has lower video latency and can handle dropped frames or information loss better.The last option we must configure is Enable application extra features. Please check the checkbox next to this option. This will allow us to take screenshots of the video during flight, which is useful.Figure 8. Final SettingsAfter adjusting all settings, scroll to the bottom of the application and click the SAVE button to save all changes. In the next steps, we will set up the Raspberry Pi to connect to the hotspot for camera and video transmission functionalities.
Setting up Raspberry Pi for FPV
To simplify the configuration of the Raspberry Pi, I created a Raspbian image that can easily install Raspberry Pi for FPV. You can download my custom latest version of the Raspbian image here: https://github.com/brenton311/drone-files/releases/download/v0.1/image.zip.To install this image, you must first extract the zip file and then follow the instructions for the latest operating system on Raspberry Pi: https://www.raspberrypi.org/documentation/installation/installing-images/.Once the installation is complete, power on the Raspberry Pi, and it will start transmitting the video stream to the phone (the Raspberry Pi takes about 40 seconds to boot, so the video will not appear on the screen immediately).
Test Flight/How to Fly the Drone
Step 1: Learn the Purpose of Each Stick and Switch
Figure 9. The Associated Sticks Marked on the Transmitter
Throttle (Stick 1: Vertical Axis) The throttle controls the speed of the motors. The higher the throttle, the faster the motors spin; the lower the throttle, the slower the motors spin. Typically, when the throttle is increased to half, the quadcopter will hover in the air (not moving up or down). When the throttle is below 50%, the aircraft will descend; when the throttle is above 50%, the aircraft will ascend.
Rudder/Yaw Stick (Stick 1: Horizontal Axis) The rudder stick controls the rate at which the quadcopter rotates around the yaw axis. When the rudder stick is centered, the quadcopter does not rotate. When the rudder stick is moved to the right, the quadcopter will rotate clockwise; when the rudder stick is moved to the left, the quadcopter will rotate counterclockwise.
Elevator/Pitch Stick (Stick 2: Vertical Axis) The elevator stick controls the angle at which the quadcopter tilts along the pitch axis. Pushing the elevator stick away from you will make the drone tilt forward; pulling the elevator stick towards you will make the drone tilt backward.
Aileron/Roll Stick (Stick 2: Horizontal Axis) The aileron stick controls the angle at which the quadcopter tilts along the roll axis. When the aileron stick is moved to the right, the drone will tilt to the right; when the aileron stick is moved to the left, the drone will tilt to the left. When both the elevator stick and aileron stick are centered, the quadcopter remains level.
Direction Lock (Stick 3) This three-way switch can switch between three direction lock modes (off, heading lock, and return point lock), which we discussed earlier in the NAZA Configuration Steps.
Flight Mode Switch (Stick 4) This three-way switch sets the flight mode. We configured NAZA to switch between three flight modes: GPS ATTI, ATTI, and FAILSAFE (GPS attitude, attitude, and failsafe). We have already discussed the functionality of each flight mode in the NAZA Configuration Steps.
Step 2: Create a Pre-Flight Checklist
Many unexpected events can occur when flying the quadcopter. To prevent low-level errors, I recommend that you create a pre-flight checklist. Before flying the quadcopter, I check the following items:
Ensure that the propellers are tightened and installed in the correct direction
Ensure that the battery is fully charged
Check the drone for any damage (such as cracks in the body, loose wires, etc.)
Ensure that the transmitter’s battery voltage is acceptable
Ensure that the area you are in is legal and safe to fly the quadcopter
Be sure to thoroughly understand your quadcopter, its flying characteristics, control methods, and how to handle problems that may arise
Wait for the NAZA LED to display green before taking off with the quadcopter.
Step 3: Learn Basic Flying Skills
Always keep the front end of the quadcopter facing away from your position (use direction lock if needed): If direction lock is not enabled, all rotation and pitch commands will be determined by the direction the quadcopter is facing. Failing to recognize the quadcopter’s orientation may lead to crashes, as your commands will not be executed as you think.
Throttle to 50% to hover: Ideally, the thrust-to-weight ratio of the quadcopter is 2:1, so when the throttle is increased to about 50%, it will hover. If you find that the throttle value is significantly high when hovering (for example, greater than 70%), the quadcopter may be too heavy—try reducing the load or using more powerful motors.
Do not overreact: The controls on the quadcopter are very sensitive, and the quadcopter can fly very fast. If it does not fly in the expected direction, make small adjustments to the yaw and pitch sticks slowly and safely.
Step 4: Always Fly the QuadCopter Safely [Important!]
Always comply with all applicable laws regarding drones (unmanned aerial vehicles) in your area! DevicePlus and the authors of this series of articles assume no responsibility for any personal or property damage resulting from the assembly or use of this drone. Drones can be very dangerous! Please operate your drone legally and safely.
If you are a beginner, be mentally prepared for the possibility of the drone crashing.
Do not over-discharge the battery.
Fly in an open area away from people, cars, or other buildings (fields, large parks).
Do not fly near airports (consult applicable laws for the no-fly radius around airports).
Never let the quadcopter fly out of sight or fly at night.
Step 5: Charge the Battery
Before attempting to charge the battery, please refer to the important information regarding battery specifications and proper maintenance in part 1 of this series. You can also click here to view the guide on LiPo batteries.The exact steps for configuring and using LiPo battery chargers vary by charger, but generally, you must:
Ensure that the charger is set to LiPo mode (many chargers support multiple chemical compositions of batteries)
Set the battery voltage to 3S (make corresponding changes if using other batteries)
Set the battery capacity to 3300mAh (make corresponding changes if using other batteries)
The charging current can remain at the default value (usually 1C)
Connect the battery leads to the charger with the correct polarity
Connect the battery’s balance lead to the balance charger
When charging the battery, keep it away from any flammable materials (it is recommended to charge outdoors)
Monitor the battery while charging to ensure it does not swell, smoke, or overheat. If any of these signs occur, stop charging immediately and move the battery outdoors away from flammable materials.
Step 6: Install the Propellers
Like the quadcopter’s clockwise and counterclockwise motors, the propellers also have clockwise and counterclockwise designs. Each clockwise motor must be paired with a clockwise propeller, and each counterclockwise motor must be paired with a counterclockwise propeller. The direction of the motor can be determined by looking at the arrow on the side of the motor. The direction of the propeller can be determined by looking at the color in the middle of the propeller.The black propeller in the middle pairs with the clockwise motor, and the silver propeller in the middle pairs with the counterclockwise motor.Figure 10. Counterclockwise Propeller (Top) and Clockwise Propeller (Bottom)To install the propeller on the motor, simply place the bottom of the propeller’s center (you will see a threaded hole) onto the motor shaft. Then, use the propeller tightening tool to secure the motor and turn the propeller in the opposite direction of the rotation until you feel significant resistance. At this point, hold the propeller in place with two fingers to prevent it from rotating, and then use the propeller tightening tool to turn the motor and lock the propeller.
Step 7: Remove the Xiaomi Yi Camera from the Gimbal
As a novice flyer, the chances of crashing your quadcopter are high. Components may be damaged when the quadcopter crashes. This is why I recommend removing the gimbal and camera—to prevent damage to expensive components in case of a crash.To remove the camera from the gimbal, loosen the two screws that secure the camera to the gimbal, then slide the camera out of the bracket and remove it.Figure 11. Xiaomi Yi Camera Installed in the Gimbal (Note the Location of the Two Screws)
Step 8: Remove the Gimbal from the Frame
To remove the gimbal from the frame, unscrew the four nuts that secure it to the frame. At the same time, ensure that the gimbal does not fall: hold the gimbal with one hand while loosening the bolts with the other hand. After removing the four nuts, the gimbal can simply slide out of the frame.
Step 9: Calibrate the Compass
Calibrating the compass is an optional step that can make the quadcopter more stable in GPS mode.Please refer to the step-by-step calibration guide below [in GPS mode].Calibration Procedure – DJI Wiki
Turn on the transmitter and then turn on the autopilot system!
Quickly switch the control mode from manual mode to GPS ATTI, then switch back to manual mode, back and forth 6 to 10 times, until the LED indicator lights up yellow.
Place the quadcopter horizontally and rotate the machine around the gravity line (about 360 degrees) until the LED turns solid green, then proceed to the next step.
Keep the quadcopter vertical and rotate it around the gravity line (about 360 degrees) with the nose pointing down until the LED turns off, indicating that calibration is complete.
After successful calibration, it will automatically exit calibration mode. If the LED continues to flash red quickly, it indicates that calibration failed. Toggle the control mode switch to cancel the calibration and start again from step 2.
Note: You do not need to rotate the multi-rotor on an exact horizontal or vertical surface, but there should be at least a 45° difference between the horizontal and vertical calibrations.Conditions for recalibration:
When the flight area changes.
When there are changes in the multi-rotor mechanical setup: a) GPS/compass module is relocated. b) Electronic devices (main controller, servos, battery, etc.) are added/removed/repositioned. c) Mechanical structure of the multi-rotor changes.
If the flight direction seems to be changing (for example, if the multi-rotor cannot fly in a