Maximize LoPy message size

I want to make the LoPy to be able to reliably send a large payload, the max of 242 bytes. Right now, I just want to get to sending 150 bytes, which I did multiple times this morning. However, after a reboot, it stopped letting me send messages > 100 bytes.

from network import LoRa
import socket
import binascii

lora = LoRa(mode=LoRa.LORAWAN, region=LoRa.US915, bandwidth=LoRa.BW_125KHZ, sf=7, adr=True)

dev_addr = 0x00000000
nwk_skey = binascii.unhexlify("0000000000000000000000000000000000")
app_skey = binascii.unhexlify("0000000000000000000000000000000000")

for i in range(8, 72):
    lora.remove_channel(i)

start = 903900000
f_inc =    200000
curr  = start

for i in range(8):
    print(curr)
    lora.add_channel(index=i, frequency=curr, dr_min=0, dr_max=4)
    curr += f_inc

lora.join(activation=LoRa.ABP, auth=(dev_addr, nwk_skey, app_skey))
s = socket.socket(socket.AF_LORA, socket.SOCK_RAW)
big_buffer = bytes([0xFF] * 150)
s.send(big_buffer)

What should the coding_rate, dr_min, and sf be to achiever this? And should adr be enabled? I’ve tried many combinations and can’t quite it right. Thanks.

The maximum depends on the data rate. So I assume the data rate dropped to a rate too low to allow for the 150 bytes:

As for why the data rate changed: maybe the node did a new OTAA Join and only succeeded at some low rate (high SF), or maybe it used confirmed uplinks and failed to receive the confirmation, hence also lowered its data rate and tried again.

In short: change your application to not need the maximum.

Thank you, input is always appreciated. I would respond exactly as you, but the maximum payload is non-negotiable. I’m using LoRaWAN for a non-IoT research project that requires large payloads. It is a very atypical use case.

On line 1215 of the LoPy’s LoRa module, it only allows data rates 0 - 4 of 7 for the US bands. Do you know why? I’m trying to understand which rates they are, and which spreading factors they correspond with.

https://github.com/pycom/pycom-micropython-sigfox/blob/master/esp32/mods/modlora.c

Removing this line sometimes lets me send large messages (up to 242!), but the behavior is inconsistent. I would greatly appreciate any more input. Thanks.

I’m reading this header file with spreading factor and data rate definitions. https://github.com/pycom/pycom-micropython-sigfox/blob/4481a1c283be97640592ea2a0440830e336064de/lib/lora/mac/region/Region.h

To me it looks like sf=7 and dr=3 would be the right choice for US915. What do you think?

Read the LoRaWAN specification and regional parameters document, that will clear things up.

Thanks. I checked out the spec. To get the largest message, it looks like SF7 at DR_3 and bw of 125 kHz is what I want.

But the LoPy device is not being set to either. No matter how I initialize the LoRa object, or set the data rate in the socket, it won’t actually transmit with those settings. Using lora.sf() gives me 7, but it only transmits at DR_0 (SF10, bw=125kHz) with cr=4/5. Has anyone been able to get the LoPy to actually transmit at different data rates?

max-payloads sf-data-rates

Time to visit the Pycom forum?

I ended up having to edit the PyCom firmware to allow data rates other than DR_0. It doesn’t actually support other data rates in LoRaWAN mode, even though it says it does.