LoPy To MultiTech Conduit
-
@dchappel I found the same thing (hanging after a short while). I'm going to pull down the current firmware source and see if I can figure out what is happening. This was pretty stable in prior releases, so it may be a minor bug with the updated LoRa stack.
-
@cmsedore That got it...Thanks!
(EDIT) Or so I thought. Now LoPY hanging after a short while. Done with this for now...will pick up again when fresh. Appreciate the help.
-
@dchappel Sorry--apparently, duty_cycle isn't supported now. Try this version of the function--I just tried your code with this change and it seems to work..
def select_subband(lora, subband): if (type(subband) is int): if ((subband<1) or (subband>8)): raise ValueError("subband out of range (1-8)") else: raise TypeError("subband must be 1-8") for channel in range(0, 72): lora.remove_channel(channel) for channel in range((subband-1)*8, ((subband-1)*8)+8): lora.add_channel(channel, frequency=902300000+channel*200000, dr_min=0, dr_max=3)
-
Added your recommendation (which makes total sense!), but now getting this when I run:
Traceback (most recent call last): File "<stdin>", line 23, in <module> File "<stdin>", line 18, in select_subband TypeError: extra keyword arguments given
Probably something simple but it's been a long day...Here's my code:
from network import LoRa import socket import time import binascii import utime def select_subband(lora, subband): if (type(subband) is int): if ((subband<1) or (subband>8)): raise ValueError("subband out of range (1-8)") else: raise TypeError("subband must be 1-8") for channel in range(0, 72): lora.remove_channel(channel) for channel in range((subband-1)*8, ((subband-1)*8)+8): lora.add_channel(channel, frequency=902300000+channel*200000, dr_min=0, dr_max=3, duty_cycle=0) lora = LoRa(mode=LoRa.LORAWAN, adr=False, public=True, tx_retries=0) select_subband(lora,1) app_eui = binascii.unhexlify('00 00 00 00 00 00 00 00'.replace(' ','')) app_key = binascii.unhexlify('00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00'.replace(' ','')) lora.join(activation=LoRa.OTAA, auth=(app_eui, app_key), timeout=0) while not lora.has_joined(): time.sleep(5) print('Not yet joined...') if(lora.has_joined()):print("Hell Yeah!") s = socket.socket(socket.AF_LORA, socket.SOCK_RAW) s.setblocking(False) pressure = 1 while lora.has_joined(): #payload = str(pressure) payload = '{"pressure":'+str(pressure)+',"tst":"'+str(utime.time())+'"}' print(payload) time.sleep(5) s.send(payload) print('Joined...') pressure +=1 if pressure > 100: pressure = 1
-
If you could post your code, that would help, but I usually find that this kind of problem is because the lopy hasn't been narrowed to use the subband channels that your gateway is listening on, so basically, random distribution will get you about 1 in 8 messages going through. Based on your screenshots, you're using subband 1, so if you use this function:
def select_subband(lora, subband): if (type(subband) is int): if ((subband<1) or (subband>8)): raise ValueError("subband out of range (1-8)") else: raise TypeError("subband must be 1-8") for channel in range(0, 72): lora.remove_channel(channel) for channel in range((subband-1)*8, ((subband-1)*8)+8): lora.add_channel(channel, frequency=902300000+channel*200000, dr_min=0, dr_max=3, duty_cycle=0)
and do a:
select_subband(lora,1)
in your code (right after you create the lora object), it should be 100% reliable.
-Chris