How to login to TTN MQTT server

jpt
Tue, 14 Oct 2025 16:22:20 +0000
MQTT

Hi,

I am new to LoRa and TTN.

I would like to attach https://lorabridge2.github.io/ to TTN instead of owning a dedicated gateway.

I advised the AI to implement the connector and it looks fine now.

But: Login to the MQTT Server fails.

any idea why?

def on_connect(client, userdata, flags, rc):
    logging.info("Connected to TTN with result code " + str(rc))

    if rc == 0:
        # Subscribe to uplink messages for all devices in the application
        # Topic format: v3/{application-id}@{tenant-id}/devices/+/up
        topic = TTN_UPLINK_TOPIC
        logging.info(f"Subscribing to TTN uplink topic: {topic}")
        client.subscribe(topic)
   # JPT OLD client.subscribe(userdata["chirp"] + "+/event/up")
    else:
        logging.error(f"Failed to connect to TTN, return code {rc}")

You can find my source here:

github.com

GitHub - JPT77/gateway-converter: Trying to connect to The Thingsnetwork TTN

Trying to connect to The Thingsnetwork TTN

MAIN branch is more or less what I am running, EMERGENT branch is what the AI produced.
If you want to see the original source just go where I forked from.
You can simply run converter.py from commandline, if python is set up correctly.

My log is:

$ ./converter.py
Starting TTN Converter
Connecting to TTN broker: eu1.cloud.thethings.network:1883
Username: 7D1903CBD0BBC269ACEE1DA1DBCD1995@ttn
Password: NNSXS.xxxx
Subscribe topic: v3/7D1903CBD0BBC269ACEE1DA1DBCD1995@ttn/devices/+/up
Connected to TTN with result code 5
Failed to connect to TTN, return code 5

Thank you very much.

JPT

8 posts - 2 participants