FiPy with LoRaWAN using AS923 channel plan

  • Been trying to get my FiPy hooked up with LoraWAN and struck an incompatiblity with AS923.

    The following code:

    import uos
    import utime
    from network import LoRa
    from machine import unique_id
    import ubinascii

    def mac2eui(mac):
    mac = mac[0:6] + 'fffe' + mac[6:]
    return hex(int(mac[0:2], 16) ^ 2)[2:] + mac[2:]

    unique_id = ubinascii.hexlify(unique_id()).decode()

    lora = LoRa(mode=LoRa.LORAWAN)
    dev_eui = mac2eui(unique_id)
    app_eui = binascii.unhexlify('70 B3 D5 7E F0 00 3B FD'.replace(' ',''))
    app_key = binascii.unhexlify('36 AB 76 25 FE 77 0B 68 81 68 3B 49 53 00 FF D6'.replace(' ',''))

    for channel in range(0, 16):

    lora.add_channel(0, frequency=923200000, dr_min=0, dr_max=5)
    lora.add_channel(1, frequency=923400000, dr_min=0, dr_max=5)

    lora.join(activation=LoRa.OTAA, auth=(app_eui, app_key), timeout=0)

    while not lora.has_joined():
    print("not joined yet...")


    gives the following output:

    (sysname='FiPy', nodename='FiPy', release='1.13.0.b1', version='v1.8.6-849-656704e on 2018-01-10', machine='FiPy with ESP32', lorawan='1.0.0', sigfox='1.0.1')

    Traceback (most recent call last):
    File "<stdin>", line 27, in <module>
    ValueError: invalid argument(s) value

    MicroPython v1.8.6-849-656704e on 2018-01-10; FiPy with ESP32
    Type "help()" for more information.

    The issue is that the add_channel() method does not allow for a dr_max > 4. The AS923 however allows for the following data rates:

    0 LoRa: SF12 / 125 kHz 250
    1 LoRa: SF11 / 125 kHz 440
    2 LoRa: SF10 / 125 kHz 980
    3 LoRa: SF9 / 125 kHz 1760
    4 LoRa: SF8 / 125 kHz 3125
    5 LoRa: SF7 / 125 kHz 5470
    6 LoRa: SF7 / 250 kHz 11000
    7 FSK: 50 kbps 50000

    Am I missing something?

  • So this should do it, acknowledging that no channel willever use AS923 data rate 0 or 1?

    for channel in range(0, 15):

    lora.add_channel(0, frequency=923200000, dr_min=0, dr_max=3)
    lora.add_channel(1, frequency=923400000, dr_min=0, dr_max=3)
    lora.add_channel(2, frequency=922200000, dr_min=0, dr_max=3)
    lora.add_channel(3, frequency=922400000, dr_min=0, dr_max=3)
    lora.add_channel(4, frequency=922600000, dr_min=0, dr_max=3)
    lora.add_channel(5, frequency=922800000, dr_min=0, dr_max=3)
    lora.add_channel(6, frequency=922000000, dr_min=0, dr_max=3)

  • @kompleteb
    Our implementation pre-dates the first AS923 implementation so we don't have support for it yet - it assumes US915.

    Usually you can go around the issue by defining channels manually using add_channel and remove_channel, but for datarates to match you need to think:

    datarate on AS923 = LoPy datarate + 2

    So if you set datarate 0 it's actually AS923 datarate 2, up to datarate 3 which is 5 on AS923. It's not possible to use AS923 data rates 0 and 1.

    This is all changing as we're making progress on updating our LoRa stack implementation, taking in the missing regions and more. But for now it only works with you consider it relative to US915.

Pycom on Twitter

Looks like your connection to Pycom Forum was lost, please wait while we try to reconnect.