Building Your Own Drone - Sensors - Part 2

Creating a drone from scratch is both a challenging and rewarding exercise. In this post, I’ll guide you through the essential components you’ll need, with a particular focus on selecting the right hardware and developing your own flight controller softare using STM32 microcontrollers.

Choosing the right components

IMU Sensor

An Inertial Measurement Unit (IMU) is crucial for stabilizing your drone. Here are some of the top options:

  • BNO055: A smart 9-DOF IMU with built-in sensor fusion and Bosch’s BSX algorithm, providing Euler angles and quaternions directly.
  • BMI270: Considered one of the best on the market for flight controllers. Widely used in drones, it provides high-precision data for stabilization. I recommend the BMI270 shuttle board 3.0.
  • BMI160: A classic option that was widely used before the BMI270 became popular.
  • BMI088: Excellent for environments with significant temperature variations. This IMU offers high vibration resistance, making it ideal for drones operating in harsh conditions.
  • MPU9250: Not highly recommended due to its performance, based on several reviews.
  • MPU6050 (GY-521): A basic IMU that includes a gyroscope and accelerometer. It communicates via I2C but lacks support for SPI.
  • MPU6000: Similar to the MPU6050 but supports faster SPI communication, up to 20MHz.
  • STM32F411E-DISCO: A development board from STM32 that includes built-in sensors like gyroscope, accelerometer, and magnetometer.

Note: In UAVs, IMU sensors primarily rely on accelerometers and gyroscopes for stabilization, not magnetometers. Magnetometers are typically used for navigation, such as in a compass for directional guidance.

Barometer

Barometric sensors are used to measure altitude by detecting air pressure changes. Some top options:

  • BME280: A temperature, humidity, and pressure sensor with a sample rate of up to 150Hz and an integrated noise-reduction filter. Suitable for measuring altitude using air pressure.
  • BMP388: A more precise sensor, specifically designed for drone applications, with a sample rate of up to 200Hz.

GPS

GPS (or GNSS) provides the drone’s latitude, longitude, altitude, velocity, and heading. Accuracy and sample rate are crucial when choosing a GPS for your drone.

  • Adafruit Ultimate GPS: 66-channel GPS with 10kHz updates. However, it only connects to the US GPS network.
  • Beitian BN220: A dual GPS module that connects to multiple networks (including GLONASS) with a 10Hz sampling rate and 2m horizontal accuracy.
  • GPS NEO-6M: A basic GPS with a 5Hz sample rate and 5m horizontal accuracy, only connecting to the US GPS network.

Connecting MPU6050 IMU to STM32 board

For testing purposes, I chose the MPU6050 IMU sensor for my drone because I had it readily available, though I only recommend it for prototyping. The MPU6050 uses I2C communication with a speed of up to 400kHz, which is slow compared to other more advanced sensors.

Here’s how you can connect the MPU6050 to an STM32 board:

  • VCC: Connect to a 3.3V and 5V sources (the breakout board has a voltage regulator).
  • GND: Ground connection.
  • SCL: Serial Clock Line for I2C protocol.
  • SDA: Serial Data Line for I2C protocol.
  • XDA: Auxiliary data line for I2C, used as the master serial data to connect external sensors.
  • XCL: Auxiliary clock line for I2C, acting as the master serial clock for connecting external sensors.
  • AD0: Used to set the I2C address (LOW = 0x68, HIGH = 0x69).
  • INT: Digital interrupt output.

Fig 1
Figure 1: Connection of MPU6050 to STM32F407G Discovery Board.

References

[1] IMU Link

[2] MicWro Engr. YouTube. All sensors needed for a drone. Link

[3] Adafruit. Article. Smart 9DOF IMU BNO055 Link

[4] STM32 IMU drone course. Link

[5] STM32 IMU drone course YouTube. Link

[6] UAV Tech. Youtube. Link

[7] Brainfpv. Drone Electronics. Good and well known shop. Link

[8] Filters used to combine gyroscope and accelerometer. Link

[9] The Hypsometric Equation. Link

[10] Satellite World Map. Link

[11] Extended Kalman Filter. Link

Written on February 26, 2024