อินเทอร์เฟซอนุกรม UART I2C SPI CAN และ DroneCAN

Communication protocols between on-board devices

Last updated:

Why it matters

A flight controller exchanges data with dozens of devices all the time. The IMU delivers thousands of samples per second, the compass and barometer report periodically, the GNSS receiver sends position, the telemetry radio talks to the ground station, and on larger aircraft the ESCs and power module report their state. Most of these links are serial: bits are sent one after another over a few wires, which suits small boards and airframe wiring.

Each interface trades off speed, wire count, devices per bus, cable length and noise immunity differently. This page compares the five you will meet on a drone and points out what usually stops them working.

InterfaceWires (excluding ground)CharacterTypical drone use
UARTTX, RXPoint to point, no clock lineGNSS, telemetry radio, companion computer
I2CSDA, SCLAddressed bus, short cablesExternal compass, barometer, LEDs
SPISCK, MOSI, MISO, plus one CS per deviceVery fast, very shortIMUs, on-board barometer
CANCANH, CANLDifferential bus, noise-tolerantGNSS, ESCs, power modules on large airframes
DroneCANUses the CAN pairProtocol on CAN for uncrewed aircraftDevices supported by ArduPilot and PX4

UART

A UART (universal asynchronous receiver-transmitter) uses one wire per direction and no clock line, so both ends must agree on the baud rate (bits per second on the wire). Following Microchip's TB3216, an 8N1 frame has one start bit, eight data bits, no parity and one stop bit: 10 bits per byte, so the real data rate is baud/10 bytes per second.

Remember that one side's TX goes to the other side's RX, that logic levels must match (most flight-controller ports are 3.3 V), and that TTL UART is not RS-232, which uses much higher voltages. Busy ports may use RTS and CTS hardware flow control so the receiver's buffer does not overflow.

I2C

According to NXP's I2C specification (UM10204 rev 7.0), I2C uses two wires, SDA (data) and SCL (clock). Device pins are open-drain: they can only pull the line low, so each line needs a pull-up resistor to VDD. Each device has a 7-bit address. Standard speeds are 100 kbit/s (Standard-mode), 400 kbit/s (Fast-mode) and 1 Mbit/s (Fast-mode Plus).

The pull-up value has both an upper and a lower limit. The specification allows a maximum rise time tr of 1,000 ns in Standard-mode and 300 ns in Fast-mode, and a total bus capacitance Cb (wire, pins and connectors) of at most 400 pF. Too large a resistor makes edges too slow; too small a resistor stops devices pulling the line low enough. UM10204 gives:

  • Rp(max) = tr / (0.8473 × Cb)
  • Rp(min) = (VDD − VOL(max)) / IOL, with VOL(max) = 0.4 V at IOL = 3 mA for Standard-mode and Fast-mode

Example 1: sizing pull-ups for an external compass bus

A 3.3 V bus runs in Fast-mode (tr = 300 ns). Rp(min) = (3.3 − 0.4) / 0.003 ≈ 967 Ω. Rp(max) depends on the cable capacitance (capacitances assumed):

Bus capacitance CbRp(max)Outcome
100 pF (short lead)3.54 kΩ2.2 kΩ works
200 pF (long lead up the GNSS mast)1.77 kΩNarrow window, about 1–1.5 kΩ
400 pF885 ΩBelow Rp(min): Fast-mode is impossible; slow down, shorten the cable or add a bus buffer

Another trap: breakout modules usually carry their own pull-ups. Three modules with 2.2 kΩ each in parallel give about 733 Ω, below Rp(min), so remove the extra pull-ups.

SPI

SPI (serial peripheral interface) uses a clock line SCK, two data lines MOSI and MISO, and a separate chip-select CS for each device. There is no address in the data stream and no acknowledge, so it is far faster than I2C. As Analog Devices explains, SPI has four modes set by the idle clock polarity (CPOL) and the clock edge used to sample data (CPHA); both ends must use the same mode. Flight controllers put their IMUs on SPI because they are read so often.

A rough comparison: reading 12 bytes of IMU data plus one command byte over SPI at an assumed 10 MHz takes 104 bits, about 10 µs. Reading the same number of bytes over I2C at 400 kHz takes about 0.34 ms, more than 30 times longer.

CAN and DroneCAN

CAN (controller area network) uses a wire pair, CANH and CANL, with differential signalling: the value is read from the voltage difference between the two wires, so noise induced equally on both cancels. That allows long runs across the airframe. All devices share the one pair, and the bus must be terminated at both ends. The data link layer is defined in ISO 11898-1 (2024 edition). If two devices transmit at once, the frame with the lower identifier wins arbitration without data loss. ArduPilot's documentation notes that 1 Mbit/s is the usual bitrate and that most autopilots have one or two CAN ports.

DroneCAN is a higher-level protocol that runs on CAN. According to the project site, DroneCAN v1 is identical to the older UAVCAN protocol, and it is the primary CAN protocol of ArduPilot and PX4. It includes the DSDL message description language and dynamic node allocation of node IDs. On a drone it means one pair of wires to many devices, devices that report their own health, and long cables that tolerate noise far better than I2C. In ArduPilot, DroneCAN is selected by setting CAN_D1_PROTOCOL to 1.

Example 2: CAN bus load

A classic CAN frame with a 29-bit identifier and 8 data bytes is about 131 bits including inter-frame space, before stuffing bits. Suppose the GNSS, compass, four ESCs and power module together send 600 frames per second (assumed).

  • Bits = 600 × 131 = 78,600 bits per second
  • At 1 Mbit/s the bus load is about 7.9%; allowing 20% for bit stuffing, about 9.4%

There is plenty of headroom, unlike a 57,600-baud UART telemetry link that carries only 5,760 bytes per second.

Common pitfalls

  • TX wired to TX, or a 5 V device on a 3.3 V port with no level shifter.
  • Mismatched baud rates, then concluding the device is dead.
  • Missing pull-ups, or several sets in parallel on an I2C bus.
  • Long I2C cables running across the airframe near high-current wiring.
  • Duplicate I2C addresses, such as two identical compasses on one bus.
  • Wrong SPI mode, or a floating CS line.
  • Unterminated CAN, or more than two terminations, and duplicate DroneCAN node IDs.

Continue in the lessons

Key references

  1. Microchip Technology. (2018). Getting started with USART (TB3216). link
  2. NXP Semiconductors. (2021). I2C-bus specification and user manual (UM10204, Rev. 7.0). link
  3. Dhaker, P. (2018). Introduction to SPI interface. Analog Dialogue, 52(3). link
  4. International Organization for Standardization. (2024). Road vehicles — Controller area network (CAN) — Part 1: Data link layer and physical coding sublayer (ISO 11898-1:2024). link
  5. DroneCAN Development Team. DroneCAN: A lightweight protocol for UAV CAN networks. link
  6. ArduPilot Dev Team. CAN bus setup. ArduPilot Copter documentation. link

Used in courses

How to cite this page

Drone Institute, Rangsit University. (2026). อินเทอร์เฟซอนุกรม UART I2C SPI CAN และ DroneCAN. In UAS Technology Knowledge Hub (B.Tech.). https://rsu-uat.pk-research.work/en/kb/new/mcu-interfaces/