Category Archives: Quadcopters

HobbyKing AIO – GPS and Bluetooth

I started by connecting the HobbyKing AIO board to the GPS that I bought from HobbyKing for $35 and to the HC-05 Bluetooth module. This allows me to configure the AIO via BT.


The connections are as follows:

GPS to AIO board

The UBlox Neo-7M GPS comes with a cable that has 2 mini-molex connectors, one with 4 pins and one with 5 pins.

gps connector

Some changes must be made to these connections in order to fit them to the AIO board. Moving the cables between pins is simple – lift the flap that holds the cable inside the connector and pull the cable out. See the photo below.


The changes to cabling are as follows:

4-pin connector

The 4 pin connector is connected to the i2C connector on the AIO.

It should have the following cable connected to it, from top (leftmost) to bottom:

  1. SCL – moved from pin 2
  2. SDA – moved from pin 3
  3. VCC – moved from the 5-pin connector
  4. GND – moved from the 5-pin connector

5-pin connector

The TX and RX cables from the 5-pin connector must be connected to RX2 and TX2 on the AIO board respectively. So I replaced the 5-pin connector with a 6-pin connector that I had from the AIO package and connected the TX and RX cables at the right slots.

AIO board to HC-05 BT module

The BT module connects to the FTDI port on the AIO as follows:

  1. AIO GND  —> HC-05 GND
  2. AIO VCC   —> HC-05 5V
  3. AIO – RX   —> HC-05 TX
  4. AIO TX is connected to HC-05 RC via a voltage divider in order to protect the HC-05. The HC-05 uses 3.3V while the output of the AIO board may be 5V. The following photo of a crumpled piece of paper shows the two resistors that form the voltage divider.


AIO external power

The AIO receives 5V power from an external source on the GND and VCC pins.

HC-05 Setup

The HobbyKing AIO that I’m using in this project talks MAVLink with the APM console (or any other MAVLink management console). I decided to use BT for connecting it to the console so I borrowed a HC-05 module from my good friend Tomer.

The HC-05 comes configured for 38400 bps (bits per second) so the first step was to configure it to operate at 115200 bps.

Configuration of the HC-05 is done with a FTDI board. I bought one on Ali express for $2.48.

Here are the HC-05 on the right and the FTDI board on the left:


This FTDI board has a switch that sets it to use 3.3V or 5V. Since the HC-05 is sensitive to voltages over 3.3 I used 3.3V.

The HC-05 enters configuration mode (via AT commands) when pin 34 is pulled high. On this board pin 34 is connected to “Key”.

The two boards are connected as follows:

  1. FTDI ground —> HC-05 ground
  2. FTDI TX          —> HC-05 RX
  3. FTDI RX          —> HC-05 TX
  4. FTDI VCC       —> HC-05 Key
  5. FTDI VCC       —> HC-05 5V

Now the FTDI board can be connected to a USB port and you can use a terminal program (I used Arduino’s serial monitor) to connect to it. Remember that the connection speed is 38400.

Sent “AT” to the board and it should respond with “OK”.

To change the bit rate send “AT+UART=115200,0,0”. The board should respond with “OK” and it is ready.

The data sheet for the HC-05 can be found here.

Flying by cellular – Project Plan

After a long break while working for a start-up company I’m returning to my main technological hobby – quadcopters.

This time I’m building a quadcopter based on the HobbyKing AIO board:


My main goal is to control the UAS (unmanned aerial system) over the cellular network. This means that commands will be sent to the UAS over the cellular network and the video feed from the UAS to the operator’s console (a computer, or a cheap PS3 joystick) will also be transmitted over the cellular network.

There is nothing new in this approach by itself and people all over the net are doing it by putting a $50 Raspberry Pi running Linux on the UAS. My angle on this would be to try and achieve this goal with cheap hardware.

My development plan is as follows:

  1. Build a good and stable UAS and get it to fly with the HK AIO controller – using the HK firmware
  2. Compile the firmware from sources, configure it and get it to fly
  3. Transmit commands over the cellular network
  4. Transmit the video feed back over the cellular network

LED Controller – Planning

After learning how to use the various features of the PIC16F1825 controller that I need for building and writing the LED controller it is time for some planning.

First the HW. Following is a schematic diagram that I prepared with the Freeware version of the Eagle application for Mac. Here are the details.

Screen Shot 2015-05-25 at 2.16.42 AM

It is an excellent app and I thank my friend Tomer for telling me about it. The freeware version is limited but completely suitable for my current educational purposes. I will even allow me to design a board if I choose to do so – the freeware version is limited to 10cm by 8 cm boards and this size is enough for my LED controller.

The application is a bit non intuitive, especially with the MAC single-key mouse, but after a bit of practice and watching this video, I managed to draw the whole schematic in about 1.5 hours.

So, here is my schematic diagram.


It looks a bit complicated but it is not. It consists of the following components:

[table id=4 /]

Most of the wiring in this diagram are for the 7-segment display. I think that the rest is self explanatory to some extent and will be clarified in the next posts when I start writing the SW.

I’m aware that this schematic is probably “on the face” as we say in Hebrew, which means very poor and I’m sure I will improve as we go.

Quadcopter 1: Preparing to fly

I’m publishing this post a bit out of order as I already published the post about flying because it was simpler and shorter. However, lets not get hung up on small details. So here I explain the last stages of preparation before flying.

The stages are:
  1. Pair the receiver to the transmitter
  2. ESC calibration
  3. Naza calibration
  4. Attach the propellors  – they must be completely parallel to the ground
  5. Hold it by hand to  see that it responds correctly to RC commands (if it is a small model). Alternatively, you can ask someone to help as I’ll explain.
  6. Find an empty field large enough to fly without crashing into something, or worse, some spectators
All the steps from 1 to 5 should be carried out with the propellors NOT attached to the engines.

 Pairing the receiver to the transmitter

Usually most transmitters and receivers have buttons that place them in pairing mode. Follow the procedure for your devices. I found that my Hitec transmitter works with the Hitec Optima receiver (obviously) and with the cheap Minima receiver.

ESC Calibration

The purpose of ESC calibration is to set the throttle range onto the ESCs. Follow these steps to do that:

  1. Connect the signal cable of the ESC (its color is usually white) to the throttle channel of the receiver. This is usually channel 3 and the signal connector is the upper one.
  2. Turn the transmitter on
  3. Push the throttle to the top most position
  4. Connect the quadcopter power. The receiver should come on
  5. The engine should beep twice
  6. Within 2 seconds move the throttle to the bottom position
  7. The engine should beep 3 times and the ESC should reset itself
  8. Move the throttle up and verify the engine starts. Note the direction in which the engine rotates – clockwise (CW) or counter clockwise (CCW)

The ESC programming instructions are usually the same for all ESCs because they all run the same SimonK firmware. The instructions for my 4-in-1 ESC can be found here.

Note that when the engine starts it should beep several times corresponding to the number of cells in the battery. If one or more engines beep a wrong count then these engines should be programmed. The programming instructions can be found in the ESC manual.

After all engines are calibrated connect the ESC signal cables to the correct engine ports on the Naza controller.

Naza calibration

Naza calibration is guided by the Naza configuration application DJI Naza-M V2 Assistant that runs on Windows and MAC. Here is a screenshot of it’s first screen.

naza first screen

I will not repeat here the information and instructions listed in the Naza-M quick start manual. I will only point out some important points that might be overlooked.

It is important to do all the configuration steps when calibrating the Naza for the first time especially the IMU calibration in the Tools window.

I recommend to do the Naza compass calibration as well. This procedure is described here.

Attaching the propellors

Note that there are two clockwise propellors (CW) and two counter-clockwise propelloers (CCW). The propellors must be attached so that the two CW and the two CCW propellors are at the edges of the diagonals.

You must also ensure that the engines rotate the right way, i.e. the CW propellor should rotate CW and the CCW propellor should rotate CCW. If an engine turns the wrong way then disconnect two of the engine’s three power cables and swap them, meaning that each should be connected to the other lead coming from the engine. This will reverse the engine’s direction.

Hold the quadcopter by hand and run a dry test

This is a risky step and I suggest to do it only if you are a cool headed grown up guy/girl and your model is small enough to hold it with one hand. If the model is large then you should ask someone to help and hold it above his head.

So, hold the quadcopter tightly, arm the system and bring the throttle up until all propellors spin. Be careful not to let go.

Now move the remote control sticks and verify that the quadcopter responds correctly.

Next release the sticks and let them return to their center position. Then hold the quadcopter and tilt it to each side. You should feel the quadcopter resist as it tries to stabilize itself.


Before flying you should perform the following checklist:
  1. All screws are tight. Especially those that connect the engines to the frame
  2. The battery is attached securely
  3. The propellors are screwed on tightly
  4. The propellors are parallel to the ground
  5. The indicator lights are in their normal state

First flights 

My first flights were catastrophic. I crashed the quadcopter many times and broke many propellors and some engines. So here are some tips to get you started:

Be patient – its takes time for your fingers to learn the controls and respond quickly and correctly.

Start flying in normal mode – be aware where the “forward” direction is and stand behind the quadcopter.

Start with simple flights – lift of and land, lift off, move one meter to each direction and land. And so on …

Don’t start flying in strong winds.

Try to fly the quadcopter circles. I think that if you succeed (in normal flight mode) then you are doing nice progress.

LED Controller – init sequence


When the controller starts it performs the init sequence. The goals of the init sequence are:

  1. Verify that all LEDs are in working order
  2. Read min/max values from NVRAM
  3. Allow the operator to set the min and max range of the PWM signal
  4. Start normal operation – read the PWM value and set the LEDs


The following sections describe the steps of the init sequence. The steps are divided into functional areas.

LED verification

On start up all LEDs should flash for 1.0 second:

  1. Turn all LEDs on with highest intensity (LED State = LEDON)
  2. Enable Timer0
  3. Wait 1000 ms
  4. Disable Timer0
  5. Turn all LEDs off (LED State = LEDOFF)

Load PWM range from NVRAM

  1. Read the min and max values from NVRAM into global variables
  2. If min > max then move to Settings mode
  3. If min > 1023 then move to Settings mode
  4. If max > 1024 then move to Settings mode
  5. If min and max values are sensible then check if settings mode is enabled.

 Check if settings mode is enabled

To enter the settings mode the user should press the push button (SPST switch) during the LED verification stage (1 second).

 Check if the switch is pressed

  1. If the switch is pressed then enter settings mode
  2. If the switch is not pressed then move to normal operation

 Settings mode

Settigs mode allows the user to set the range (max – min) of the PWM value for the LED controller channel

To set the mode the user should move the PWM switch all the way up, wait one second and then all the way down and wait one second.Turn LED 1 on

  1. Start capturing the PWM value.
  2. Enable Timer0
  3. Set counter to 0
  4. While value n+1 is greater than value n set counter to 0
  5. If value n+1 == value n, then check the counter.
  6. If the counter value is 1 secod then:
    1. Store the PWM value as max in NVRAM
    2. Store the PWM value as max in the variable
    3. Turn LED 1 off
    4. Turn LED 2 on
  7. While value n+1 == MAX do nothing
  8. While value n+1 < value n then:
    1. Set counter to 0
  9. If value n+1 == value n then check the counter
  10. If the counter value is 1 second then:
    1. Turn LED2 off
    2. Store the PWM value as min in NVRAM
    3. Store the PWM value as min in the variable
    4. Move to normal operation.

LED Controller Requirements


The LED Controller (LC) for quadcopters controls up to 4 high-power LEDs that can be attached to the quadcopter and can be used to make it visible in the dark and/or indicate the status and condition of the quadcopter.

The LC supports multiple configurations of LEDs as described below. It allows the operator to select configurations via the remote control over a dedicated channel.

The blinking interval (the length of time that the LEDs are on or off) can be set by a potentiometer.

The LC may include an optional 7-segment display that shows the LC state.


The LC consists of the following HW components:

Component Purpose
PIC16F1825 Application processor – runs the main LC application
PIC16F1826 Optional 7-segment display controller
7-segment display Optional. Displays:

  • the blink interval
  • the PWM min and max values while in settings mode
  • the configuration number (see below) while the user is changing the mode
10K Potentiometer Defines the “blink interval” the amount of time a LED stays on when blinking
Push button – SPST Forces the LC into settings mode
4 Transistors For switching current to the LEDs. One for each LED.
4 High power LEDs

LED Configurations

The LC supports the following configurations:

ID Name Description
1 All off All LEDs are off
2 All on All LEDs stay on permanently
3 All blinking – 1 – High intensity  All LEDs blinking in a fixed rate – on and off
 4  All blinking – 1 – Low intensity  All LEDs blinking in a fixed rate – on and off
 5  All blinking – 2 – High intensity  All LEDs blinking twice and then a break
 6  All blinking – 2 – Low intensity  All LEDs blinking twice and then a break
 7 All blinking – 3 – High intensity  All LEDs blinking three times and then a break
 8 All blinking – 3 – Low intensity  All LEDs blinking three times and then a break
 9 LEDS 1, 2 on and 3, 4 off  
10 LEDs 3, 4 on and 1, 2 off  
11 LEDs 1, 2 blinking 1 – High intensity LEDs 3, 4 are off. LEDs 1 and 2 are blinking in a fixed rate
12 LEDs 1, 2 blinking 1 – Low intensity LEDs 3, 4 are off. LEDs 1 and 2 are blinking in a fixed rate
13 LEDs 1, 2 blinking 2 – High  intensity LEDs 3, 4 are off. LEDs 1 and 2 are blinking twice and then a break
14 LEDs 1, 2 blinking 2 – Low  intensity LEDs 3, 4 are off. LEDs 1 and 2 are blinking twice and then a break
15 LEDs 1, 2 blinking 3 – High  intensity LEDs 3, 4 are off. LEDs 1 and 2 are blinking three times and then a break
16 LEDs 1, 2 blinking 3 – Low  intensity LEDs 3, 4 are off. LEDs 1 and 2 are blinking three times and then a break
17 LEDs 3, 4 blinking – 1 – High intensity LEDs 1, 2 are off. LEDs 3 and 4 are blinking at a fixed rate
18 LEDs 3, 4 blinking – 1 – Low intensity LEDs 1, 2 are off. LEDs 3 and 4 are blinking at a fixed rate
19 LEDs 3, 4 blinking – 2 – High intensity LEDs 1, 2 are off. LEDs 3 and 4 are blinking twice and then a break
20 LEDs 3, 4 blinking – 2 – Low intensity LEDs 1, 2 are off. LEDs 3 and 4 are blinking twice and then a break
21 LEDs 3, 4 blinking – 3 – High intensity LEDs 1, 2 are off. LEDs 3 and 4 are blinking three times and then a break
22 LEDs 3, 4 blinking – 3 – Low intensity LEDs 1, 2 are off. LEDs 3 and 4 are blinking three times and then a break.

Main use cases

The main use cases of the system are:

1. Initialization

When the LC starts it enters the initialization sequence. The init sequence is described in a separate post.

2. Normal operation

In normal operation the LC drives the LEDs according to the currently selected configuration. The LC also monitors the following inputs:

a. Potentiometer – the potentiometer value determines the blink interval – the time that LEDs, in blinking mode, are on and off. In the “blinking 2” and “blinking 3” modes, the potentiometer value determines also the amount of time that the LED is off between blinks. This amount of time is twice as long as the blinking interval. When the value of the potentiometer changes the LC performs the “Setting the blink interval” use case.

b. RC input. If the PWM value on the RC channel changes then the LC performs the “Changing the LED configuration” use case.

During normal operation the 7-segment display, if present, shows  the ID of the current LED configuration.

3. Setting the blink interval

When the blink interval is changed (i.e. the potentiometer value is changed) and if the 7-segment display is present, then the LC displays the new value of the potentiometer for 1 second. After 1 second the display returns to showing the configuration ID.

4. Changing the LED configuration

When the PWM value changes, the LC moves to the newly selected LED configuration. The LC also displays the current configuration ID on the 7-segment display, if present.