Skip to content

Data Magician

Sensor data is the foundation of drone control. In this project, you will learn how to read the drone’s sensor data and perform simple analysis.

  • Sensor data reading
  • I2C communication protocol
  • Data logging functionality
  • Data analysis methods
Item Quantity Notes
Fully Assembled Drone 1 -
Computer 1 With VS Code + ESP-IDF environment
USB Cable 1 For programming
Smartphone 1 With Drone Control APP installed
Sensor Function
MPU6050 6-axis sensor, measures acceleration and angular velocity
BMP280 Pressure sensor, measures pressure and altitude

Open the following files to understand data reading logic:

  • components/drivers/i2c_devices/mpu6050/mpu6050.c
  • components/core/crazyflie/modules/src/estimator_complementary.c

Open components/core/crazyflie/modules/src/log.c and add new log variables (e.g., acc_x, gyro_y, height).

Register these variables in the logInit() function.

  1. Compile and flash the code
  2. Power on, connect to smartphone APP
  3. Enter the “Log” page, select the data variables to view
  4. Click “Start Log”
  5. Move the drone and observe changes in sensor data
  1. Export log data to computer
  2. Use Excel or Python for analysis
  3. Plot curves of acceleration, angular velocity, and altitude over time
  4. Analyze the drone’s motion state
  • Check I2C connections
  • Confirm sensor address is correct
  • Check Wi-Fi connection
  • Confirm log variables are registered

Congratulations! You have mastered the methods of reading and analyzing sensor data, which is an important skill for drone development!

In the next project, you will learn how to use ultrasonic sensors for obstacle avoidance.

First published atdrone.imagrove.com/intermediate/data-analysis/Please credit Imagrove and link back to this page when quoting or republishing.

Questions or issues with this tutorial?

Sign in with GitHub to leave a comment. If a step fails for you, tell us — we verify it and update the tutorial.

ImagroveMore ESP32 tutorials · ESP32 IoT Tutorial

© 2026 ESP32 Drone. All rights reserved.