Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
LoPy - The Things Network Australia
from network import LoRa
import time
import binascii
import pycom
pycom.heartbeat(False) #needs to be disabled for LED functions to work
pycom.rgbled(0x7f0000) #red
#Set AppEUI and AppKey - use your values from the device settings -->
app_eui = binascii.unhexlify('1234567890ABCDEF')
app_key = binascii.unhexlify('1234567890ABCDEF1234567890ABCDEF')
lora = LoRa(mode=LoRa.LORAWAN, public=1, adr=0, tx_retries=0)
# Remove default channels
for index in range(0, 72):
# Set AU ISM 915 channel plan for TTN Australia
for index in range(8, 15):
lora.add_channel(index, frequency=915200000+index*200000, dr_min=0, dr_max=3)
lora.add_channel(65, frequency=917500000, dr_min=4, dr_max=4)
for index in range(0, 7):
lora.add_channel(index, frequency=923300000+index*600000, dr_min=0, dr_max=3)
#Join TTN Network via OTAA
lora.join(activation=LoRa.OTAA, auth=(app_eui, app_key), timeout=0)
# wait until the module has joined the network
while not lora.has_joined():
pycom.rgbled(0x7f7f00) #yellow
print('Trying to join TTN Network!')
print('Network joined!')
pycom.rgbled(0x007f00) #green
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment