While tinkering with electronics Oftentimes I end up with some sort of device that uses UART interface, but that I don’t have any idea what baud rate it uses, etc. Connecting it to a serial monitor application and checking with different baud rate is a time-killing process. So I decided to build an arduino based hardware device which can be used to find the unknown baud rate of uart devices.
The Basic Idea :
All you need is to measure the shortest interval between two flanks(rising →falling or falling → rising)for some amount of traffic.Assuming the communication wiring is good,the shortest duration between two flanks will be the duration of a single bit.The baud rate will then be 1 divided by that duration(in seconds). You probably want to round to/adjust that to be the closest “standard “ baud rate once measured.
Table 1. Standard Baud Rates
- Connect UART device’s GND to GND of Arduino UNO
- Connect TX pin of UART device to RX(0th pin – D0) of Arduino UNO
Launch Arduino IDE Software and select the correct COM Port and upload auto_baud_detector.ino arduino Sketch.
Once the arduino sketch is uploaded, open the arduino serial monitor or any other serial console application with 9600 baud rate.Connect TX pin of unknown UART device to RX pin of Arduino Uno.It will display the nearest standard baud rate.
The following screenshot shows one of the test results.
I have tested and verified the following baud rates.
Note :This baud rate detection algorithm may fail to predict if characters with multiple zero bits in a row are received.But that is a rare condition.The documentation for pulseIn states that it can be used for intervals of 10 microseconds to 3 minutes. This cannot be used to check above 115200 baud rate.
Download Source Code