pygate, wipy & TTN no data



  • Hello,
    I think I did everything ok, as on the manuals, but gateway is still disconected on TTN

    On my pygate I have:
    boot. py

    # boot.py -- run on boot-up
    import machine
    import pycom
    from _pybytes import Pybytes
    from _pybytes_config import PybytesConfig
    
    # We want to save a little bit power
    # Disable Heartbeat LED
    pycom.heartbeat_on_boot(False)
    # Enable Pybytes
    pybytes_conf = PybytesConfig().read_config()
    pybytes = Pybytes(pybytes_conf)
    pybytes.start()
    
    # disable debug messages
    machine.pygate_debug_level(1)
    
    # Proceed with main.py
    machine.main('main.py')
    
    

    global_conf.json (downloaded from TTN);

    {
      "SX1301_conf": {
        "lorawan_public": true,
        "clksrc": 1,
        "antenna_gain": 0,
        "radio_0": {
          "enable": true,
          "type": "SX1257",
          "freq": 867500000,
          "rssi_offset": -166,
          "tx_enable": true,
          "tx_freq_min": 863000000,
          "tx_freq_max": 870000000
        },
        "radio_1": {
          "enable": true,
          "type": "SX1257",
          "freq": 868500000,
          "rssi_offset": -166,
          "tx_enable": false
        },
        "chan_multiSF_0": {
          "enable": true,
          "radio": 1,
          "if": -400000
        },
        "chan_multiSF_1": {
          "enable": true,
          "radio": 1,
          "if": -200000
        },
        "chan_multiSF_2": {
          "enable": true,
          "radio": 1,
          "if": 0
        },
        "chan_multiSF_3": {
          "enable": true,
          "radio": 0,
          "if": -400000
        },
        "chan_multiSF_4": {
          "enable": true,
          "radio": 0,
          "if": -200000
        },
        "chan_multiSF_5": {
          "enable": true,
          "radio": 0,
          "if": 0
        },
        "chan_multiSF_6": {
          "enable": true,
          "radio": 0,
          "if": 200000
        },
        "chan_multiSF_7": {
          "enable": true,
          "radio": 0,
          "if": 400000
        },
        "chan_Lora_std": {
          "enable": true,
          "radio": 1,
          "if": -200000,
          "bandwidth": 250000,
          "spread_factor": 7
        },
        "chan_FSK": {
          "enable": true,
          "radio": 1,
          "if": 300000,
          "bandwidth": 125000,
          "datarate": 50000
        },
        "tx_lut_0": {
          "pa_gain": 0,
          "mix_gain": 8,
          "rf_power": -6,
          "dig_gain": 0
        },
        "tx_lut_1": {
          "pa_gain": 0,
          "mix_gain": 10,
          "rf_power": -3,
          "dig_gain": 0
        },
        "tx_lut_2": {
          "pa_gain": 0,
          "mix_gain": 12,
          "rf_power": 0,
          "dig_gain": 0
        },
        "tx_lut_3": {
          "pa_gain": 1,
          "mix_gain": 8,
          "rf_power": 3,
          "dig_gain": 0
        },
        "tx_lut_4": {
          "pa_gain": 1,
          "mix_gain": 10,
          "rf_power": 6,
          "dig_gain": 0
        },
        "tx_lut_5": {
          "pa_gain": 1,
          "mix_gain": 12,
          "rf_power": 10,
          "dig_gain": 0
        },
        "tx_lut_6": {
          "pa_gain": 1,
          "mix_gain": 13,
          "rf_power": 11,
          "dig_gain": 0
        },
        "tx_lut_7": {
          "pa_gain": 2,
          "mix_gain": 9,
          "rf_power": 12,
          "dig_gain": 0
        },
        "tx_lut_8": {
          "pa_gain": 1,
          "mix_gain": 15,
          "rf_power": 13,
          "dig_gain": 0
        },
        "tx_lut_9": {
          "pa_gain": 2,
          "mix_gain": 10,
          "rf_power": 14,
          "dig_gain": 0
        },
        "tx_lut_10": {
          "pa_gain": 2,
          "mix_gain": 11,
          "rf_power": 16,
          "dig_gain": 0
        },
        "tx_lut_11": {
          "pa_gain": 3,
          "mix_gain": 9,
          "rf_power": 20,
          "dig_gain": 0
        },
        "tx_lut_12": {
          "pa_gain": 3,
          "mix_gain": 10,
          "rf_power": 23,
          "dig_gain": 0
        },
        "tx_lut_13": {
          "pa_gain": 3,
          "mix_gain": 11,
          "rf_power": 25,
          "dig_gain": 0
        },
        "tx_lut_14": {
          "pa_gain": 3,
          "mix_gain": 12,
          "rf_power": 26,
          "dig_gain": 0
        },
        "tx_lut_15": {
          "pa_gain": 3,
          "mix_gain": 14,
          "rf_power": 27,
          "dig_gain": 0
        }
      },
      "gateway_conf": {
        "gateway_ID": "2462ABFFFEF4Dxxx",
        "server_address": "eu1.cloud.thethings.network",
        "serv_port_up": 1700,
        "serv_port_down": 1700,
        "servers": [
          {
            "gateway_ID": "2462ABFFFEF4Dxxx",
            "server_address": "eu1.cloud.thethings.network",
            "serv_port_up": 1700,
            "serv_port_down": 1700,
            "serv_enabled": true
          }
        ]
      }
    }
    

    main. py

    from network import WLAN
    import time
    import machine
    from machine import RTC
    import pycom
    
    print('\nStarting LoRaWAN concentrator')
    # Disable Hearbeat
    pycom.heartbeat(False)
    
    # Define callback function for Pygate events
    def machine_cb (arg):
        evt = machine.events()
        if (evt & machine.PYGATE_START_EVT):
            # Green
            pycom.rgbled(0x103300)
        elif (evt & machine.PYGATE_ERROR_EVT):
            # Red
            pycom.rgbled(0x331000)
        elif (evt & machine.PYGATE_STOP_EVT):
            # RGB off
            pycom.rgbled(0x000000)
    
    # register callback function
    machine.callback(trigger = (machine.PYGATE_START_EVT | machine.PYGATE_STOP_EVT | machine.PYGATE_ERROR_EVT), handler=machine_cb)
    
    print('Connecting to WiFi...',  end='')
    # Connect to a Wifi Network
    wlan = WLAN(mode=WLAN.STA)
    wlan.connect(ssid='<SSID>', auth=(WLAN.WPA2, "<PASSWORD>"))
    
    while not wlan.isconnected():
        print('.', end='')
        time.sleep(1)
    print(" OK")
    
    # Sync time via NTP server for GW timestamps on Events
    print('Syncing RTC via ntp...', end='')
    rtc = RTC()
    rtc.ntp_sync(server="pool.ntp.org")
    
    while not rtc.synced():
        print('.', end='')
        time.sleep(.5)
    print(" OK\n")
    
    # Read the GW config file from Filesystem
    with open('/flash/global_config.json','r') as fp:
        buf = fp.read()
    
    # Start the Pygate
    machine.pygate_init(buf)
    # disable degub messages
    # machine.pygate_debug_level(1)
    

    pybytes_config.json
    config.png

    I folow manuals and create in TTN Aplication and gateway:
    gateway.png

    and to mention, when I restart pygate I get this:

    >>> WMAC: 2462ABF4Dxxx
    Firmware: 1.20.2.r6
    Pybytes: 1.7.1
    WMAC: 2462ABF4Dxxx
    Firmware: 1.20.2.r6
    Pybytes: 1.7.1
    Initialized watchdog for WiFi and LTE connection with timeout 1260000 ms
    WiFi connection established
    Connected to MQTT mqtt.pybytes.pycom.io
    Pybytes connected successfully (using the built-in pybytes library)
    Traceback (most recent call last):
      File "boot.py", line 16, in <module>
    AttributeError: 'module' object has no attribute 'pygate_debug_level'
    
    Starting LoRaWAN concentrator
    Traceback (most recent call last):
      File "main.py", line 25, in <module>
    AttributeError: 'module' object has no attribute 'callback'
    Pycom MicroPython 1.20.2.r6 [v1.11-c5a0a97] on 2021-10-28; WiPy with ESP32
    Pybytes Version: 1.7.1
    Type "help()" for more information.
    >>> 
    

    What did I do wrong?



  • @jcaron
    wii that was it.
    I can’t tell you how happy I am that after many days of trying it finally works! : D



  • @Gregor-Leban it does look better now. You must be missing the global_config.json (not global_conf.json).



  • Now I did it again. But I'm still disconected on TTN gateway

    pycom1.png

    pycom2.png

    pycom3.png

    Connecting to COM3...
    WMAC: 2462ABF4Dxxx
    Firmware: 1.20.2.r6
    Pybytes: 1.7.1
    Initialized watchdog for WiFi and LTE connection with timeout 1260000 ms
    WiFi connection established
    Connected to MQTT mqtt.pybytes.pycom.io
    Pybytes connected successfully (using the built-in pybytes library)
    Pybytes configuration read from /flash/pybytes_config.json
    
    Starting LoRaWAN concentrator
    Connecting to WiFi... OK
    Syncing RTC via ntp...... OK
    
    Traceback (most recent call last):
      File "main.py", line 48, in <module>
    OSError: [Errno 2] ENOENT
    Pycom MicroPython 1.20.2.r6 [v1.11-c5a0a97] on 2021-10-28; WiPy with ESP32
    Pybytes Version: 1.7.1
    Type "help()" for more information.
    


  • @Gregor-Leban did you flash the WiPy with the Pygate version of the firmware? Use the firmware upgrade tool and make sure you pick the right version.


Log in to reply
 

Pycom on Twitter