Created
May 22, 2017 06:12
-
-
Save leogaggl/ecbcd48d68bcfe139e18dfc7c86a5bc8 to your computer and use it in GitHub Desktop.
LoPy - The Things Network Australia
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 --> https://console.thethingsnetwork.org/ | |
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): | |
lora.remove_channel(index) | |
# 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 | |
time.sleep(5) | |
print('Trying to join TTN Network!') | |
pass | |
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