16 KiB
Usage: build, setup and flight
To fly Flix quadcopter, you need to build the firmware, upload it to the ESP32 board, and set up the drone for flight.
To get the firmware sources, clone the repository using git:
git clone https://github.com/okalachev/flix.git && cd flix
Beginners can download the source code as a ZIP archive.
Building the firmware
You can build and upload the firmware using either Arduino IDE (easier for beginners) or command line.
Arduino IDE (Windows, Linux, macOS)
- Install Arduino IDE (version 2 is recommended).
- Windows users might need to install USB to UART bridge driver from Silicon Labs.
- Install ESP32 core, version 3.3.6. See the official Espressif's instructions on installing ESP32 Core in Arduino IDE.
- Install the following libraries using Library Manager:
FlixPeriph, the latest version.MAVLink, version 2.0.25.
- Open the
flix/flix.inosketch from downloaded firmware sources in Arduino IDE. - Connect your ESP32 board to the computer and choose correct board type in Arduino IDE (WEMOS D1 MINI ESP32 for ESP32 Mini) and the port.
- Build and upload the firmware using Arduino IDE.
Command line (Windows, Linux, macOS)
-
On Linux, install it like this:
curl -fsSL https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh | BINDIR=~/.local/bin sh -
Windows users might need to install USB to UART bridge driver from Silicon Labs.
-
Compile the firmware using
make. Arduino dependencies will be installed automatically:makeYou can flash the firmware to the board using command:
make uploadYou can also compile the firmware, upload it and start serial port monitoring using command:
make upload monitor
See other available Make commands in Makefile.
Tip
You can test the firmware on a bare ESP32 board without connecting IMU and other peripherals. The Wi-Fi network
flixshould appear and all the basic functionality including console and QGroundControl connection should work.
Before first flight
Choose the IMU model
In case if using different IMU model than MPU9250, change imu variable declaration in the imu.ino:
ICM20948 imu(SPI); // For ICM-20948
MPU6050 imu(Wire); // For MPU-6050
Connect using QGroundControl
QGroundControl is a ground control station software that can be used to monitor and control the drone.
- Install mobile or desktop version of QGroundControl.
- Power up the drone.
- Connect your computer or smartphone to the appeared
flixWi-Fi network (password:flixwifi). - Launch QGroundControl app. It should connect and begin showing the drone's telemetry automatically.
Access console
The console is a command line interface (CLI) that allows to interact with the drone, change parameters, and perform various actions. There are two ways of accessing the console: using serial port or using QGroundControl (wirelessly).
To access the console using serial port:
- Connect the ESP32 board to the computer using USB cable.
- Open Serial Monitor in Arduino IDE (or use
make monitorin the command line). - In Arduino IDE, make sure the baudrate is set to 115200.
To access the console using QGroundControl:
- Connect to the drone using QGroundControl app.
- Go to the QGroundControl menu ⇒ Vehicle Setup ⇒ Analyze Tools ⇒ MAVLink Console.
Tip
Use
helpcommand to see the list of available commands.
Access parameters
The drone is configured using parameters. To access and modify them, go to the QGroundControl menu ⇒ Vehicle Setup ⇒ Parameters:
You can also work with parameters using p command in the console. Parameter names are case-insensitive.
Define IMU orientation
The IMU orientation (relative to the drone's axes) is defined using the parameters: IMU_ROT_ROLL, IMU_ROT_PITCH, and IMU_ROT_YAW.
The drone has X axis pointing forward, Y axis pointing left, and Z axis pointing up, and the supported IMU boards have X axis pointing to the mounting holes side and Z axis pointing up from the component side:
Use the following table to set the parameters for common IMU orientations:
Calibrate accelerometer
Before flight you need to calibrate the accelerometer:
- Access the console using QGroundControl (recommended) or Serial Monitor.
- Type
cacommand there and follow the instructions.
Setup motors
If using non-default motor pins, set the pin numbers using the parameters: MOTOR_PIN_FL, MOTOR_PIN_FR, MOTOR_PIN_RL, MOTOR_PIN_RR (front-left, front-right, rear-left, rear-right respectively).
Certain ESP32 models (such as ESP32-S3 and ESP32-C3) support a lower maximum PWM frequency; on these boards the parameter MOT_PWM_FREQ should be set to 38000 Hz.
If using brushless motors and ESCs:
- Set the appropriate PWM using the parameters:
MOT_PWM_STOP,MOT_PWM_MIN, andMOT_PWM_MAX(1000, 1000, and 2000 is typical). - Decrease the PWM frequency using the
MOT_PWM_FREQparameter (400 is typical).
Caution
Remove the props when configuring the motors! If improperly configured, you may not be able to stop them.
Battery voltage monitoring
ESP32 ADC can measure only up to 3.3 V, so you need to use a voltage divider to monitor the battery voltage. To enable voltage measurement, set the following parameters:
PWR_VOLT_PIN— GPIO pin number where the voltage divider is connected (-1 to disable).PWR_VOLT_SCALE— voltage divider coefficient (2 for two equal resistors).
After this setup, you should see the battery voltage in QGroundControl top panel or using pw command in the console.
Important: check everything works
-
Check the IMU is working: perform
imucommand in the console and check the output:- The
statusfield should beOK. - The
ratefield should be about 1000 (Hz). - The
accelandgyrofields should change as you move the drone. - The
accel biasandaccel scalefields should contain calibration parameters (not zeros and ones). - The
gyro biasfield should contain estimated gyro bias (not zeros). - The
landedfield should be1when the drone is still on the ground and0when you lift it up.
- The
-
Check the attitude estimation: connect to the drone using QGroundControl, rotate the drone in different orientations and check if the attitude estimation shown in QGroundControl is correct. Compare your attitude indicator (in the large vertical mode) to the video:
-
Perform motor tests. Use the following commands — remove the propellers before running the tests!
mfr— rotate front right motor (counter-clockwise).mfl— rotate front left motor (clockwise).mrl— rotate rear left motor (counter-clockwise).mrr— rotate rear right motor (clockwise).
Make sure rotation directions and propeller types match the following diagram:
Warning
Never run the motors when powering the drone from USB, always use the battery for that.
Setup remote control
There are several ways to control the drone's flight: using smartphone (Wi-Fi), using SBUS remote control, or using USB remote control (Wi-Fi).
Control with a smartphone
Using Mavlink Joystick app (Android)
- Download and install Mavlink Joystick app.
- Power the drone using the battery.
- Connect your smartphone to the appeared
flixWi-Fi network (password:flixwifi). - Open Mavlink Joystick app. It should connect and begin showing the drone's telemetry automatically.
- Use the virtual joystick to fly the drone!
Using QGroundControl app
- Install QGroundControl mobile app on your smartphone.
- Power the drone using the battery.
- Connect your smartphone to the appeared
flixWi-Fi network (password:flixwifi). - Open QGroundControl app. It should connect and begin showing the drone's telemetry automatically.
- Go to the settings and enable Virtual Joystick. Auto-Center Throttle setting should be disabled.
- Use the virtual joystick to fly the drone!
Tip
Decrease
CTL_TILT_MAXparameter when flying using the smartphone to make the controls less sensitive.
Control with a remote control
If using SBUS-connected remote control you need to enable SBUS and calibrate it:
- Connect to the drone using QGroundControl.
- In parameters, set the
RC_RX_PINparameter to the GPIO pin number where the SBUS signal is connected, for example: 4. Negative value disables SBUS. - Check if the receiver is working using
rccommand in the console. - Open the console, type
crcommand and follow the instructions to calibrate the remote control. - Use the remote control to fly the drone!
Control with a USB remote control
If your drone doesn't have RC receiver installed, you can use USB remote control and QGroundControl app to fly it.
- Install QGroundControl app on your computer.
- Connect your USB remote control to the computer.
- Power up the drone.
- Connect your computer to the appeared
flixWi-Fi network (password:flixwifi). - Launch QGroundControl app. It should connect and begin showing the drone's telemetry automatically.
- Go the the QGroundControl menu ⇒ Vehicle Setup ⇒ Joystick. Calibrate you USB remote control there.
- Use the USB remote control to fly the drone!
Flight
For both virtual sticks and a physical joystick, the default control scheme is left stick for throttle and yaw and right stick for pitch and roll:
Arming and disarming
To start the motors, you should arm the drone. To do that, move the left stick to the bottom right corner:
After that, the motors will start spinning at low speed, indicating that the drone is armed and ready to fly.
When finished flying, disarm the drone, moving the left stick to the bottom left corner:
Note
If something goes wrong, go to the Troubleshooting article.
Flight modes
Flight mode is changed using mode switch on the remote control (if configured) or using the console commands. The main flight mode is STAB. In order to change modes using SBUS remote control, set the parameters: CTL_FLT_MODE_0, CTL_FLT_MODE_1, and CTL_FLT_MODE_2 to required mode numbers (0 for RAW, 1 for ACRO, 2 for STAB, 3 for AUTO).
STAB
In this mode, the drone stabilizes its attitude (orientation). The left stick controls throttle and yaw rate, the right stick controls pitch and roll angles.
Important
The drone doesn't stabilize its position, so slight drift is possible. The pilot should compensate it manually.
ACRO
In this mode, the pilot controls the angular rates. This control method is difficult to fly and mostly used in FPV racing.
RAW
RAW mode disables all the stabilization, and the pilot inputs are mixed directly to the motors. The IMU sensor is not involved. This mode is intended for testing and demonstration purposes only, and basically the drone cannot fly in this mode.
AUTO
In this mode, the pilot inputs are ignored (except the mode switch). The drone can be controlled using pyflix Python library, or by modifying the firmware to implement the needed behavior.
If the pilot moves the control sticks and mode switch is not configured, the drone will switch back to STAB mode.
Wi-Fi configuration
You can configure the Wi-Fi using parameters and console commands.
The Wi-Fi mode is chosen using WIFI_MODE parameter in QGroundControl or in the console:
0— Wi-Fi is disabled.1— Access Point mode (AP) — the drone creates a Wi-Fi network.2— Client mode (STA) — the drone connects to an existing Wi-Fi network (may cause additional delays, so generally not recommended).3— ESP-NOW mode — the drone uses ESP-NOW protocol for communication.
The SSID and password are configured using the ap and sta console commands:
ap <ssid> <password>
sta <ssid> <password>
Example of configuring the Access Point mode:
ap my-flix-ssid mypassword123
p WIFI_MODE 1
Disabling Wi-Fi:
p WIFI_MODE 0
Using ESP-NOW
ESP-NOW is a low level wireless communication protocol. It can provide lower latency, better reliability, and longer range than Wi-Fi. However, it requires a second ESP32 board to be used as a proxy for the computer.
To setup ESP-NOW communication:
-
Flash the second ESP32 board with ESP-NOW proxy sketch:
tools/espnow-proxy/espnow-proxy.ino. Use Arduino IDE or command line:make upload_proxy. -
Open Serial Monitor or use
make monitorcommand. The ESP32 will print its MAC address and generated encryption key, for example:espnow 7a:c8:e3:eb:bf:e9 &PiuSysxP9+$L&5ERun this line as a console command on each drone you want to bind to this proxy board. The maximum number of simultaneously connected drones is 20 (unencrypted) io 6 (encrypted).
-
Set the
WIFI_MODEparameter to3on the drone:p WIFI_MODE 3 -
Go to the QGroundControl menu ⇒ Application Settings ⇒ Comm Links, add new link with the following settings:
- Name: ESP32.
- Type: Serial.
- Serial Port: choose the port of the proxy ESP32 board, e. g.
/dev/cu.usbserial-0001. - Baud Rate: 115200.
-
Click Save. QGroundControl should connect to the drone using ESP-NOW and begin showing the telemetry.
Flight log
After the flight, you can download the flight log for analysis wirelessly. Use the following command on your computer for that:
make log
See more details about log analysis in the log analysis article.








