Hello everyone,
Hope you're all doing great during these difficult times...
I'm working with an XBee 3 Cellular LTE-M/NB-IoT , trying to set it up with NB-IoT connection in Brazil.
Currently, I'm using the most basic setup possible to ensure that there are no problems with my Arduino's code, so I'm using default XBee's micropython until I get it to work.
Problem
Or the module returns NETWORK_REG_FAILURE
or it just keep as REGISTERING_TO_NETWORK
and nothing happens.keeps
Hardware
I'm currently with an XBIB-U-Dev and using a W3554B0140 PulseLarsen Antenna.
Software
As I said before, I'm trying to isolate errors and use as much default code provided by Digi as possible to avoid problems on my end as I'm unable to get it working.
I'm using just XCTU and Pycharm 2020.3.5 with Digi's extension.
import time
import xbee
AI_DESC = {
0x00: 'CONNECTED',
0x22: 'REGISTERING_TO_NETWORK',
0x23: 'CONNECTING_TO_INTERNET',
0x24: 'RECOVERY_NEEDED',
0x25: 'NETWORK_REG_FAILURE',
0x2A: 'AIRPLANE_MODE',
0x2B: 'USB_DIRECT',
0x2C: 'PSM_DORMANT',
0x2F: 'BYPASS_MODE_ACTIVE',
0xFF: 'MODEM_INITIALIZING',
}
IP_PROTOCOL = {
'UDP': 0,
'TCP': 1,
'SMS': 2,
'Reserved': 3,
'TCPSSL': 4,
}
def watch_ai(old_ai):
"""
Monitors the value of the AI parameter. Whenever it changes it displays
the new value.
"""
new_ai = xbee.atcmd("AI")
if new_ai != old_ai:
print("- AI Changed!")
print(" * New AI: 0x%02X (%s)"
% (new_ai, AI_DESC.get(new_ai, "UNKNOWN")))
return new_ai
def watch_db(old_db):
"""
Monitors the value of the DB parameter. Whenever it changes it displays
the new value.
"""
new_db = xbee.atcmd("DB")
if new_db != old_db:
print("- DB: {}".format(new_db))
return new_db
print(" +-------------------------------------------+")
print(" | XBee MicroPython Connection Status Sample |")
print(" +-------------------------------------------+\n")
xbee.atcmd("AN", "myapn.com.br")
xbee.atcmd("CU", "user")
xbee.atcmd("CW", "pass")
xbee.atcmd("CP", 1) #Carrier Profile = No Profile
xbee.atcmd("BN", 0x10000000) #Set NB-IoT Bandmask
xbee.atcmd("N#", 3) #Set NB-IoT only
xbee.atcmd("IP", IP_PROTOCOL.get('TCP'))
old_ai = -1
old_db = -1
while old_db != 0x00 and old_ai != 0x00:
old_ai = watch_ai(old_ai)
old_db = watch_db(old_db)
time.sleep(1)
Code Output
+-------------------------------------------+
| XBee MicroPython Connection Status Sample |
+-------------------------------------------+
- AI Changed!
* New AI: 0x22 (REGISTERING_TO_NETWORK)
- DB: None
- AI Changed!
* New AI: 0xFF (MODEM_INITIALIZING)
- AI Changed!
* New AI: 0x22 (REGISTERING_TO_NETWORK)
- DB: 105
- DB: 51
- DB: 69
- DB: 51
- DB: 69
- DB: 51
- DB: 69
- DB: 51
Sometimes I get NETWORK_REG_FAILURE
.
Important Observations
I can read signal strength, however, the module doesn't seem able to read the SIM card phone number, but it does read the others like IMEI, IMSI, ICCID.
I also checked with the SIM card company and they reassured me that the APN, Bandmask, user, and password are right.