Cellular LoRaWAN Nanogateway



  • Hey, does anyone know if it's possible edit the lorawan nanogateway code so that the device is connected via cellular (Cat M1) rather than wifi?



  • @robert-hh So far, I have used the fipy connected to wify and I have also used the fipy with lte. I'm not sure what I'm using (Ap or STA).... but I only use one technology at a time (wifi or lte)

    wifi code (config.py)
    """LoPy LoRaWAN Nano Gateway configuration options"""

    import machine
    import ubinascii

    WIFI_MAC = ubinascii.hexlify(machine.unique_id()).upper()
    GATEWAY_ID = GATEWAY_ID = WIFI_MAC[:6] + "FFFE" + WIFI_MAC[6:12]

    SERVER = 'router.us.thethings.network'
    PORT = 1700
    NTP = "pool.ntp.org"
    NTP_PERIOD_S = 3600

    WIFI_SSID = ''
    WIFI_PASS = '
    '

    LORA_FREQUENCY = 903900000
    LORA_GW_DR = "SF10BW125" # DR_0
    LORA_NODE_DR = 0

    LTE code (config.py)

    """ LoPy LoRaWAN Nano Gateway configuration options """

    import machine
    import ubinascii

    WIFI_MAC = ubinascii.hexlify(machine.unique_id()).upper()

    Set the Gateway ID to be the first 3 bytes of MAC address + 'FFFE' + last 3 bytes of MAC address

    GATEWAY_ID = WIFI_MAC[:6] + "FFFE" + WIFI_MAC[6:12]

    SERVER = 'router.us.thethings.network'
    PORT = 1700

    NTP = "pool.ntp.org"
    NTP_PERIOD_S = 3600

    for US915

    LORA_FREQUENCY = 903900000
    LORA_GW_DR = "SF10BW125" # DR_0
    LORA_NODE_DR = 0



  • @Miguel-Toscano-G There was a discussion about simultaneous WiFi and LTE mode at the forum. As far as I recall the result, there was no clear control about which interface is used by the gateway for it's communication.
    Do you use the FiPy in AP or STA mode?



  • @robert-hh Finally it is running on LTE cat m1 =D thanks... ¿Do you know, how can i use lte cat m1 and wifi on the same gateway at the same time? I want to connect my fipy with ttn using LTE CAT M1(its ready) and connect the same gateway with a laptop through wifi....



  • @robert-hh you are correct, that was the error =D



  • @Miguel-Toscano-G Obviously the file is formatted wrong. Did you really copy the line numbers? If not, there is probably a mix of tabs and spaces in the file, which may be causes by the process of copying and storing.



  • @robert-hh Hi Robert, thank you for help me, I tried with the example "nanogateway" code with WiFi and its work good, but when I changed the config file with de LTE code. I get this IndentationError.

    ----------- Console--------------
    OK
    attached!
    connecting [##] connected!
    [(2, 1, 0, '', ('18.195.176.111', 80))]
    Traceback (most recent call last):
    File "main.py", line 14, in <module>
    File "nanogateway.py", line 99
    IndentationError: unexpected indent
    Pycom MicroPython 1.20.2.rc6 [v1.11-01f49f7] on 2020-02-28; FiPy with ESP32
    Pybytes Version: 1.3.1
    Type "help()" for more information.


    File nanogateway.py
    line 99 refers to ssid y password

               99        self.ssid = ssid
               100        self.password = password
    

    *** the main and nanogatawey files, I did not modify them. Only to the file "config", I delete all the wifi code, and paste the lte configuration, and also, I put the information telephone company.



  • @Miguel-Toscano-G All you have to do is start LTE and connect to the network. Once you have done that, you can run the nanogateway code as it is. I just tried that here with NB-IoT.
    For connecting to the LTE service, follow the examples.



  • @robert-hh
    I changed config.py code for these:

    from network import LTE
    import time
    import socket

    lte = LTE()
    lte.init()

    lte.attach(band=20, apn="internet.itelcel.com")
    print("attaching..",end='')
    while not lte.isattached()
    time.delay(0.25)

    print('.',end='')
    print(lte.send_at_cmd('AT!="fsm"'))
    

    print("attached!")

    lte.connect()
    print("connecting [##",end='')
    while not lte.isconnected():
    time.sleep(0.25)
    print('#',end='')
    #print(lte.send_at_cmd('AT!="showphy"'))
    print(lte.send_at_cmd('AT!="fsm"'))
    print("] connected!")

    print(socket.getaddrinfo('pycom.io', 80))
    lte.deinit()
    #now we can safely machine.deepsleep()


    and now i know, I have to change this into nanogateway.py.... ¿but how ?

    self.wlan = WLAN(mode=WLAN.STA)
    self._connect_to_wifi()




  • @robert-hh said in Cellular LoRaWAN Nanogateway:

    et up the LTE connection.

    Hi Robert, help me please =D, ¿How can I instead set up the LTE connection ?



  • @mylescai the nanogateway opens a socket connection to the TTN server. So you just have to attach and connect the LTE link, and the go on with connecting to TTN.

    Edit: To be more specific. In nanogateway.py, function start(), at about line 140 the wifi is set up. At that place you can instead set up the LTE connection.



  • I was able to get it work just fine. The internet connection to the server worked fine. I'm having issues getting downlink messages to the lorawan nodes, but on AT&T LTE-M its working great.


Log in to reply
 

Pycom on Twitter