How to connect a LoRaWAN node to TTN step by step

Last update: January 25, 2026
  • LoRaWAN requires a properly configured gateway (frequency, IP network, server) and registered with TTN for nodes to communicate.
  • End devices are registered in TTN applications using DevEUI, JoinEUI/AppEUI and AppKey (OTAA) or NWKSKEY/APPSKEY/DEVADDR (ABP).
  • It is possible to use commercial sensors (SenseCAP, Decentlab, Dragino, Tabs) or DIY nodes with ESP32/Arduino and LMIC library to send data to TTN.
  • TTN facilitates integrations with Node-RED and external platforms to visualize and exploit IoT data collected by the LoRaWAN network.

Connect LoRaWAN node to TTN

If you've made it this far, it's because you want to know how to connect a LoRaWAN node to TTN from start to finish , leaving nothing out: gateways, nodes, sensors, libraries, keys, and network configuration. The good news is that you don't need to be a telecommunications expert; with a well-structured guide and a little patience, you can set up your own functional LoRaWAN network in no time.

In the following lines, you'll see, step by step, how to set up a gateway, register it on The Things Network, add applications and end devices, and program LoRaWAN nodes based on ESP32 or Arduino boards, as well as examples with commercial sensors (SenseCAP, Decentlab, Dragino, Tabs Browan). We'll also cover practical details not always found in manuals: common key problems, frequency selection, physical pin connections, and tricks to verify that everything is actually communicating with TTN.

What are LoRa and LoRaWAN, and why use TTN?

LoRa and LoRaWAN are two related concepts, but they are not the same . LoRa is a long-range, low-power radio frequency modulation proprietary to Semtech. LoRaWAN is the network protocol that relies on LoRa to manage how end devices (nodes) communicate with gateways and the network server.

In a typical LoRaWAN network, there are two main components: gateways and nodes . Gateways act as "bridges" between the LoRa world (radio) and the IP world (internet), forwarding packets to the LoRaWAN server. Nodes are the sensors or actuators that send and receive information using LoRa to and from these gateways.

To connect all of this, you need a LoRaWAN server. You can pay for a private service (operators like Movistar, Vodafone, or platforms like Loriot, Actility, Kerlink) or go the community route using The Things Network (TTN), which is a public, open network maintained by the community.

TTN has the advantage of respecting data governance, being neutral, and allowing you to contribute gateways to the network . In many cities, people are installing gateways on their own initiative, and anyone can benefit from this coverage at no cost other than the hardware of the nodes.

LoRaWAN Frequencies, Channels, and Limitations

Before buying any device, it's crucial to ensure the LoRa frequency is compatible with your region . Working in Europe is not the same as working in the United States or Asia; if you choose the wrong band, the device may be useless or even illegal.

In Europe, the 868 MHz band (EU868) is primarily used . In the United States, the typical band is 915 MHz (US915). Chinese retailers offer a wide variety of 433 MHz modules, which may be tempting due to their price, but they are not always compatible with LoRaWAN or your country's operating system.

In addition to frequency, LoRaWAN is organized into channels, spreading factor (SF), and frequency plans . The SF defines the speed and range: a higher SF means greater range but also more time on the air, which consumes more power and occupies more channel space.

In Europe, the well-known "1% rule" applies : each device can only occupy the radio channel for a small percentage of the time, typically around 1%. This limits how often you can send data, and is one of the reasons why LoRaWAN sensors usually transmit every few minutes, not every few seconds.

Preparations and selection of hardware for gateway and nodes

To set up a practical network, you will need at least one LoRaWAN gateway and one or more nodes (sensors) . You can combine hardware from different manufacturers, as long as they comply with the LoRaWAN standard and operate on the same frequency band.

One popular indoor gateway model is the Dragino LPS8 , which integrates an SX1308 concentrator and supports up to 10 parallel channels. It comes pre-configured with different frequency plans depending on the country, and in Europe, it operates at 868 MHz. It is powered by 5V via USB-C and connects to the IP network via RJ-45 or Wi-Fi.

Other examples of gateways that work well with TTN include the RAK7289 (outdoor, rugged, and with LTE/4G option) or the official TTN-GW-868 MHz gateways, designed for deploying coverage in cities or Smart City projects. It's also possible to build a single-cell gateway with an ESP32 board and an SX1262 LoRa module , as is done with the Wio-SX1262 kit and a Xiaomi ESP32S3.

As nodes you have two options: use commercial sensors already ready for LoRaWAN (SenseCAP S210x, Tabs Browan TBHH100, Dragino TrackerD, Decentlab, etc.) or build your own nodes with development boards such as TTGO LoRa32 V2.0, ESP32 + RMF95, Arduino + LoRa module, etc.

Configure a LoRaWAN gateway and connect it to TTN

The first major step in the project is to get the gateway up and running and have "Connected" appear on TTN . Although each manufacturer has its own dashboard, the conceptual steps are very similar.

With a Dragino LPS8, for example, you can manage it via SSH or HTTP . If you connect it via RJ-45 cable, you'll need to find out the IP address assigned by the DHCP server (using an IP scanner or through your router). If you prefer initial setup via Wi-Fi, the LPS8 creates its own network with an SSID like “dragino-xxxxx” and a default password like “dragino+dragino”. Accessing the IP address 10.130.1.1 will take you to the web panel, where the initial username and password are usually “admin/dragino”.

Upon entering, you will see a menu with several sections, and some options may have a red cross indicating that configuration is missing . The first step is to select the correct frequency plan for your area in the LoRa tab; in Europe, this is EU868 (approximately 868 MHz).

  Differences between Bluetooth 4.0, 5.0 and 5.3 explained in detail

Next, tap the LoRaWAN or Network Server tab . There you define which LoRaWAN server the gateway will connect to. For TTN, choose "TTN" as the provider and enter the address of the European server (for example, eu1.cloud.thethings.network), keeping the UDP ports (usually 1700 for both upload and download). In that same section, you'll see the Gateway ID or EUI, which we'll need later in TTN.

In the Network section, you configure how the gateway connects to the internet : LAN, WAN, or Wi-Fi WAN. For the WAN interface, you can choose a static IP address or DHCP; whenever possible, a static IP address over a wired connection is recommended for a more stable connection and easier management access. The LAN section is typically used for the gateway's internal access point network; it's best not to change this setting without fully understanding what you're doing, as it could be a lifesaver if something goes wrong.

In the WiFi section, you can adjust both the access point generated by the gateway itself and its connection to an external WiFi network . For security, it is recommended to change the default SSID and password of the access point that came from the factory.

On RAK7289 gateways, the process is similar: access the web panel, configure the IP address (static or DHCP) via Network → WAN Interface , and then, in LoRa Network → Network Settings → Packet Forwarder, enter the TTN server details and note the Gateway EUI to register it with TTN later. If you are behind a router that provides DHCP, you can locate the gateway's IP address by looking at the lease table (by hostname, for example, "RAK7289") or using tools like nmap.

Gateway registration on The Things Network

Once the gateway has internet access, you need to register it with TTN . If you don't have an account, first register on The Things Network website and then access the Console in the corresponding region (for example, https://eu1.cloud.thethings.network/).

Within the console, select the Gateways section and click on “Register gateway” . TTN will ask for a Gateway ID (a unique name within your account) and, depending on the gateway type, the Gateway EUI. For Dragino LPS8 gateways that use the classic packet forwarder, you must select the “I'm using the legacy packet forwarder” option.

Additionally, you will specify the frequency plan (EU868 for Europe) , the corresponding region or router, and optionally, the location (coordinates, indoor/outdoor, etc.). On gateways like the single-cell one with the XIAO ESP32S3 and Wio-SX1262, the firmware itself may display the Gateway ID via the serial port upon startup; simply copy it and use it in the registration form.

After completing this information and registering the gateway, TTN will display a status checker (“Connected” or “Disconnected”) and a “Traffic” section where you can view the packet flow in real time. If everything is configured correctly on both the gateway and TTN, you should see it change to “Connected” within a minute or two and start seeing traffic when nodes are transmitting.

This means that the infrastructure (gateway + server) is now operational . From here, the configuration of applications and end devices comes into play.

Application creation and node registration in TTN

In TTN, devices are not registered directly at the root of the account, but rather within applications . An application groups one or more nodes that send related data, for example, all the environmental sensors in a building, or several GPS trackers in an educational project.

In the TTN console, go to the Applications section and create a new application . Give it a unique ID, optionally a description, and choose the appropriate region. Within that application, you will register each LoRaWAN node with its credentials (DevEUI, JoinEUI/AppEUI, and AppKey or other keys depending on the activation method).

For commercial sensors like the Browan TBHH100-868 temperature and humidity sensors, a label with DevEUI, AppEUI, and AppKey is usually attached. They typically use the OTAA (Over-The-Air Activation) method, which generates key sessions with each network join, making it more secure than ABP.

With OTAA, in TTN you select to register a new end device, enter JoinEUI (AppEUI), DevEUI, and AppKey , verify the data, and confirm. Once saved, if the node is correctly configured and within range of a gateway, it will see the network beacons, perform the join procedure, and you will start seeing uplink messages with their measurements in the console.

The same applies to sensors like the Decentlab level and temperature sensors : the manufacturer provides the ID, DevEUI, AppEUI, and AppKey, but doesn't know in advance which server you'll be using. You're responsible for registering this information with TTN (or another server) so the sensor can be registered. Many Decentlab devices come pre-registered with TTN if you request it, which further simplifies the process.

Configuring commercial LoRaWAN sensors

Let's look at some concrete examples of how to prepare and register commercial LoRaWAN sensors that will then communicate with TTN through your gateway.

In the SenseCAP S210x range (for example, environmental sensors), the typical workflow is to use the manufacturer's SenseCraft app . First, you download the app, turn on the sensor with a button (by holding it down for a few seconds until the LED flashes every second), and then in the app, you select "Scan" to read the device's QR code.

Within the app, there's an "Advanced Configuration" mode where you select "The Things Network" as the platform . You must select the same frequency plan as your gateway (for example, EU868) and verify that the joining mode is OTAA. The application will display the Device EUI, AppEUI (JoinEUI), and AppKey; it's a good idea to note these down because you'll need to enter them into TTN when registering the device.

In the case of the Tabs Browan TBHH100-868 sensor , the keys come pre-configured from the factory. The sensor measures temperature and humidity, is powered by a 3,6V battery, and transmits data according to these rules: every 60 minutes if there is no change, or sooner if the temperature changes by ±2°C or the humidity by ±5%. To register it, simply enter the APPKey, APPEUI, and DevEUI provided by the manufacturer into your LoRaWAN server (TTN, for example). Sometimes there may be a problem with the format or byte order (msb/lsb), so it's important to check this if it doesn't connect the first time.

  Firewall configuration: a complete guide to protecting your network

Dragino TrackerD devices are used as GPS trackers with a panic button. Each unit has its own set of LoRaWAN keys. In TTN, these are typically registered in the same application (e.g., "course-tracking"), and the device is configured, if necessary, via serial port (USB) using AT commands. The documentation details commands for adjusting the transmission rate, alarm behavior, etc. Important: Many Dragino firmwares require that AT commands be pasted in full into the terminal, not typed character by character.

In sensors like Decentlab's level, pressure, or environmental sensors , the philosophy is similar: DevEUI, AppEUI, and AppKey are used to connect them to TTN (or another network). Decentlab typically sets a transmission interval of 10 minutes because it's a proven compromise between data consumption and resolution, although this can be modified upon request or via configuration. Users can view the data on the manufacturer's own cloud platform or integrate the device into third-party platforms (MyDevices, ResIoT, WMW, etc.) by adding the appropriate payload decoder.

Build your own LoRaWAN node with open-source hardware

If you enjoy tinkering, the most fun is often building and programming your own LoRaWAN node . A very popular combination is to use an ESP32-based board with integrated LoRa, such as the TTGO LoRa32 V2.0 868 MHz, and add a simple sensor, for example, a DS18B20 temperature sensor.

This approach requires four pieces: the control board (ESP32, Arduino, etc.), the LoRa radio module (for example an RFM95 type SX1276/78), the sensor you want to measure , and optionally, peripherals such as an OLED display to show data locally.

The TTGO LoRa32 V2.0 comes with an integrated LoRa transceiver and, depending on the version, a small OLED display. Based on the ESP32, it provides WiFi and Bluetooth, and in many cases, it's also perfect for building a single-channel mini gateway when connected to the internet. However, on this board and similar ones, some signals from the LoRa module (DIO1, DIO2) are not pre-wired to the microcontroller , and you'll have to wire them yourself.

For example, the TTGO LoRa32 V2.0 typically uses the following pinout for LoRa: SCK on GPIO5, MISO on GPIO19, MOSI on GPIO27, CS on GPIO18, RESET on GPIO14, and DIO0 on GPIO26 . DIO1 and DIO2 are usually physically connected to GPIO33 and GPIO32, respectively, which are located directly opposite each other on the opposite row, making it very easy to use a direct jumper.

There are three typical ways to make these connections: soldering wires directly to the pins (for final assembly), using jumper wires if the board is on a breadboard , or routing the connections onto a dedicated PCB onto which the TTGO is plugged. The jumper option is usually the most convenient for testing.

Node software: LMIC library, frequency and TTN keys

To program a LoRaWAN node on Arduino/ESP32, the MCCI LoRaWAN LMIC library is widely used , which implements the LoRaWAN stack and manages everything related to channels, joins, retries, receive windows, etc.

First, install the library from the Arduino IDE's Library Manager by searching for "LMIC" and selecting "MCCI LoRaWAN LMIC library". Once installed, there's a critical detail: by default, it's configured for US915 (United States), so if you're in Europe, you must change it to EU868.

To do this, locate the lmic_project_config.h file within the library folder (something like /Arduino/libraries/MCCI_LoRaWAN_LMIC_library/project_config/) and edit the definitions. Comment out CFG_us915 ​​and enable CFG_eu868, also ensuring the correct radio type is enabled (for example, CFG_sx1276_radio for SX1276/78 modules). This is a one-time change that applies to all your LMIC projects.

Then you open one of the included examples, for instance ttn-abp , which periodically sends a “Hello, world!” as a payload. This example serves as a basis for adapting it to your board and your TTN credentials.

In the code, you'll see an lmic_pinmap structure that specifies the NSS (CS), RST, and DIO pins . By default, it's usually mapped for the Feather M0 LoRa, so if you're using a TTGO LoRa32 V2.0, you'll need to change this structure to use .nss = 18, .rst = 14, and .dio = {26, 33, 32} (assuming you've wired DIO1 to GPIO33 and DIO2 to GPIO32). If your hardware is different, you'll need to consult its documentation or find a specific example.

Once the pinout is correct, it's time to configure the keys that identify your node in TTN . In the ttn-abp example, the variables NWKSKEY, APPSKEY, and DEVADDR appear with the word FILLMEIN so you can fill them in with your values.

You obtain this data from the TTN console when creating a device with ABP activation. TTN provides you with the Network Session Key (NWKSKEY), App Session Key (APPSKEY), and Device Address (DEVADDR) . In the interface, the keys are hidden for security reasons, but you can make them visible and, more usefully, copy the value directly as a C array (using the "<>" button) with the correct byte order (msb). Clicking the copy icon copies the array to the clipboard, and you can simply paste it into your code where each FILLMEIN is located.

For NWKSKEY and APPSKEY, you'll use the byte array format provided by TTN , while for DEVADDR, you'll set the hexadecimal value as a single integer of type u4_t, for example, `static const u4_t DEVADDR = 0x26011111;`. With this, your node will be able to authenticate and route its packets to your TTN application.

Integrate sensors into the node code

Once the LoRaWAN skeleton is working, it's time to replace the typical "Hello, world!" with real sensor data . Continuing with the example of the TTGO LoRa32 and a DS18B20, you use the OneWire bus and the DallasTemperature library.

  How to transfer files between PCs: all options explained

At the beginning of the sketch, include the headers and define the bus pin: `#include <OneWire.h>`, `#include <DallasTemperature.h>`, and `#define ONE_WIRE_BUS X` , where X is the GPIO pin to which you have connected the sensor. Create the `OneWire` object `oneWire(ONE_WIRE_BUS)` and the `DallasTemperature` object `sensor(&oneWire). If you don't have the DS18B20 library installed, add it from the library manager.

In the setup() function, you initialize the sensor with sensor.begin() and, if you want, set the resolution (for example, sensor.setResolution(11)) . From then on, the sensor is ready to read temperature when you need it.

The key function in LMIC for sending data is `do_send(osjob_t* j)`. Inside, you'll see a check for an ongoing transmission (`OP_TXRXPEND`). If there isn't one, you call `sensor.requestTemperatures()`, get the value with `sensor.getTempCByIndex(0)`, and store it in the `mydata` array. For example, you could use `mydata[0] = (uint8_t)sensor.getTempCByIndex(0);` to send only the integer part.

Then you call LMIC_setTxData2(1, mydata, sizeof(mydata), 0) , where the first parameter is the LoRaWAN port (1 in this case), the second is the buffer, the third is the size, and the last indicates whether the message is acknowledged (1) or unacknowledged (0). The library then schedules the transmission in the next available slot.

There are many possible improvements: expanding the payload to include decimal data, adding other sensors, packaging data in an efficient binary format , etc. But even in this simple version, you already have a node that periodically sends real-time measurements to TTN, visible on the console and ready to integrate with other systems.

OTAA activation, security, and practical experience

So far we've mainly discussed ABP for code examples, but in production, it's highly recommended to use OTAA (Over-The-Air Activation) . OTAA is the method used by, for example, Decentlab sensors and many SenseCAP sensors, because it enhances security.

With OTAA, the LoRaWAN session is negotiated "on the air" each time the device joins the network . When the node is powered off, restarted, or loses connection, new session keys are generated the next time it joins, making it difficult for someone to clone the device simply by copying static keys.

In the TTN console, when you select OTAA for a device, instead of static NWKSKEY and APPSKEY, you will have DevEUI, JoinEUI/AppEUI, and AppKey . Session keys are constructed each time from these values ​​and the exchange with the server, and you will only see the derived keys for the duration of the session.

In practice, users starting from scratch with LoRaWAN have found that with a gateway registered with TTN and a correctly configured OTAA sensor, the registration process can be very simple : create an account on TTN, activate the gateway, register the sensor with the keys provided by the manufacturer, and in a few minutes view data on a web platform (whether it is Decentlab's own, SenseCAP, or third-party dashboards).

Factors such as the location of the sensor's LoRa box (best in a vertical position, which favors the radiation pattern of the internal antenna) , the radio environment, and the gateway's height greatly influence the actual coverage, but the setup flow is fairly mechanical once understood.

From TTN to your applications: integrations and visualization

With the nodes now uploading data to TTN, the next step is to bring that information into your own applications, dashboards, or automation workflows . TTN provides powerful integrations and an API for this.

A very common approach is to use Node-RED to receive data from TTN and process it as needed . You configure an MQTT or HTTP connection with your TTN application credentials, decode the payload (according to your sensors' format), and from there you can do practically anything: save to databases, display graphs, trigger alerts, etc.

Another option is to use third-party platforms that already integrate with TTN , such as Datacake, MyDevices, ResIoT, WMW, and others. Many of these platforms already have specific templates for devices like Decentlab sensors or some Dragino models, so you just need to select the device type, link it to your TTN application, and start viewing the data on user-friendly dashboards.

In educational projects, for example, TTN has been used in conjunction with RAK7289 gateways and Dragino TrackerD trackers for locating people or vehicles. The workflow is as follows: gateway registered, trackers registered in TTN, data viewed on the console, and then displayed in real time on a public Datacake dashboard with maps and graphs showing position, battery level, etc.

The important thing to understand is that TTN acts as a LoRaWAN network layer and data router ; you decide the application and visualization layer: from a Python script that consumes the API to an industrial IoT data platform.

In short, connecting a LoRaWAN node to TTN involves several steps (correct frequency, properly configured gateway, TTN registration, node keys, OTAA or ABP activation, device software, and, if desired, subsequent integrations), but each part is manageable even without prior experience if the right guidelines are followed. Once the initial setup is complete, deploying more nodes or gateways becomes a highly repeatable and scalable process, perfect for large-scale sensor projects, Smart City initiatives, or simply for learning and experimenting with long-range IoT.