UART baud rate calculator

A UART makes its baud rate by dividing a clock, so many speeds come out slightly off. Pick your board and a speed to see the divider registers, the real rate, the error and whether it will work.

Results are arithmetic on published formulas, not measurements. Check them on your hardware. Free, no sign-up

Why the baud rate error matters

UART has no clock wire. The receiver only knows when the start bit began; then it samples each following bit at the moment it expects it, timed by its own clock. If the two sides run at slightly different speeds, the sampling point drifts a little further on every bit of the character.

Over a 10-bit character (start bit, 8 data bits, stop bit: “8N1”) the last bit must still be sampled inside its own bit time. In theory that allows about 5 % of mismatch between the two sides together; real receivers need part of that for their own sampling. That is why this calculator calls up to 1 % fine, up to 2 % usually fine if the other side is accurate, and more than 2 % risky.

Why some speeds are exact and others are not

The divider can only take certain values, so the real rate is the clock divided by the nearest one. An Arduino Uno at 16 MHz makes 250000, 500000 and 1000000 baud exactly, but 115200 comes out as 117647 (+2.1 %). An ESP32 divides its 80 MHz clock with a fractional divider and lands very close to every common speed. The nRF52 only offers a fixed list of rates, each with its own small error.

The formula

AVR (ATmega328P, ATmega2560):  UBRR = fclk / (16 × baud) − 1     double speed (U2X = 1): fclk / (8 × baud) − 1
STM32:            USARTDIV = fck / (16 × baud), BRR = 12-bit mantissa + 4-bit fraction
ESP32, S3, C3:    baud = APB_CLK / (CLKDIV + FRAG / 16)
RP2040, RP2350:   baud = 4 × clk_peri / (64 × IBRD + FBRD)
nRF52840:         fixed BAUDRATE values, each with its real rate in the register table
error = (real rate − wanted rate) / wanted rate × 100 %

Source: ATmega328P datasheet, USART0 “Baud Rate Generation” and “Examples of UBRRn Settings”; RM0368 / RM0383 “Fractional baud rate generation”; ESP32 Technical Reference Manual, UART Controller; RP2040 Datasheet 4.2.7.1 “Baud Rate Calculation” and Pico SDK uart_set_baudrate(); nRF52840 Product Specification, UARTE BAUDRATE register.

Worked example

Arduino Uno, 16 MHz, 115200 baud. Normal speed: UBRR = 16 000 000 / (16 × 115200) − 1 = 7.68, rounded to 8, so the real rate is 16 000 000 / (16 × 9) = 111111 baud (−3.5 %). Double speed (U2X0 = 1): UBRR = 16, real rate 16 000 000 / (8 × 17) = 117647 baud, +2.12 %: the better of the two, but still risky.

At 9600 baud the same chip gets UBRR = 103 and 9615 baud, only 0.16 % off. An ESP32 at 115200 baud gets CLKDIV 694 and FRAG 7, practically exact.

Questions and answers

What baud rate error is acceptable?

As a rule of thumb, keep each side within about 2 % and the total mismatch between both sides well under 5 %; within 1 % is always fine. The receiver resynchronises on every start bit, so the error only has to hold across one character, not the whole message.

Why does 115200 baud give errors on an Arduino Uno?

At 16 MHz the nearest divider gives 117647 baud, 2.1 % fast. It often still works over the Uno’s own USB connection, because the USB-to-serial chip on the board (an ATmega16U2) also runs at 16 MHz and makes the same error. Talking to another device at an exact 115200 is where it fails. 38400 (0.2 % off) or 250000 (exact) are safer choices.

Which baud rates are exact at 16 MHz?

250000, 500000 and 1000000 baud are exact at 16 MHz, and 9600, 19200 and 38400 are within 0.2 %. 115200 and 230400 are more than 2 % off on a 16 MHz AVR.

Do both devices need the same settings?

Yes: the same baud rate and the same frame format, usually 8N1 (8 data bits, no parity, 1 stop bit). TX of one side goes to RX of the other, and the grounds must be connected. The voltage levels must match too: a 5 V TX into a 3.3 V RX needs a divider or a level shifter.

How many bytes per second does a baud rate give?

With 8N1 each byte takes 10 bits (start bit, 8 data bits, stop bit), so divide the baud rate by 10: 115200 baud carries at most 11520 bytes per second, 9600 baud carries 960.

Learn the background

Free lessons of the BoardPilot course that explain the ideas behind this calculator:

Other calculators

See it on a real board

BoardPilot uses these same calculations inside the app, next to a live 3D view of your board, its pins and wires, with guided debugging when something does not work. Try it in your browser, or download it for macOS and Windows.