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 gotten this far, it's because you want to know how. Connecting a LoRaWAN node to TTN end-to-endIt covers everything: gateways, nodes, sensors, libraries, keys, and network configuration. The best part 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 will see, step by step, how Set up a gateway, register it on The Things Network, register applications and end devices, and program LoRaWAN nodes Based on ESP32 or Arduino-type 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 keying 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 we have two main components: gateways and nodesGateways act as "bridges" between the LoRa (radio) world and the IP (internet) world, forwarding packets to the LoRaWAN server. Nodes are the sensors or actuators that send and receive information using LoRa to these gateways.

To connect all of this, you need a LoRaWAN server. You can pay for a private service (operators such as Movistar, Vodafone or platforms such as 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 that It respects data governance, is neutral, and allows you to contribute gateways to the network.In many cities, people install gateways on their own initiative, and anyone can benefit from that coverage at no cost other than the hardware of the nodes.

LoRaWAN Frequencies, Channels, and Limitations

Before buying any device, it is key to be clear that The LoRa frequency must be compatible with your regionWorking in Europe is not the same as working in the United States or Asia; if you use the wrong band, the device may be useless or even illegal.

In Europe, the following is mainly used: 868 MHz band (EU868)In the United States, the typical band is 915 MHz (US915). Chinese stores 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.

In addition to frequency, LoRaWAN is organized into channels, spreading factor (SF), and frequency plansSF defines speed and range: a higher SF means more range but more time in the air, which consumes more energy and takes up more channel.

In Europe, the famous “1% rule”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 a LoRaWAN gateway and one or more nodes (sensors)We can combine hardware from different manufacturers, as long as they respect the LoRaWAN standard and the same frequency band.

One of the most commonly used models for an indoor gateway is the Dragino LPS8It integrates an SX1308 concentrator and allows up to 10 parallel channels. It comes pre-configured with different frequency plans depending on the country, and in Europe it will operate 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 fit well with TTN are the RAK7289 (for outdoor use, rugged and with LTE/4G option) or the official TTN-GW-868 MHz gateways, designed to deploy coverage in cities or Smart City projects. It is also possible to set up a single-cell gateway with an ESP32 board and an SX1262 LoRa module, as is done with the Wio-SX1262 kit along with a XIAO ESP32S3.

As nodes you have two paths: use commercially available sensors already configured 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 block of the project is Start the gateway and get "Connected" to appear in TTNAlthough each manufacturer has its own panel, the conceptual steps are very similar.

With a Dragino LPS8, for example, you can manage it via SSH or HTTPIf 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 the default password “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 you may Some options will appear with a red cross indicating that configuration is missing.The first thing to do is select the correct frequency plan for your area in the LoRa tab; in Europe EU868 (approx. 868 MHz).

  OSI Model: Uses and characteristics

Then tap the tab LoRaWAN or Network ServerHere you define which LoRaWAN server the gateway will connect to. For TTN, you 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 does the gateway connect to the internet?LAN, WAN, or WiFi WAN. For the WAN interface, you can choose a static IP address or DHCP; whenever possible, a wired static IP address is recommended for a more stable connection and easier management access. The LAN interface is typically used for the gateway's internal access point network; it's best not to change it without fully understanding what you're doing, as it could be your lifeline if something goes wrong.

In the WiFi section you will be able to adjust both the access point generated by the gateway itself and its connection to an external WiFi networkFor security, it is recommended to change the default SSID and password of the AP that comes from the factory.

In RAK7289 gateways, the idea is similar: you enter the web panel, You configure the IP (static or DHCP) from Network → WAN Interface 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're behind a router that provides DHCP, you can find 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, it's time to... register him/her in TTNIf 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, you select the section Gateways and click on “Register gateway”TTN will ask you 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.

In addition, you will indicate 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 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 form where you can check the status (“Connected” or “Disconnected”) and a "Traffic" section where you can see the packet flow in real time. If everything is configured correctly on both the gateway and TTN, after one or two minutes you should see it change to "Connected" and start seeing traffic when nodes are transmitting.

This means that The infrastructure part (gateway + server) is already operationalFrom 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 within applicationsAn application groups one or more nodes that send related data, for example all the environmental sensors of a building, or several GPS trackers of an educational project.

In the TTN console, you access the section Applications and create a new applicationYou 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 such as Brown Tabs TBHH100-868 Temperature and humidity sensors are usually attached to a sticker with DevEUI, AppEUI, and AppKey. 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 choose to register a new end device. you introduce JoinEUI (AppEUI), DevEUI and AppKeyYou double-check 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 such as Decentlab level and temperatureThe 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 Prepare and register commercial LoRaWAN sensors who will then talk to TTN through your gateway.

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

Within the app there is a mode to “Advanced Configuration” where you choose “The Things Network” as the platformYou 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 Sensor Tabs Browan TBHH100-868The keys come pre-configured from the factory. The sensor measures temperature and humidity, is powered by a 3,6V battery, and transmits 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 formatting or byte order (msb/lsb) issue, so it's important to check this if it doesn't connect the first time.

  What is a network administrator and their functions

Los Dragino TrackerD trackers They are used as GPS trackers with a panic button. Each unit has its own set of LoRaWAN keys. In TTN, they 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 the Decentlab for level, pressure, or environmental analysisThe philosophy is similar: DevEUI, AppEUI, and AppKey are used to connect to TTN (or another network). Decentlab typically sets a 10-minute transmission interval 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 like tinkering, the most fun is usually... Build and program your own LoRaWAN nodeA 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 screen to display 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 is 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 connected to the microcontroller and you'll have to wire them yourself.

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

There are three typical ways to make these joints: Solder wires directly to the pins (for final assembly), use jumper wires if the board is on a breadboard or route the connections on a custom 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 following is often used: MCCI LoRaWAN LMIC bookstore, which implements the LoRaWAN stack and manages everything related to channels, joins, retries, receive windows, etc.

First you install the library from the Arduino IDE Library Manager Search for “LMIC” and select “MCCI LoRaWAN LMIC library”. Once installed, there is a critical detail: by default it is configured for US915 (United States), so if you are in Europe you must change it to EU868.

For that, you look for the file lmic_project_config.h inside the library folder (something like /Arduino/libraries/MCCI_LoRaWAN_LMIC_library/project_config/) and edit the definitions. You'll comment out CFG_us915 ​​and enable CFG_eu868, also enabling the correct radio type (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 example ttn-abpwhich 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 will see a structure lmic_pinmap where the NSS (CS), RST and DIO pins are specified.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 that 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 check its documentation or find a specific example.

Once the pinout is correct, play Configure the keys that identify your node in TTNIn the ttn-abp example, the variables NWKSKEY, APPSKEY, and DEVADDR appear with the word FILLMEIN so that you can fill them with your values.

You obtain this information from the TTN console when creating a device with ABP activation. TTN offers you 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, most usefully, you can copy the value directly in C array format (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 will use the byte array format that TTN providesFor DEVADDR, you'll set the hexadecimal value as a single integer of type u4_t, for example, `static const u4_t DEVADDR = 0x26011111;`. This will allow your node 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 dataContinuing with the example of the TTGO LoRa32 and a DS18B20, you use the OneWire bus and the DallasTemperature library.

  How to find out my public IP address and understand everything it implies

At the beginning of the sketch you include the headers and define the bus pin: #include , #include and #define ONE_WIRE_BUS Xwhere X is the GPIO to which you have connected the sensor. You create the OneWire object oneWire(ONE_WIRE_BUS) and DallasTemperature sensor(&oneWire). If you do not 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, you can set the resolution (for example sensor.setResolution(11))From then on, the sensor is ready to read the temperature whenever 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 handles scheduling the transmission in the next available slot.

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

OTAA activation, security, and practical experience

So far we've talked mostly about ABP for code examples, but in production It is 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 strengthens security.

With OTAA, the LoRaWAN session It negotiates "on the air" each time the device joins the networkWhen the node shuts down, restarts, 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 choosing OTAA for a device, instead of static NWKSKEY and APPSKEY you will have DevEUI, JoinEUI/AppEUI and AppKeySession keys are built 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 properly 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 (either Decentlab's own, SenseCAP, or third-party dashboards).

Factors such as LoRa sensor box location (best in a vertical position, which favors the radiation pattern of the internal antenna)The radio environment and the gateway height greatly influence the actual coverage, but the configuration 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 Bring that information into your own applications, dashboards, or automation workflowsTTN provides integrations and a very powerful API for this.

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

Another option is to use third-party platforms that already integrate with TTNsuch as Datacake, MyDevices, ResIoT, WMW, and others. Many of them already have specific templates for devices like Decentlab sensors or some Dragino models, so you just have to select the device type, link it to your TTN application, and start viewing the data on "human-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: registered gateway, trackers registered in TTN, data viewed on the console, and then displayed in real time on a public Datacake dashboard with maps and graphs of position, battery level, etc.

The important thing is to understand that TTN acts as a LoRaWAN network layer and data routerYou 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.