Quadcopter from scratch · Part 2

Choosing a brain and a sensor for the drone

Before I worry about motors or a frame I need two things. A chip to run the code, and a sensor so the code knows which way the drone is pointing.

These are what I picked.

  • ESP32-S3 dev boardDual core, 240 MHz, with a floating point unit
    $4.10
  • MPU-9250 IMUNine axis motion sensor, connected over SPI
    $3.05
Total$7.15

About seven bucks total.

The ESP32-S3

Two cores, up to 240 MHz. A flight controller doesn't need much more than that. The main loop reads the sensor, figures out how tilted the drone is, and adjusts the motors, thousands of times a second. It just can't fall behind.

The thing I actually cared about was the floating point unit. Keeping a drone level is basically all decimal math, angles and rates and tiny corrections. Chips without an FPU have to fake decimals in software and it's slow. This one does it in hardware, so I can write the math with normal decimal numbers and not worry about it.

Having two cores is nice too. I'm planning to have one core only fly and the other handle stuff like sending data to my laptop over wifi so I can see what the drone thinks is going on.

Also it's four dollars. I'm going to fry at least one.

The MPU-9250

This is the IMU (inertial measurement unit). It's three sensors in one chip.

The gyroscope measures how fast it's rotating. The accelerometer measures acceleration, and since gravity is always pulling down, it can tell you which way down is. The magnetometer is a compass. Each of those measures in three directions, so nine axes.

The gyro and accelerometer are what keep it level. You need both, and I'll get into why in a later post. You don't need the compass to fly but it would let the drone know which way it's facing, which I might want later.

I'm hooking it up over SPI and not I2C. Both are ways for chips to talk to each other but SPI is way faster on this sensor. I2C maxes out at 400 kHz and SPI can read the data at 20 MHz. If I'm reading it thousands of times a second I want the fast one.

Why these two

The ESP32 is fast and good at decimal math and the MPU-9250 can tell it which way is up quickly. Every flight controller is some version of that combo.

Updates

Email updates are coming. Until then, follow along on X or RSS.