Search code examples
pythonnetworkingat-commandsim900

Sim900 Won't Find Networks


I have a Sim900 from Sainsmart. I have a working serial connection from my Raspberry Pi to Sim900. I can write commands, receive responses, and even query data such as my phone number from the Sim Card. My Sim Card is an AT&T card. I cannot make Sim900 find a network and attempt to connect. Supposedly, it is supposed to do it on its own, but I have not seen that either. The only two things I can think of are that either the firmware is wrong, or the chip is not getting enough power. The firmware (from AT+CGMR) is Revision:1137B06SIM900M64_ST_ENHANCE. This appears to be the latest firmware that you can get from Simcom's Site. As for power, I am pretty sure the power is sufficient as I bought a charger usb cable and adapter in which the adapter that came with the cable promised to support 2 amps. I stripped the cable and gave it a 3 amp supply of power. The chip also doesn't randomly reset when I try connecting it. I can set settings that get lost on power loss, but they only disappear when I unplug the chip to reset the settings.

The below output is from my latest test to try to understand why I cannot send SMS.

----------------------------------------------------------------------------------------
Command: "b'AT\r\n\r\n'" Response: "AT


OK
"
----------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------
Command: "b'AT+CMEE=2\r\n'" Response: "AT+CMEE=2

OK
"
----------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------
Command: "b'AT+CFUN?\r\n'" Response: "AT+CFUN?

+CFUN: 1

OK
"
----------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------
Command: "b'AT+CREG=2\r\n'" Response: "AT+CREG=2

OK
"
----------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------
Command: "b'AT+CREG?\r\n'" Response: "AT+CREG?

+CREG: 2,0

OK
"
----------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------
Command: "b'AT+COPS?\r\n'" Response: "AT+COPS?

+COPS: 0

OK
"
----------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------
Command: "b'AT+QBAND?\r\n'" Response: "AT+QBAND?

ERROR
"
----------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------
Command: "b'AT+CSQ\r\n'" Response: "AT+CSQ

+CSQ: 20,0

OK
"
----------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------
Command: "b'AT+QENG?\r\n'" Response: "AT+QENG?

ERROR
"
----------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------
Command: "b'AT+CIMI\r\n'" Response: "AT+CIMI

310REDACTED

OK
"
----------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------
Command: "b'AT+CNUM\r\n'" Response: "AT+CNUM

+CNUM: "","1678REDACTED",129,7,4

OK
"
----------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------
Command: "b'AT+CMGF=1\r\n'" Response: "AT+CMGF=1

OK
"
----------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------
Command: "b'AT+CSCS=?\r\n'" Response: "AT+CSCS=?

+CSCS: ("IRA","GSM","UCS2","HEX","PCCP","PCDN","8859-1")

OK
"
----------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------
Command: "b'AT+CSCS="GSM"\r\n'" Response: "AT+CSCS="GSM"

OK
"
----------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------
Command: "b'AT+CREG?\r\n'" Response: "AT+CREG?

+CREG: 2,0

OK
"
----------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------
Command: "b'AT+CMGS="978REDACTED"\r'" Response: "AT+CMGS="978REDACTED"

> "
----------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------
Command: "b'Pi\x1a'" Response: "Pi
+CMS ERROR: operation not allowed
"
----------------------------------------------------------------------------------------

The Python3 script that generated this output is below:

import serial
import time
import binascii

ser = serial.Serial(port='/dev/serial0',baudrate=9600,timeout=1)

command = bytes("AT" + '\r\n', 'utf-8') + binascii.a2b_hex('0D0A')
ser.write(command)
rcv = ser.read(1000)
print("----------------------------------------------------------------------------------------")
print("Command: \"%s\" Response: \"%s\"" % (command, rcv.decode()))
print("----------------------------------------------------------------------------------------")
time.sleep(1)

command = bytes('AT+CMEE=2'+'\r\n', 'utf-8')
ser.write(command)
rcv = ser.read(1000)
print("----------------------------------------------------------------------------------------")
print("Command: \"%s\" Response: \"%s\"" % (command, rcv.decode()))
print("----------------------------------------------------------------------------------------")
time.sleep(1)

#ser.write(bytes("ATE0" + '\r\n', 'utf-8')) # Reverse it with ATE
#rcv = ser.read(1000)
#print(rcv)
#time.sleep(1)

command = bytes('AT+CFUN?'+'\r\n', 'utf-8')
ser.write(command)
rcv = ser.read(1000)
print("----------------------------------------------------------------------------------------")
print("Command: \"%s\" Response: \"%s\"" % (command, rcv.decode()))
print("----------------------------------------------------------------------------------------")
time.sleep(1)

command = bytes('AT+CREG=2'+'\r\n', 'utf-8') # What does 2 do?
ser.write(command)
rcv = ser.read(1000)
print("----------------------------------------------------------------------------------------")
print("Command: \"%s\" Response: \"%s\"" % (command, rcv.decode()))
print("----------------------------------------------------------------------------------------")
time.sleep(1)

command = bytes('AT+CREG?'+'\r\n', 'utf-8')
ser.write(command)
rcv = ser.read(1000)
print("----------------------------------------------------------------------------------------")
print("Command: \"%s\" Response: \"%s\"" % (command, rcv.decode()))
print("----------------------------------------------------------------------------------------")
time.sleep(1)

#command = bytes('AT+COPS=?'+'\r\n', 'utf-8')
#ser.write(command)
#rcv = ser.read(1000)
#print("----------------------------------------------------------------------------------------")
#print("Command: \"%s\" Response: \"%s\"" % (command, rcv.decode()))
#print("----------------------------------------------------------------------------------------")
#time.sleep(10)

command = bytes('AT+COPS?'+'\r\n', 'utf-8')
ser.write(command)
rcv = ser.read(1000)
print("----------------------------------------------------------------------------------------")
print("Command: \"%s\" Response: \"%s\"" % (command, rcv.decode()))
print("----------------------------------------------------------------------------------------")
time.sleep(1)

#ser.write(bytes('AT+COPS=0'+'\r\n', 'utf-8'))
#rcv = ser.read(1000)
#print("\"%s\"" % rcv.decode())
#time.sleep(1)

command = bytes('AT+QBAND?'+'\r\n', 'utf-8')
ser.write(command)
rcv = ser.read(1000)
print("----------------------------------------------------------------------------------------")
print("Command: \"%s\" Response: \"%s\"" % (command, rcv.decode()))
print("----------------------------------------------------------------------------------------")
time.sleep(1)

command = bytes('AT+CSQ'+'\r\n', 'utf-8')
ser.write(command)
rcv = ser.read(1000)
print("----------------------------------------------------------------------------------------")
print("Command: \"%s\" Response: \"%s\"" % (command, rcv.decode()))
print("----------------------------------------------------------------------------------------")
time.sleep(1)

command = bytes('AT+QENG?'+'\r\n', 'utf-8')
ser.write(command)
rcv = ser.read(1000)
print("----------------------------------------------------------------------------------------")
print("Command: \"%s\" Response: \"%s\"" % (command, rcv.decode()))
print("----------------------------------------------------------------------------------------")
time.sleep(1)

command = bytes('AT+CIMI'+'\r\n', 'utf-8')
ser.write(command)
rcv = ser.read(1000)
print("----------------------------------------------------------------------------------------")
print("Command: \"%s\" Response: \"%s\"" % (command, rcv.decode()))
print("----------------------------------------------------------------------------------------")
time.sleep(1)

command = bytes('AT+CNUM'+'\r\n', 'utf-8')
ser.write(command)
rcv = ser.read(1000)
print("----------------------------------------------------------------------------------------")
print("Command: \"%s\" Response: \"%s\"" % (command, rcv.decode()))
print("----------------------------------------------------------------------------------------")
time.sleep(1)

#ser.write(bytes('AT+CNMI=2,1,0,0,0'+'\r\n', 'utf-8'))
#rcv = ser.read(1000)
#print(rcv)
#time.sleep(1)

# TEXTING

command = bytes('AT+CMGF=1'+'\r\n', 'utf-8') # Select Message format as Text mode 
ser.write(command) 
rcv = ser.read(1000)
print("----------------------------------------------------------------------------------------")
print("Command: \"%s\" Response: \"%s\"" % (command, rcv.decode()))
print("----------------------------------------------------------------------------------------")
time.sleep(1)

command = bytes('AT+CSCS=?'+'\r\n', 'utf-8') # Possible Value: GSM
ser.write(command) 
rcv = ser.read(1000)
print("----------------------------------------------------------------------------------------")
print("Command: \"%s\" Response: \"%s\"" % (command, rcv.decode()))
print("----------------------------------------------------------------------------------------")
time.sleep(1)

command = bytes('AT+CSCS="GSM"'+'\r\n', 'utf-8') # Possible Value: (8859-1/latin-1)
ser.write(command)
rcv = ser.read(1000)
print("----------------------------------------------------------------------------------------")
print("Command: \"%s\" Response: \"%s\"" % (command, rcv.decode()))
print("----------------------------------------------------------------------------------------")
time.sleep(1)

command = bytes('AT+CREG?'+'\r\n', 'utf-8')
ser.write(command)
rcv = ser.read(1000)
print("----------------------------------------------------------------------------------------")
print("Command: \"%s\" Response: \"%s\"" % (command, rcv.decode()))
print("----------------------------------------------------------------------------------------")
time.sleep(1)

command = bytes('AT+CMGS="978REDACTED"', 'utf-8') + binascii.a2b_hex('0D') # 0D is CR
ser.write(command)
rcv = ser.read(1000)
print("----------------------------------------------------------------------------------------")
print("Command: \"%s\" Response: \"%s\"" % (command, rcv.decode()))
print("----------------------------------------------------------------------------------------")
time.sleep(5)

command = bytes("Pi",'utf-8') + binascii.a2b_hex('1A')
ser.write(command)
rcv = ser.read(1000)
print("----------------------------------------------------------------------------------------")
print("Command: \"%s\" Response: \"%s\"" % (command, rcv.decode()))
print("----------------------------------------------------------------------------------------")
time.sleep(5)

#ser.write(binascii.a2b_hex('0D0A')) # 0D is CR
#rcv = ser.read(1000)
#print("\"%s\"" % rcv.decode())

Also, the same issue happens when running in minicom. This is not a Python specific issue. Although there is an issue with displaying data from the AT command "AT+COPS=?" in Python. However, the displaying bug is an issue for another day as I can still read it in minicom.

Edit: Clarify the question

Basically, I want to know why I cannot send SMS and how to fix it! I am sure it has to do with not registering on any network, but no network shows up to connect to when running "AT+COPS=?". Listing any potential reasons is appreciated. I can do things such as take a picture of my setup if I need to.

Edit: Provide some insight to "AT+COPS=?"

Using Minicom, I get the below result with "AT+COPS=?". I cannot test this command in Python 3 as it makes the feedback from itself and all other future commands empty, as in empty quotes (e.g. ""). It is a problem even when CMEE is enabled to provide verbose text. This gets reset when I reset the Python program.

AT+COPS=?
+COPS: (1,"Off Network","","310260"),,(0,1,4),(0,1,2)

OK

I get the above result every time I run the command, no matter what I set CREG to.

Links: Amazon Page Where I Bought Sim900


Solution

  • It turns out there is nothing wrong with either my code or hardware. This is an issue with my network provider, AT&T. Now, I knew they got rid of 2G, but I didn't realize that meant calls and texts too. Because I forget calls and texts aren't on their own separate protocol. Since, I am typing this on my phone, I will just use screenshots to show what I mean.

    This is a list of network submodes. My phone is usually on the top option with LTE data. My GSM chip uses the second option, obviously GSM. I may be able to hack together a slower LTE connection as I still support the bands that AT&T's LTE network provides. I would just have to see how feasible it is to hack the firmware.

    Network Submode

    This is what my network list for LTE looks like when scanning (essentially AT+COPS=?):

    LTE Network List

    This is the same output of what my GSM chip sees. This is with the GSM option. I cannot call anyone when selecting the off network option.

    GSM Network List

    Given this, I either need to find a carrier that supports GSM, hack together the firmware to support slow LTE, or chop off my arm and sell it on the black market for an expensive LTE chip.