Microcontrollers for drones: from a first circuit to steady flight

Learn the drone's embedded brain from Arduino and ESP32 to STM32, sensors, control and firmware through basic, applied and advanced lessons

Last updated:

A drone with its propellers removed, a flight control board and a microcontroller board on a desk for learning embedded systems
Concept image generated with AI; it is not a screenshot or a device model confirmed to be supported

Start reading signals with the ADC and PWM guide with exercises and a planning sheet, before extending to communication channels

Continue with the Complementary Filter chapter with a worked example to separate prediction from the fused angle

Continue with the chapter on angles crossing ±180° with an example to read angle differences that cross the range boundary

Continue with the chapter on continuous angle and rotation rate from a log to practise accumulating angle and checking the real time interval

Continue with the chapter on smoothing angles versus delay to practise the three-point average and to separate out the time at which the result is ready to use

Continue with the chapter on accumulating angle from a gyro using real time to practise unequal dt and the effect of an accumulated offset

Choose what to read or practise according to your goal

You can use only the parts that match your question. Practice sets, quizzes and real board results have different boundaries of evidence.

After choosing a set, see how to open the files and fill in the worksheets before editing the downloaded files

If you are stuck on terms, open the glossary, units and timing of the practice sets before reading a log or an answer

If you will choose sensor connections or a log, open the I2C, SPI and UART guide before planning how to connect devices

Why a drone looks still while its embedded brain works all the time

Wind, vibration and changing thrust push the drone's attitude away from the desired value, so the system must read sensors, estimate the state, compare it with the target and adjust commands continuously. This is a feedback loop, or closed-loop control. Stability depends on the data, the control and the processing time together. See how a real system divides its functions in PX4 v1.16 architecture

This lesson set uses ideas from the video 'Behind the embedded brain that keeps a drone steady' , provided by the user as an outline, then reorganised into a hands-on learning sequence, with terms and details checked against the official documents linked in each lesson.

Diagram: sensor → state estimation → control → actuator, with the change measured and fed back

Concept diagram: the system continuously measures the effect of its commands; each stage has data and timing limitations

Know the parts before choosing a board

Term What it does Learning example
MCU (microcontroller) Combines a processor, memory and signal input/output circuits on one chip Reading buttons, keeping time, reading sensors
Development board Brings out the MCU's USB power and signal pins so it is easy to experiment with Arduino UNO R3 or a chosen ESP32 board
Flight controller A flight control board combining an MCU, sensors and connection ports for a drone system Reading the IMU and sending commands through ESCs
Firmware Software that manages devices and the control logic PX4 or ArduPilot on a supported board
Companion computer An additional computer for tasks separate from the flight control loop Image processing or mission planning

Arduino refers both to a development tool and a family of boards, while ESP32 and STM32 have many variants, so the chip, board and SDK must be chosen to match. Start reading about connections and basic programming from Arduino Learn

Choose a level based on what you want to do

Basic level: Arduino/ESP32

Objective: understand I/O and timing in a program. Hands-on: read a button, blink an LED and send serial data without halting the whole program. Outcome: explain GPIO, ADC and PWM, and run two tasks together.

Applied level: sensors and communication

Objective: turn readings into trustworthy data. Hands-on: read an IMU, check axes and units, record timestamps, then experiment with dropped messages. Outcome: distinguish errors arising from sensors, timing and communication.

Continue practising with the guided IMU/message worksheet with 8 questions to read axes, units, data age and message order, with answers reasoned from the existing PC data

Advanced level: STM32 and drone firmware

Objective: understand the constraints of real control systems. Hands-on: analyse timing, PID, failsafe and logs using a SITL test plan. Outcome: explain the causes of abnormal behaviour from evidence.

If you have never programmed, start with the basic lesson and finish the LED exercise before buying more equipment. If you can already read sensors, start with the applied lesson. Those with flight controller experience should read the advanced lesson, checking back on terms and units when necessary.

Practice paths you can choose from

Starting point Work practised Before moving on to the next chapter
Arduino/ESP32 basics LED, button, Serial and debounce Can explain I/O and timing, and read compile results separately from board results
Applied: sensors and communication Axes, units, timestamps and dropped messages Can identify units and evidence of errors
Advanced, in seven separate chapters Timing → Interrupt → Queue → Freshness → Log diagnosis → Log provenance → PID/SITL Checks the answers and states the boundary of results that are not yet confirmed

You can study just one topic for reference. This sequence is the recommended path for those who want to continue practising in order.

Learning steps that connect into a system

  1. Draw the data path: sensors → state estimation → controller → actuators → sensors, stating what each point measures or commands
  2. Choose one small task: for example, read a button and blink an LED, and write down what you expect to happen before running it
  3. Collect evidence: record the board model, SDK, wiring, units, sampling rate and results
  4. Change one factor at a time: use logs to explain the results before adding sensors or communication
  5. Move to the next level once you can explain: separate 'the program runs' from 'the data is correct' and 'the control behaviour is appropriate'

Use the Sim for the right purpose

Open DroneSim to practise designing and assembling drones, planning missions, or field practice with Replay. It can help you visualise the system and the mission. At present DroneSim does not execute Arduino/ESP32/STM32 code and does not simulate the boards' electronic circuits.

When you want to study the behaviour of flight control firmware , continue with the SITL lesson in the knowledge base , which explains running control software with a model on a computer. Passing exercises on a computer still requires checking equipment and the environment before real use.

PC-ready practice sets: UNO R3 input/debounce has code that compiles and passes host tests; IMU/communication uses synthetic data; timing/PID and the ArduCopter SITL failsafe separate the teaching equations from real firmware results, with logs and answers. Boards, sensors, radios and real flight still need to be checked against the chosen equipment.

Advice before you start

Start with USB, LEDs and sensors on the bench. Use the board's pinout guide and check the voltage levels of connected devices. This exercise set does not require fitting propellers or commanding motors. Choose tools that can log and repeat, so errors can be analysed before adding complexity.

Check your understanding: Try explaining how an MCU, a flight controller and firmware differ, then choose one variable that should be recorded when a drone vibrates, such as angular rate, the commanded value or the interval between sampling times, and give your reason.

Self-check your understanding

Open the three-level quiz with explanations 4 questions per level; the pre-reading and post-review rounds are recorded only in the browser, use the same questions, and are not an assessment of real learners or a certificate

Activities linking MCU knowledge with simulation

Choose a DroneSim activity, read a log, or study SITL firmware results with objectives, steps, worksheets, and event summaries drawn from the stored ArduCopter 4.7.1 results, separating what each tool can confirm

Prepare to collect evidence from a real board

UNO/ESP32/STM32 experiment-preparation guide with worksheets check the model, wiring, source/core clock and raw files before concluding. The guide is ready to use, but the actual upload/measurement still awaits equipment

Separate Verify, upload port, Serial and Log file problems with a blank problem-record form. Code checking can start on the computer, while the parts that use a board still await real equipment

Practise the basics before connecting sensors

Guided practice set on buttons and debounce, 8 questions tracing the states of 15 calls and four 'due' examples from the original source, with worksheets, answers and a report that separates computed values from real board results

Choose practice sets that match your goal

Choose from the 20 MCU practice sets, with tasks, worksheets, planning forms and answers separated into basic, applied and advanced, with prerequisites and review methods. You can pick one problem of interest without doing every set in order.

Terms, units and times used in the practice sets

Objective: open to compare meanings before reading a task or a Log Foundation: read the column names and know the source set Suggested time: 5–10 minutes per answer, not yet measured with learners. You can use this guide as a reference point without reading every chapter in order.

  1. Pick a term you are unsure about from the groups below, then open the linked chapter
  2. Check the unit, the timestamp point, the clock/session and the rules of that set before substituting into a formula
  3. Note down the explanation of one column, then use the guide to checking conclusions from evidence to separate what still needs to be collected

Diagram for reading the meaning of fields and units, timestamp points and clocks, then checking formulas, boundaries and policies before concluding from a Log

The existing realistic-looking image on the overview page is used for context. This diagram is a guide to reading data; it contains no new trace or measurement results.

Basics · signals and units

  • GPIO — a pin that receives/sends a digital state such as HIGH/LOW, used to read a button or drive an LED Unit/context: logic state; check the voltage for the board model Caution: a GPIO number is not the pin position on every kind of board GPIO · basics chapter

  • ADC — converts an analogue signal into a digital value; the raw value needs its resolution and unit conversion checked Unit/context: raw count or mV depending on the API Caution: a raw value from analogRead is not a calibrated voltage ADC · basics chapter

  • PWM / duty cycle — PWM switches a signal periodically; the duty cycle is the fraction of the period during which the signal is in the active state Unit/context: period/frequency and duty fraction; check the value range according to the API Caution: an LED dimming example does not confirm that it can be used to command an ESC PWM · basics chapter

  • ms / µs / s — 1 ms = 1,000 µs and 1 s = 1,000 ms; convert to the same unit before calculating Unit/context: duration; for example 10,000 µs = 10 ms Caution: the same number in different units is not the same time Time units · Polling Timing

Applied · data and time

  • timestamp / clock / session — a timestamp states the time at one point; you must know the event that was stamped, the clock source and the cycle of operation Unit/context: ms or µs according to the data contract Caution: host time and MCU time cannot be subtracted directly when the relationship between the clocks is not yet known clock and session · Log provenance

  • angular rate / angle — a gyro gives the rate of rotation, while the angle must be estimated from the data and the time interval; check the axis and the positive direction Unit/context: deg/s or rad/s for rates; deg or rad for angles Caution: do not read a rotation-per-second value directly as an angle Rotation rate · IMU chapter

  • age / fresh / stale — age is the time from a given timestamp to the point of checking; fresh/stale is the result of comparing against the cutoff for the task Unit/context: messages use ms; the Freshness Gate uses µs according to the guide Caution: fresh at the time of checking does not confirm fresh at the later time of use; callback age is not always sensor age Data age · Freshness Gate

  • sequence / accepted-stream gap — sequence is a sequence number; a gap in this message set counts the numbers missing between messages accepted under the protocol Unit/context: count of sequence numbers; the teaching message set uses 16 bits and a single session Caution: a gap is not the number of radio packets lost; check wraparound and the acceptance policy Message sequence · Communication chapter

Advanced · tasks and evidence

  • ISR / snapshot / handoff — an ISR handles an interrupt; a snapshot reads shared data consistently; a handoff passes data to main for further use Unit/context: ticks/time and state according to the Timer Interrupt set Caution: volatile alone does not guarantee a multi-field snapshot; the source is not a concurrency measurement on a board ISR and handoff · Timer Interrupt

  • late_us / work_us — polling: late is lateness from the latest cycle; work measures the scheduler/LED interval before the CSV is arranged and serial is sent Unit/context: µs; uses the measurement-point boundaries of this polling set Caution: a small late value can still miss an older cycle; work does not cover the whole loop and the ISR set is not compared directly as a benchmark Timing boundaries · Polling Timing

  • skipped / dropped — polling: skipped is an old period not done at that time; dropped is the cumulative count of Log rows that could not be sent since boot Unit/context: number of periods per row / cumulative number of rows, respectively Caution: a Log that could not be sent does not mean the work was not done; use the delta counter within a round that can be confirmed skipped/dropped · Polling Timing

  • observed / declared / unknown — separates what can be read from the file, what the manifest declares, and what the file does not yet confirm Unit/context: type/boundary of evidence, not a numeric unit Caution: a matching hash confirms that the bytes match, but does not confirm a complete capture or real board results Evidence boundary · Log provenance

Advice: the same field name may measure different intervals in each set, especially work_us and age_us ; treat the protocol and the measurement point as the primary reference. The example values and cutoffs for practice are not yet requirements for a real drone.

Download 12-term MCU glossary CSV, one-column meaning note form and the glossary guide . Check the provenance and hashes of the source chapters against the per-set manifests

Set-specific definitions cite the linked chapters, while the basic APIs are checked against the official Espressif documentation: GPIO, ADC and LEDC/PWM . Do not assume the same pinout, resolution or voltage limits for every board.

Check conclusions from the practice sets

Practise writing conclusions that match the evidence with basic, applied and advanced examples, plus a six-item checklist and a blank report form, to identify the row, unit, clock, boundary and evidence still to be collected

Used in courses

How to cite this page

Drone Institute, Rangsit University. (2026). Microcontrollers for drones: from a first circuit to steady flight. In UAS Technology Knowledge Hub (B.Tech.). https://rsu-uat.pk-research.work/en/kb/knowledge/microcontrollers/

Original from Drone-Hub: https://drone.pk-research.work/knowledge/microcontrollers/ · © PK-Research