Returns a network.LTE object with an active Internet connection.
def getLTE():
# If already used, the lte device will have an active connection.
# If not, need to set up a new connection.
if lte.isconnected():
return lte
# Modem does not connect successfully without first being reset.
print("Resetting LTE modem ... ", end="")
lte.send_at_cmd('AT^RESET')
print("OK")
time.sleep(1)
#print(".\n")
# While the configuration of the CGDCONT register survives resets,
# the other configurations don't. So just set them all up every time.
print("Configuring LTE ", end='')
lte.send_at_cmd('AT+CGDCONT=1,"IP","hologram"') # Changed this from origninal
print(".", end='')
lte.send_at_cmd('AT!="RRC::addscanfreq"') #
print(".", end='')
lte.send_at_cmd('AT+CFUN=1')
print(" OK")
# If correctly configured for carrier network, attach() should succeed.
if not lte.isattached():
print("Attaching to LTE network ", end='')
lte.attach(apn='hologram')
while(True):
if lte.isattached():
print(" OK")
break
print('.', end='')
time.sleep(1)
# Once attached, connect() should succeed.
if not lte.isconnected():
print("Connecting on LTE network ", end='')
lte.connect()
while(True):
if lte.isconnected():
print(" OK")
break
print('.', end='')
time.sleep(1)
# Once connect() succeeds, any call requiring Internet access will
# use the active LTE connection.
return lte
Clean disconnection of the LTE network is required for future
successful connections without a complete power cycle between.
# Ensures LTE session is connected before attempting NTP sync.
lte = getLTE()
print("Updating RTC from {} ".format(NTP_SERVER), end='')
rtc.ntp_sync(NTP_SERVER)
while not rtc.synced():
print('.', end='')
time.sleep(1)
print(' OK')
Only returns an RTC object that has already been synchronised with an NTP server.
def getRTC():
if not rtc.synced():
setRTC()
return rtc
Program starts here.
try:
print(“Initially, the RTC is {}”.format(“set” if rtc.synced() else “unset”))
rtc = getRTC()
while(True):
print(“RTC is {}”.format(rtc.now() if rtc.synced() else “unset”))
time.sleep(5)
except Exception:
pass # do nothing on error
Hologram does have a contract with Telefonia in Germany, see: Global IoT Coverage | Hologram (click or type “Germany”) although they do not list Cat-M1 as being supported so it may or may not work. That would be the only carrier that supports Cat-M1 at this time. Note hologram does not support NB-IOT yet.
If AT+CPIN? is returning an error, then the cellular modem is unable to communicate with your SIM. You’ll want to check that the SIM is inserted properly and that you’re satisfying the power requirements of the board you’re using.
Yep I agree with Pat, its an error with reading the simcard, likely not installed correctly, or bad power supply for the device causing it to brown out. Check the orientation of the simcard against the pycom documentation. I’ve definitely installed simcards in every wrong way possible, its also possible that its just not inserted all the way or inserted too far, some of the simcard holders are crap.
The CFUN being 0 instead of 1 would also be an issue, although this may be because the simcard is not readable, you could try running AT+CFUN=1 and see if it will switch to active mode.
The Hologram simcards work with a lot of technologies even in Europe such as 2G, 3G and “standard” LTE such as Cat-1, 2, 4. Cat-M1 and NB-IOT are fairly new and its actually the tower owners (“traditional” telecoms) that are fairly restrictive with it, likely because it is so new.
I was tinkering with the GPY with a Hologram card here in the US until I moved on to the DIGI XBee3 that works perfectly. Apparently the GPY is not certified to work on ATT network here There is no need to use CPIN command as there is no pin for Hologram cards. If you want to make sure the modem can read the sim then use the AT+SQNCCID?. Before doing so though you need to set CFUN to 4 for it to read the ICCID from the sim card. For proper connection attempt, also be sure to set the APN to “hologram” either with AT commands or the Python functions built in to the GPY OS.
Thanks guys, really appreciate the help!
I removed and reinserted the SIM card. The orientation was correct, power supply is, too.
Just noticed that I missed the part that hologram doesn’t support NB, yet. The tests I ran below were with the NB firmware. I’ll flash CAT1 and come back.
I’ll leave the tests here for comparison.