LoPy ABP Example

Use the ttnctl command like mentioned here by @arjanvanb
And please change your keys because now they are known to the world :blush:

Thank you so much…finally I got my first message through!!!

Now time for my sodaq :wink:

(and yes, I will change those keys :wink:

perhaps @danicampora can that that value type / signed / unsigned in account with the next release

Yes I hope so, I reported the problem on the Pycom forum. But at least there is a workaround by choosing your device address when using the ttnctl command as mentioned above. So it’s not as blocking as the 1 packet issue.

I probably don’t need it if I don’t know what it is–but I’m curious and can’t help asking. What’s ABP?

This topic is probably a good starter for your question.

For more information please refer to this nice starting point:

1 Like

Hi all, Daniel Campora is working on a guide for using TTN with LoPy. You can find the current draft at:


If you have corrections or suggestions, just use the edit button to do a quick PR!

as long as stuff aint working, i am not spending another minute on the LoPy

That includes building docs


think there has been an update !

think its still not working, not even the new examples

Cant get the wifi working wither to be able to upload files to the LoPy with the new firmware. When I setup wifi to be a station it crashes

posted a working example using a Lopy with the latest firmware using OTAA and a Pi3 gateway in this topic:

PyCom announcing a new module: FiPy

The LoPy Works. Upgrade to latest PyMakr and firmware from the website and you can use the following example:

from network import LoRa
from time import sleep

import socket
import binascii
import struct

# Initialize LoRa in LORAWAN mode.
lora = LoRa(mode=LoRa.LORAWAN, sf=7, tx_power=14)


# create an ABP authentication params
dev_addr = struct.unpack(">l", binascii.unhexlify('XX XX XX XX'.replace(' ','')))[0]
nwk_swkey = binascii.unhexlify('XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX'.replace(' ',''))
app_swkey = binascii.unhexlify('XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX'.replace(' ',''))

# join a network using ABP (Activation By Personalization)
lora.join(activation=LoRa.ABP, auth=(dev_addr, nwk_swkey, app_swkey))

# create a LoRa socket
s = socket.socket(socket.AF_LORA, socket.SOCK_RAW)

# set the LoRaWAN data rate
s.setsockopt(socket.SOL_LORA, socket.SO_DR, 5)

# make the socket blocking.

while True:
    #Do you stuff make data and then send in a loop

Hi, I see a couple of likes but can anyone confirm they have this code working?

try it, it works fine … as long as you don’t want to change the DR/SF

When I’m using the ABP method it always returns true on lora.has_joined(),
I’ve tried to send a few messages with this method but only one actually came through to TTN.

I did also try the OTAA message, in this case the has_joined function does seem to work and messages get through to TTN more often (But after one message I need to reset the board).

are you running the latest firmware?

As firmware is updated quite often I am not entirely sure. I’m running 0.9.6.B1 at the moment

I am running 0.9.5.B1 which works fine. havent tested the newer one yet.

Just noticed there is an installer for 0.9.6.b1a available now too. Will try this one this evening and let you know the results