-1

I am using SIM808 to send SMS to a perticuar number. But when trying to set the number using AT+CMGS=XXXXXXX returns +CMS ERROR:325. I have set the AT+CSCS to GSM but still no luck.The following is the code:

import serial
import os, time

# Enable Serial Communication
port = serial.Serial("/dev/ttyUSB0", baudrate=9600, timeout=1)

# Transmitting AT Commands to the Modem
# '\r\n' indicates the Enter key

port.write('AT'+'\r\n')
rcv = port.read(10)
print rcv
port.write('AT+CMGF=1\r\n')
time.sleep(10)
rcv = port.read(10)
print rcv
port.write('AT+CMGS=\'9912345678\'\r\n')

time.sleep(2)
port.write('test msg')
time.sleep(2)
port.write(chr(26))
rcv = port.read(10)
print rcv
port.flush()

1 Answers1

0

SIM808 expects that AT+CMGS command should enclose the mobile/cell number in double quotes. You have provided escape sequence for single quote. Your code should be :

port.write("AT+CMGS=\"9912345678\"\r\n")

instead of

port.write('AT+CMGS=\'9912345678\'\r\n')

Because you are providing single quotes escape sequence you get +CMS ERROR:325 error.

While providing mobile/cell number it is an good practice to include country code (in your case +91).

Dark Sorrow
  • 1,681
  • 14
  • 37