At commands to mail for gsm module
Here are some common AT commands used to send and receive SMS messages using a GSM module:
Sending SMS
AT+CMGS=<recipient's phone number>
: Send a SMS message to the specified recipient's phone number.- Example:
AT+CMGS=1234567890
- Example:
AT+CMGS=<recipient's phone number>,<message>
: Send a SMS message to the specified recipient's phone number with the specified message.- Example:
AT+CMGS=1234567890,"Hello, World!"
- Example:
AT+CMSS=<message>
: Send a SMS message with the specified message.- Example:
AT+CMSS,"Hello, World!"
- Example:
Receiving SMS
AT+CNMI=<mode>
: Set the mode for receiving SMS messages.- Example:
AT+CNMI=2
(set to receive SMS messages in text mode)
- Example:
AT+CMGL=<index>
: Read the SMS message with the specified index.- Example:
AT+CMGL=1
(read the first SMS message)
- Example:
AT+CMGR=<index>
: Read the SMS message with the specified index and display it.- Example:
AT+CMGR=1
- Example:
Other AT commands
AT+CMGF=<mode>
: Set the SMS message format (text or PDU).- Example:
AT+CMGF=1
(set to text mode)
- Example:
AT+CMGDA=<command>
: Send a command to the SMS center (SC).- Example:
AT+CMGDA="DEL 1"
(delete the first SMS message)
- Example:
AT+CMGD=<index>
: Delete the SMS message with the specified index.- Example:
AT+CMGD=1
(delete the first SMS message)
- Example:
Error handling
AT+CMEE=<mode>
: Set the error mode for SMS commands.- Example:
AT+CMEE=1
(set to display error messages)
- Example:
AT+CREG=<mode>
: Set the registration mode for the GSM module.- Example:
AT+CREG=2
(set to automatic registration)
- Example:
Note: The exact AT commands and syntax may vary depending on the specific GSM module and its firmware. It's recommended to consult the module's documentation for specific usage and error handling.