Why do people use AT commands in serial communication?

One seldom-appreciated detail about "AT" commands is that many modems would start out in "auto-baud/auto-parity" mode. Initially, the modem would start out not trying to actually decode any serial data, but would simply watch for a consecutive low pulse and high pulse whose widths matched the same valid bit period (e.g. 3.333ms for 300 baud, 833us for 1200 baud, etc.). Upon finding that, they would see if the next low pulse was five times that width. If so, they would watch for either another high-low-high or else for at least 1.5 bit times of high. Finding either of those would indicate that the modem had just seen a 0x41 or 0xC1 (i.e. "A") of the identified baud rate. It would further indicate either the attached computer was using either 8-N-1 or 7-E-1, or that it was using either 7-N-1 or 7-O-1. In either case, it would look for the next character to be either 0x54 or 0xD4 (i.e. "T"). That would allow the modem to further categorize the character length and parity settings.

Note that everything received before the "AT" would be ignored. If echo was turned on, the data would be echoed back to the attached computer simply by mirroring all line transitions without any serial decoding. If a computer sent data prior to the "AT" at e.g. 247 baud, it would be echoed back at that speed.

Nowadays, a few devices use an initial "A" for auto-baud-rate detection, but otherwise the fact that commands start with "AT" is basically a historical curiosity.


It refers to the Hayes command set which has been the standard for a long time for issuing commands to modems (and other equipment) over a serial line.

Instead of the commands and data having two separate lines, only one line is used and to switch into command mode from data a certain sequence is sent, e.g. +++ followed by a set length pause. Then the next data is seen as a command by the receiving equipment.
The reason to use something like this is the fact that it avoids the need for another pair of lines, which in many cases are simply not available, especially in small embedded systems.

Have a look at the Wiki page and the links at the bottom - there is plenty of detail there.

There are all sorts of extensions to the original AT set though, so I wouldn't bank on everything that mentions AT to actually use all the original Hayes commands. For example I have a bluetooth serial chip here which IIRC uses it's own AT type set.
I'm no expert on it though, I just remember hacking around with commands in ye olde days of dial up and BBS.


The "AT" command set was to solve a problem of needing out of band control information over the same byte-stream channel arbitrary data was sent. This was a common problem of modems, back when they were external boxes connected to computers via a serial cable.

Hayes was a manufacturer of such modems, and gained a lot of early popularity. Their solution for the out of band problem was to send the modem mostly two letter ASCII control commands with a special sequence to put it in data pass thru mode. To reduce the likelyhood of random stuff looking like commands, their command sequences all started with the AT command, which stood for "attention".

Hayes gained so much market share that other modem manufacturers had to implement the same command set to be compatible. That way customers could use their modems without having to re-write software, which was already set up to drive a Hayes modem.

Nowadays, this scheme is rarely used but of course something that was so pervasive sticks around in dark corners even today.