Electronics · Arduino
Arduino baud rate calculator.
Enter the clock and the baud rate you want. You get the UBRR register value, the baud rate you really get, and whether the error is within the datasheet's recommendation.
Inputs
Result
Enter the clock and baud rate.
How the AVR baud rate register is calculated
UBRR = fosc ÷ (16 × baud) − 1 in normal mode, and fosc ÷ (8 × baud) − 1 in double speed mode, rounded to the nearest whole number. The actual baud rate is then fosc ÷ (16 × (UBRR + 1)). These are the equations in section 19 of the ATmega328P datasheet.
Worked example. 16 MHz at 9600 baud: 16,000,000 ÷ (16 × 9600) − 1 = 103.17, so UBRR = 103. The real rate is 9615.38 baud, an error of 0.16% (the datasheet table shows 0.2%). At 115200 baud the same clock gives UBRR = 8 and an error of -3.5%; double speed gives UBRR = 16 and 2.1%. At 250000 baud the error is 0%.
How much error is acceptable? The datasheet's recommended maximum receiver error for 8 data bits is ±2.0% in normal speed mode and ±1.5% in double speed mode. It states these assume the sender and receiver share the total error equally, so a partner with an exact baud rate leaves you more room. This tool flags results over those limits.
The calculation is for the ATmega328P USART (Uno, Nano, Pro Mini) with an asynchronous setup. Other chips, other Arduino cores and 8-bit-versus-16-bit register details differ, so check your chip's datasheet.
Frequently asked questions
What is UBRR for 9600 baud at 16 MHz?
103. The actual baud rate is 9615.38 with an error of 0.16% (0.2% in the datasheet table).
Why does 115200 baud show an error warning at 16 MHz?
The datasheet table lists −3.5% in normal mode and 2.1% in double speed mode at 16 MHz, both over the recommended limit. It can still work if the other device is very accurate, since the error is shared between both ends, but 250 kbps, 0.5 Mbps and 1 Mbps list 0.0% at 16 MHz.
What does U2X0 do?
Setting it halves the divisor from 16 to 8, which doubles the speed for a given UBRR and gives finer steps, at the cost of a smaller receiver error tolerance (the datasheet says normal mode tolerates more variation).
What is the maximum UBRR value?
UBRR is a 12-bit register, so 4095. A baud rate that needs more than that is too slow for the clock.
Why not just use the Arduino Serial library?
You usually should: Serial.begin(9600) sets this for you. This tool is for checking the error, bare-metal AVR code or choosing a crystal.
Sources
Checked
Runs entirely in your browser. Nothing you type is sent or stored.
Scope and safety
Low-voltage hobby use only. These results are arithmetic from the formulas shown, not an engineering design or professional advice. Real parts vary with tolerance, temperature and age, so check the datasheet for every part. Never work on mains-powered circuits from a calculator result, and treat lithium and other rechargeable batteries with care.