Cellular survey?

Adafruit cellular platform - SMS and IoT over celluar

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
barkerben
 
Posts: 10
Joined: Sun Feb 21, 2021 7:42 am

Cellular survey?

Post by barkerben »

I've been looking at the AT commands for the 5320E :

https://www.adafruit.com/product/2691

I was ideally looking for a way to survey the available mobile networks.

I can use the +COPS? AT command to see which networks are available locally
I can then loop through each, attempt to register with the network, and ask for signal quality using +CSQ

However, I assume that signal quality would be expected to change depending on whether I was connecting over 3G or 2G, so it is not clear to me what the CSQ is actually returning...

Is there a way I can query each available network for the access technologies availabile (2G / 3G etc) as well as the signal quality for each...?

Cheers!

User avatar
rskup
 
Posts: 230
Joined: Sat Aug 01, 2020 9:04 pm

Re: Cellular survey?

Post by rskup »

Just a tinkerer with a FONA 3G, not an expert, but looks like:

AT+CPSI?

will tell you whether you're GSM or CDMA

and

AT+CNMP=x

can select GSM (13) or CDMA (14)

Here's the big 5320 manual where I found these:

https://simcom.ee/documents/SIM5320/SIM ... _V2.05.pdf

There's also a command to set band preference in there, AT+CNBP=x, you could possibly even check out each band under GSM or CDMA.

563 pages of commands, this much fun should be illegal!

User avatar
barkerben
 
Posts: 10
Joined: Sun Feb 21, 2021 7:42 am

Re: Cellular survey?

Post by barkerben »

Good spot!
That seems to be backed up by this page (It is referring to LTE bands, but an extension of the same it seems, for modules that support that):

https://m2msupport.net/m2msupport/how-t ... 0-modules/

I'm assuming then that if I try to select a given band, I will get a success of failure, depending upon the cababilities of that cell, and if success, if I then run the +CSQ command, I will get the signal quality for that band.

I'll test it out tonight. If that works, it suggests CSQ defaults to the default preferred mode. Not sure how that default is chosen - the obvious choice would be "best available in theory" - but then, is poor quality on 3G better than great quality on GPRS. Not that it really matters :-)

Cheers!

User avatar
barkerben
 
Posts: 10
Joined: Sun Feb 21, 2021 7:42 am

Re: Cellular survey?

Post by barkerben »

Looking good.
Interestingly,. with a SIM inserted a +COPS command only shows me the operator who provided the SIM - not much use for a survey!
Perhaps for this to work I need to try with an international SIM, which lets you see all the UK networks at once

User avatar
rskup
 
Posts: 230
Joined: Sat Aug 01, 2020 9:04 pm

Re: Cellular survey?

Post by rskup »

Hmmm, looking over the big manual, curious, did you type:

AT+COPS?

or

AT+COPS=?

Looks like (according to the examples on page 81) the first one just tells you who you're currently connected to, but the second one gives you a list?!

Also looks like (again, according to the examples) the leading number (1, 2, or 3) tells you whether that network is "available", "current", or "forbidden". Guessing "forbidden" would be who your simcard isn't with.

User avatar
barkerben
 
Posts: 10
Joined: Sun Feb 21, 2021 7:42 am

Re: Cellular survey?

Post by barkerben »

Yep - the first tells you what you have, the second runs a query.

But, in the UK at least, you can't normally see operators networks other than those who own the SIM unless you are roaming abroad.
I have ordered a French SIM (which I don't plan to activate) to see whether having it inserted allows me to see the other UK networks - I suspect it may...

User avatar
rskup
 
Posts: 230
Joined: Sat Aug 01, 2020 9:04 pm

Re: Cellular survey?

Post by rskup »

Ah, ok. For kicks I think I'll try this on my FONA 3G (5320A) tonight, see what happens in the US (or at least where I live in the US).

I also have a SIM7000G breakout board with a Hologram.io simcard, is suppose to connect anywhere.

Anyways, will try both with both versions of the COPS command, see what happens.

User avatar
barkerben
 
Posts: 10
Joined: Sun Feb 21, 2021 7:42 am

Re: Cellular survey?

Post by barkerben »

Cheers :-) And I'll await my French SIM!

Btw, one useful thing:

+CSQ returns RSSI as a number from 0-199 that can be converted to dBm

It looks like the command you noticed - +CPSI - returns the same RSSI, but directly in dBm, with no conversion required, along with a load of other useful info

User avatar
barkerben
 
Posts: 10
Joined: Sun Feb 21, 2021 7:42 am

Re: Cellular survey?

Post by barkerben »

Ah - I may have spoken too soon regarding the inability to see other networks.

The below works fine, and returns a list of all networks in sight

Code: Select all

import serial
import pprint
import time 
import re 

modem = serial.Serial("/dev/ttyS0", baudrate=115200, timeout=1.0)

def cops():
        modem.write('AT+COPS=?\r\n')
        time.sleep(60)
        result=modem.read(2000)
        regex = r"(\(([^)]*)\))"
        matches = re.finditer(regex, result, re.MULTILINE)
        return matches

def csq():
        modem.write('AT+CSQ=?\r\n')
        result=modem.read(100)
        regex = r"\+CSQ:.*"
        matches = re.search(regex, result, re.MULTILINE)
        return matches.group(0)

def cpsi():
        modem.write('AT+CPSI?\r\n')
        result=modem.read(100)

        regex = r"\+CPSI:.*"
        matches = re.search(regex, result, re.MULTILINE)
        return matches.group(0)

#cpsi=cpsi()
#print cpsi

#csq=csq()
#print csq

cops=cops()
operators={}

for match in cops:
        operator =  match.group(2)
        data=operator.split(",")

        registration=data[0]

        if registration != "0":
                long_name=data[1]
                short_name=data[2]
                operator_code=data[3]
                mode=data[4]

                if operator not in operators:
                        operators[long_name]=[]

                site_data={}

                site_data["short_name"]=data[2]
                site_data["code"]=data[3]
                site_data["mode"]=data[4]
                site_data["registration"]=data[0]

                operators[long_name].append(site_data)


pp = pprint.PrettyPrinter(indent=4)
pp.pprint(operators)

User avatar
rskup
 
Posts: 230
Joined: Sat Aug 01, 2020 9:04 pm

Re: Cellular survey?

Post by rskup »

Oh, very cool, was just finishing up my tests. Like yourself, it seems like I can see all the networks around me too.

btw, thanks for posting that m2msupport link for the SIM7000, I'm still learning the details of mine and examples are great to have!

Locked
Please be positive and constructive with your questions and comments.

Return to “FONA”