How can I send AT Commands to a cellular module?
Question
How can I send AT Commands to a cellular module?
Solution
Cellular modules can be controlled using standardized plus proprietary AT commands. (Refer to Techship product webpages for the specific products' supported AT commands in the AT commands reference guide, found under Technical documentations tab)
This can be done over the serial interfaces described as modem or AT commands interfaces by the manufacturer. Depending on the way you have the module connected to your host system it is either done over physical UART/RS232 serial interface or the virtual serial interface endpoints enumerated over the physical USB or other host interface.
In Linux AT Commands are sent through the ttyUSB or ttyACM ports. The naming is depending on what driver are used and they can be found under the /dev/ path.
To list available ttyUSB or ttyACM devices you can for example use the following command:
ls /dev/ttyUSB*
ls /dev/ttyACM*
The port name numbers are increased depending on amount of ports found so there's no way to directly tell which serial port accept AT Commands. This have to be checked against which physical device and interface endpoint number they are bound to or by probing the serial port for OK response to the command AT followed by carriage return + new line signs. (cr lf).
There are several applications you can use to send AT commands to a serial port. A common one is the application minicom in Linux. It can often be acquired through the package manager in the Linux distribution you use, e.g. in Ubuntu with apt package manager:
apt-get install minicom
For details on how to use minicom, refer to the following webpage:
http://www.tldp.org/HOWTO/Remote-Serial-Console-HOWTO/modem-minicom.html
Run minicom with elevated privilege like this: (where x represents the port number you want to open)
sudo minicom -D /dev/ttyUSBx
This opens up a new CLI where you can write AT commands. Don't forget to run ATE1 to activate AT Command Echo, to be able to see what you're typing.
In Windows you can find the serial port and their COM numbers by looking in Windows device manager, check under the Modems sub-category or Ports (COM & LPT) sub-category. Under Ports the COM port number is listed directly in the interface endpoint name, while if you look at a modem device you need to right click it, open properties and navigate to the Modem tab to see the COM number
You can use 3rd party software like TeraTerm or Putty to read and write AT commands to the serial COM ports.
https://osdn.net/projects/ttssh2/releases/
https://www.putty.org/
In TeraTerm, choose "serial" and the Modem or AT Command port from the drop down list.
In Putty, select Session, Choose connection type: Serial and enter the correct COM interface and Speed: 115200.
Once you've opened the port you can now send messages to the cellular module. Please be aware that you might not see any replies or letters appearing on the screen until you have successfully sent a message and it has been received by module. Therefore start by writing a simple empty attention command followed by enter key:
AT (enter key)
It should result in an OK reply if successfully received by module or an ERROR if not interpreted correctly.
There are many other 3rd party tools available for both Linux and Windows that can be used to communicate with serial interfaces also.