Connecting the Arduino MKR WAN to The Things Network using LoRaWAN Part 2


In the previous tutorial, we covered the setup of your Arduino MKR WAN. This included installing the Arduino IDE, connecting the board to your computer, and downloading and installing the necessary boards and drivers. In the second part of this tutorial, we will create and activate an account on The Things Network (TTN), add your Arduino MKR WAN to the account, and send a test message to TTN.

Creating and activating an account at The Things Network

Each MKR WAN device has a unique identification number, known as its Device EUI. It is essential to locate this number before setting up your account on The Things Network (TTN).

First configuration get EUI

Ensure your device remains connected to the computer. Upload the sketch named FirstConfiguration from the MKRWAN library. Navigate to File > Examples > MKRWAN > FirstConfiguration to find it.

Upload the sketch to your device and then open the serial monitor, as previously done for the firmware update sketch. The serial monitor should display the Device EUI.

Copy the device EUI from the serial monitor and paste into any convenient text editor such as Notepad. You will need this EUI to register your device with The Things Network.


To create an account, register for free here (click on the light blue button on the left). You will need to include a username, email address and password. Make a note of these. Note that your username will be used as the ‘Owner’ name when you start registering your applications.

Now visit The Things Network and select your region, either by selecting from the left-hand menu, or by clicking on the map. I selected ‘Europe 1’.

Adding an application

Install Boards Manager

Once you have logged into the landing page, click the ‘Create an application’ button, or ‘Go to applications’ if you already have one created. You may see one of the screens below. Now click ‘Applications’.


Go To Application

Registering a device (such as your MKR WAN 1300) with The Things Network is a two-stage process. Firstly, you have to set up an ‘Application’, and then you add ‘Devices’ to your application. If you wanted to, you could add several devices to one application. I have just added one device to one application for simplicity.

Add application button

Once you have clicked the ‘Create an application’ button, (or ‘Go to applications’ button), you will arrive at the Applications landing page. Click the blue ‘Add application’ (it may say ‘Create application’) button to start the process.

Boards 2, 3, 4 and 5 are ones I did earlier (there is no Board 1). You will now be taken to this page.


Add application

The ‘Owner’ field is automatically filled in based on the username you used when you registered (this field may be missing if you already have previous applications).

The ‘Application ID’ is the unique name that you give your application. You can call it anything, provided you only use lowercase letters, numbers and dashes (-)

You can type anything into the ‘Application name’ field. You are not limited to lowercase letters, numbers and dashes (-).

The ‘Description’ field is optional.

When done, click the blue ‘Create application’ button. You will then be taken to the application landing page.


Registering a Device

Register end device

To get started, click the blue ‘Add end device’ (it may say ‘Register end device’) button.

Select end device

Select the end device

Select Brand ‘Arduino SA’, then select Model ‘Arduino MKR WAN 1310’ (which works the same as the 1300). Select the newest Hardware Version (click on the dropdown and select the highest number) and the newest Firmware version. This should hopefully match the firmware version you previously updated using the MKRWANFWUpdate_standalone sketch.

Then select the Profile (Region). If you are in Europe, select EU_863_870. The numbers represent the frequency range in MHz that LoRa radio is permitted to use in Europe. The range is different in other parts of the world, so if you are in the US or in Australia, select your local version.


Enter registration data

Enter registration data

Frequency plan – select the recommended option for your region.

AppEUI – click the ‘Fill with zeros’ button. (This is now called the JoinEUI. You can manually fill this field with zeros, just keep typing zeros until the box is full, then click ‘Confirm’.)

DevEUI – this is the ID that copied from the serial monitor when we ran the FirstConfiguration sketch. Copy it (from wherever you have saved it) and paste it into the box. The ID will be split into pairs of numbers and letters as you do so (do not select ‘Generate’).

AppKey – click the ‘Generate’ button.

Device overview page

End Device ID – this is created automatically from the DevEUI you just added. Note: this is no longer automatic, you have to type in your own AppKey. I am using the same format as the form originally used, that is to type ‘eui’ followed by a dash ‘-‘ and then the DevEUI, for example: ‘eui-a8610a3230228616’.

When you have finished, click the blue ‘Register end device’ button.

After pressing the Register button, your board will show up on the Device Overview page. You can now see all the information needed to complete the Arduino setup.




Device overview detail

In our device overview, we can now see three rows: Device EUI, Application EUI and App Key. These contain information that we will need in the next few steps.

Click on the ‘eye’ symbol to see the AppKey.


Connect Your Device to The Things Network (TTN)

You have now registered your device with The Things Network. The next step is to connect your device and upload some data.

Enter the number 1 here

To do this, we need to open the Arduino FirstConfiguration sketch again.

To be safe, reset your board. An easy way to do this is to just unplug the MKR WAN 1300 and then plug it back into your computer. Upload the FirstConfiguration sketch and open the Serial Monitor again.

Once the program starts, it will start asking questions in the serial monitor. The first one is 'are we are using OTAA or ABP'. We will use OTAA (Over The Air Authentication), so we can enter a '1' in the monitor and hit 'send'.

Enter appEUI

And you should see this in the serial monitor.

Now enter your AppEUI copied from the ‘Activation information’ above. You can copy the AppEUI by clicking on the ‘copy’ symbol to the right of the AppEUI box. Paste this into the serial monitor and click ‘Send’.

Enter appKey

Now you will see this.

Now, repeat the process to add the AppKey. Then click ‘Send’. 

Message sent correctly

If all goes according to plan, you will see this.

The last line should say ‘Message sent correctly’. This means that your Arduino is now connected by radio to The Things Network.

You may have to wait a minute or two for this last line to appear.

Something went wrong

If things don’t go according to plan, you will see this.

If you see the ‘Something went wrong’ message, first check you are within range of a TTN gateway, as was explained in the opening paragraphs of this article (click here to check). If you are, then try this:

  • Unplug the MKR WAN 1300 from your computer, and then plug it back in.
  • Open the FirstConfiguration sketch as explained above.
  • Click ‘tools’ in the Arduino IDE and make sure you have the correct port and board selected.
  • Upload the sketch.
  • Open the serial monitor.
  • And hope this fixes it.

Let us assume that you have now managed to connect your device. The message you have just sent (known as a 'payload') just says 'HelLora world!', coded in HEX (hexadecimal code, set to base 16 rather than decimal 10). This can be seen in the 'Live data' tab in the 'End device' overview (you can also click on ‘Live data’ in the left-hand navigation panel).

Live data

Here we can view any incoming data from our device. If the message was sent successfully, it will appear here. Any unsuccessful attempts to connect will also be listed here, with a lightning icon next to it.

The HEX code has been circled in red. If you hover your mouse over this code fragment, you will see the full message (payload). This should be 48654C6F524120776F726C6421. You may also see a ‘copy to clipboard’ icon to the right of the payload, which enables you to copy the message. 

HEX translator

You can translate this by typing this string of letters and numbers into a HEX code translator, such as this one. Try it with the code above.

You will see that it has translated the string into ‘HeLoRa world!’.

We have successfully connected your device to The Things Network and transmitted some test data. To gather meaningful data, the next step involves integrating a sensor with the MKR WAN so that we can take some actual measurements. Click here for the next steps.

© Copyright 2025 Dr Dulcamara - All Rights Reserved