This isn't strictly limited to Arduino but I spend a lot of time with serial devices on my Arduino and I'm sure that others do as well:

Here goes..

Let's say a device sends three characters [ABC] via serial at 9600 8N1.

And let's also say the device receiving the data only knows that it's serial stream and 8N1 but does not know the baud.

The receiving device would need to take a guess at the baud and so probably get it wrong. It would therefore receive weird characters.

Is there anyway/anything around that a user could paste the strange characters into that would reverse engineer (from the bit stream) to give the correct baud and hence correct ascii characters [ABC]?


4 Answers 4


I am not aware of anything like that, no. The problem is what you are seeing as characters are a complete corruption of the data. Only some part of it may have been interpreted as a valid bit sequence, and even then you can't know what bit it was.

However, there is one magic character in UART communication: U

What is special about that character is its binary pattern. It is ASCII character 85, which in HEX is 0x55, or binary it's 0b01010101. Add to that the start and stop bits, and invert it for the UART logic (1 = LOW, 0 = HIGH) and the signal that gets sent out of the UART looks like:

____start_____     _____     _____     _____     _____
    |   |  0  | 1 |  0  | 1 |  0  | 1 |  0  | 1 | stop
    -----     -----     -----     -----     -----

And yes, that's a pretty good square wave. The frequency of that square wave will be exactly half the baud rate - so a frequency of 4800Hz will be a baud rate of 9600 baud.

This effect is cleverly used for a system called Automatic baud rate detection whereby a receiver waits for a U character to determine the baud rate to use. Most modern microcontrollers have this facility available.

If you can't get the frequency of a block of U characters you will have to examine the waveform with an oscilloscope. It should be possible to identify the individual characters in the data stream as distinct blocks in the waveform. From that you can then work out the width of one symbol and thus the baud rate. It's best to use a DSO for this since you can then capture a short burst and use the markers to measure the time between different points in the waveform. A logic analyser will also do the job quite well, and will most likely be able to decode the waveform and calculate the baud rate for you.

If you have neither of those it would be possible to program an Arduino to capture the time between transitions of an incoming signal and allow you to plot them in Excel to give you a waveform you can examine to determine the baud.

Another option is just to keep trying different baud rates (there's relatively few "standard" baud rates) until you see the right text coming in.


My logic analyser has a "guess baud rate" feature, which usually is fairly accurate. If you analyse an incoming bit stream you can probably have a reasonably good guess. For example the shortest transition means the baud rate cannot be slower than that. For example, at 9600 baud sooner or later you will get a transition in 104 µs (ie. 1/9600). Thus if you see that, the baud rate could not be 4800 baud.

Also, in general, there will be a gap between "packets", so in your case after the "ABC" there would be a longer gap (of all 1s). You would assume then that the active time represents an integral number of bytes (eg. 3 bytes, 8 bytes, but not 1.5 bytes).

Another thing is that baud rates are usually multiples of a power of 2 times 300 (ie. 300, 600, 1200, 2400, 4800). So this gives you a small range of possible baud rates to test. You could test (say for 9600) and see if you get reasonable results. A "reasonable result" would be a stop bit appearing 10 bits after a start bit.

See my post: How does serial communications work on the Arduino?


Try measuring pulse width and match shortest pulse against pre-defined widths corresponding to available baudrates. This way you can detect baudrate by analysing random binary stream.

Signal glitches, such as very short spikes, will be filtered out, as they will never match the list of baudrates.

Repeat the measurement few times to raise accuracy and choose the most probable value from all guessed values.


In the days of dumb terminals and time sharing systems, setting the baud rate was accomplished by the terminal sending a pre-determined series of characters with gaps between them and the host changing its baud rate and looking for the expected data. It is best to start at a high baud rate and drop the rate between tries.

For example the terminal user would hit Enter repeadedly and the host would try decreasing baud rates until it saw the Carriage Return character. When it saw the CR, it would respond with "Login Please" and you would know you were good to go.

  • In those days,you didn't have many baud rates to choose from: 300 or 1200.
    – user31481
    Commented Feb 3, 2018 at 7:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.