mrajiullah / IoT

0 stars 0 forks source link

NB-IOT with FiPy (connection testing successful) #1

Closed mrajiullah closed 5 years ago

mrajiullah commented 5 years ago

FiPy firmware update

NB-IOT Antenna

You will need to connect the antenna to the FiPy using the U.FL connector on the under side of the FiPy. Fipy NB-IOT antenna connection

Module firmware update

>>> import os
>>> os.uname()
(sysname='FiPy', nodename='FiPy', release='1.18.2.r7', version='v1.8.6-849-df9f237 on 2019-05-14', machine='FiPy with ESP32', lorawan='1.0.2', sigfox='1.0.1')

Modem firmware update

IMEI: 354346096085039

- Please note that the updater.elf file is only around 300K so you can also store it inside the flash file system of the module. The firmware dup files will NOT fit into the available /flash file system on the module, so you either need to use an SD card or upload it directly from your computer (UART).
- I used the UART mode
- I uploaded the updater.elf file to the fipy using the pymakr (Ctrl + shift + S)
- You will need the following software installed on your computer:
    - python3
    - PySerial
    ```bash
    $ sudo pip3 install pyserial
    $ pip show pyserial
      DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7.
      Name: pyserial
      Version: 3.4
      Summary: Python Serial Port Extension
      Home-page: https://github.com/pyserial/pyserial
      Author: Chris Liechti
      Author-email: cliechti@gmx.net
      License: BSD
      Location: /Users/mraj/miniconda2/lib/python2.7/site-packages
      Requires: 
      Required-by: adafruit-ampy
mrajiullah commented 5 years ago

Fipy NB-IOT sim insertion I do manage to connect to the Telia NB-IOT but couldnt use socket to make data connection.

>>> from network import LTE
>>> lte=LTE()
>>> lte.attach(band=20, apn="lpwa.telia.iot")
>>> lte.isattached()
True
>>> lte.connect()
>>> lte.isconnected()
True
>>> def send_at_cmd_pretty(cmd):
...     response = lte.send_at_cmd(cmd).split('\r\n')
...     for line in response:
...        print(line)
...
...
...
>>> lte.imei()
'354346096085039'
>>> lte.iccid()
>>>  lte.isattached()
Traceback (most recent call last):
  File "<stdin>", line 1
IndentationError: unexpected indent
>>> lte.isattached()
False
>>> lte.attach(band=20, apn="lpwa.telia.iot")
>>> lte.isattached()
True
>>> lte.iccid()
'89450421190211492260'
>>> send_at_cmd_pretty('AT!="showphy"')

DL SYNCHRO STATISTICS
=====================
    Synchro state                         : CELL_ACQUIRED
    PPU SIB1 ACQ watchdog                 : 0
    Frequency Hypothesis RF  (Hz)         : 0
    RSRP (dBm)                            : -90.96
    RSRQ  (dB)                            : -12.47
    Channel estimation state (Cell-spec.) : LOW CINR
    Channel estimation state (UE-spec.)   : LOW CINR
    Channel estimation state (MBSFN)      : LOW CINR
    Channel estimation CINR               : 2.42
    Channel length                        : SHORT
  AGC
    AGC RX gain (dB)                      : 50.46
    RX PSD BO (dBFs)                      : -22.04
    RX PSD (dBm)                          : -92.81
    Noise level RS (dBm)                  : -94.42
    Digital gain (dB)                     : 4.72
    CINR RS (dB)                          : 3.46
  NARROWBANDS
    Last DL NB                            : Central
    Last UL NB                            : 0
  AFC
    Frequency offset RF  (Hz)             : -467
    Frequency offset BB  (Hz)             : 0
  PBCH
    MIB received quantity                 : 0
    MIB timeout quantity                  : 0

OK

>>> send_at_cmd_pretty('AT!="fsm"')

SYSTEM FSM
==========
    +--------------------------+--------------------+
    |            FSM           |        STATE       |
    +--------------------------+--------------------+
    | RRC TOP FSM              |CAMPED              |
    | RRC SEARCH FSM           |CAMPED              |
    | RRC ACTIVE FSM           |IDLE                |
    | PMM PLMN FSM             |NORM_CAMPED         |
    | EMM MAIN FSM             |REGISTERED          |
    | EMM AUTH FSM             |KASME_DEFINED       |
    | EMM CONN FSM             |EMM_IDLE            |
    | EMM TAU FSM              |NULL                |
    | EMM TEST FSM             |NULL                |
    | ESM BEARER FSM           |BEARER_ACTIVE       |
    | SMS MT FSM               |IDLE                |
    | SMS MO FSM               |IDLE                |
    | LPP FSM                  |IDLE                |
    | HP MAIN FSM              |IDLE                |
    | HP USIM FSM              |READY               |
    | HP SMS MO FSM            |IDLE                |
    | HP SMS MT FSM            |IDLE                |
    | HP CAT FSM               |IDLE                |
    +--------------------------+--------------------+

OK
mrajiullah commented 5 years ago

Ok, it worked for the first time

from network import LTE
import time

lte = LTE()
lte.attach(band=20, apn="lpwa.telia.iot")
while not lte.isattached():
    time.sleep(0.25)
lte.connect()       # start a data session and obtain an IP address
while not lte.isconnected():
    time.sleep(0.25)
>>> import usocket
>>> usocket.dnsserver(0,'8.8.8.8')
>>> usocket.dnsserver(1,'4.4.4.4')
>>> usocket.dnsserver()
('8.8.8.8', '4.4.4.4')
>>> print(usocket.getaddrinfo("www.google.com", 80)[0][-1])
('172.217.21.132', 80)
>>> print(usocket.getaddrinfo("www.kau.se", 80)[0][-1])
('193.10.226.48', 80)