LoPy4 failing to connect to Australia TTN?
I have purchased several LoPy4 kits, and I'm trying to connect them to the local TTN network here in Australia.
First, I followed the tutorial at https://docs.pycom.io/gettingstarted/registration/lora/ttn/ to register the LoPy4 device on TTN.
- I created a new application.
- I selected "Add end device". PyCom/LoPy didn't appear in the "LoRaWAN device repository", so I picked "Manually"
- LoRaWAN verison was set to "MAC V1.0.2"
- Regional Parameters version was set to "PHY V1.0.2 REV A"
- Frequency Plan was set to "Australia 915-928 MHz, FSB 2 (used by TTN)"
- I got my DevEUI from the LoPy4 using the below snippet:
from network import LoRa import ubinascii lora = LoRa() print("DevEUI: %s" % (ubinascii.hexlify(lora.mac()).decode('ascii')))
- AppEUI was filled with zeros
- AppKey was generated
- End Device ID was pre-filled with the DevEUI - I left this alone.
I then tried to register the device to the network via OTAA, using some of the commands from https://docs.pycom.io/tutorials/networks/lora/lorawan-otaa/.
>>> from network import LoRa >>> import socket >>> import time >>> import ubinascii >>> lora = LoRa(mode=LoRa.LORAWAN, region=LoRa.AU915) >>> dev_eui = ubinascii.unhexlify('SANITISED') >>> app_eui = ubinascii.unhexlify('0000000000000000') >>> app_key = ubinascii.unhexlify('SANITISED') >>> lora.join(activation=LoRa.OTAA, auth=(dev_eui, app_eui, app_key), timeout=0)
I then wait several minutes to see if it's joined - and it hasn't:
>>> lora.has_joined() False
Does anybody have any ideas why it's failing to connect?
Also, from the official LoRaWAN OTAA instructions, there's two points that aren't very clear:
- It's unclear when you should specify
dev_euior when you should let is use the default? When would you use one over the other?
- There's some commented out parts which mention they should be used with AU915 and PyGate specifically - I assume in this case since I'm just connecting to the community TTN network which may not use a PyGate device I don't need it right? The text is a little unclear when this is needed exactly.
@GregS Caution: I now believe that the only reason that code works for me is because it uses DR0 for the join requests, which is in violation of the regional parameters for Australia, which say to use DR2. I.e - I am too far away from a gateway. As I have said in another thread, the proper way of joining using OTAA is actually working for me, when get closer.
(I don't know WHY that code uses DR0, but I don't really care - it's not code I will be using any more)
FWIW, I've managed to get my LoPy 1 (running current FW) to join using OTAA, using this rather old code:
I don't know how reliable it is yet - all I have done is the join.
@jcaron in the new TTN (nowadays called The Things Stack) they no longer provide a random app EUI, so you'll have to make up your own. Their instructions mention to use all 0's.
Indeed check if you're in range of a local gateway.
There's some commented out parts which mention they should be used with AU915 and PyGate specifically - I assume in this case since I'm just connecting to the community TTN network which may not use a PyGate device I don't need it right? The text is a little unclear when this is needed exactly.
The frequency plan FSB2 indeed coincides with the instructions listed in the green block on this page: https://docs.pycom.io/tutorials/networks/lora/lorawan-otaa/: long story short, a gateway generally listens to only 8 channels, of which these 8 are the most common, and listed on the TTS as 'FSB2'. The instructions mention Pygate, but with the new TTS interface, it is possible to define the frequency plan in more detail than before.
# Uncomment for US915 / AU915 & Pygate # for i in range(0,8): # lora.remove_channel(i) # for i in range(16,65): # lora.remove_channel(i) # for i in range(66,72): # lora.remove_channel(i)
concerning your other question
It's unclear when you should specify dev_eui or when you should let is use the default? When would you use one over the other?
The only requirement is that the
dev_euiis both the same on the device and in TTS. In some cases its convenient to use the LoRa MAC of the Lopy4, in other cases its convenient to use the TTS provided value.
I've never got an OTAA join confirmation here in AU for pycom devices. Give ABP a shot that seemed to work.
@Victor-Hooi the all-zeroes App EUI seems weird to me, although I haven’t used the TTN UI in a long time.
Are you within reach of an existing gateway? Are you indoors or outdoors? Do you have line of sight? how far away are you? Do you know the details of the gateway?
IIRC the AU frequency plan is similar to the US plan, having a lot more channels than a single gateway can support, so you need to remove a lot of channels and only keep those actually used by the network, that’s probably the commented parts you are referring to.