# Arduino MKR NB 1500

Arduino MKR NB 1500 is the fastest start with LTE-M and the Internet of Things. It’s the perfect introduction to IoT for your organization, and is also used in education. Arduino MKR NB 1500 uses its LTE-M connectivity to connect to the internet from anywhere in the world where there is LTE-M coverage.

{% hint style="info" %}
When ordering the Arduino MKR NB 1500 make sure that an antenna is included in the order since it's not delivered with the board
{% endhint %}

<figure><img src="https://1453626848-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl6RrePMSAjRvOgcHjMBZ%2Fuploads%2Fro0pY04LktPSHimlcJKt%2Fimage.png?alt=media&#x26;token=8f3a6739-c1a7-4cca-9c9d-cf8fee94d02d" alt="" width="188"><figcaption></figcaption></figure>

Before you can start you need a KPN simcard. You can order 2 free cards via <https://portal.kpnthings.com/home>

On this page you will find the window below to order a simcard.

<div align="left"><figure><img src="https://1453626848-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl6RrePMSAjRvOgcHjMBZ%2Fuploads%2FOpsahGmrwnixGFc6pnuR%2FSIMKaart_aanvraag.png?alt=media&#x26;token=c81cc5b6-df85-494e-a809-6e878ad58ed2" alt=""><figcaption></figcaption></figure></div>

## 1. Setup your Arduino MKR NB 1500

> To connect the Arduino MKR NB 1500 to the computer you must use a USB cable.

### Setup your Arduino environment

* Download the [Arduino IDE](https://www.arduino.cc/en/Main/Software) and follow the installer. We'll use it later on to program the Arduino MKR NB 1500.
* Connect your Arduino MKR NB 1500 to your computer.
* From the Tools menu, under Board, under Arduino SAMD boards (32-bits ARM Cortex M0+), select Arduino MKR NB 1500.

<div data-full-width="false"><figure><img src="https://1453626848-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl6RrePMSAjRvOgcHjMBZ%2Fuploads%2FlSkdIx7MUXrKICgxfDfj%2FPicture2.png?alt=media&#x26;token=abaa1634-20c9-4298-af0f-08991c33c5b5" alt=""><figcaption></figcaption></figure></div>

* If the board is not available go to Tool menu, under Board select Board Manager and search for the Arduino SAMD boards (32-bits ARM Cortex M0+). Click install to install the board.
* Also from the Tools menu, under Port, make sure the correct COM port is selected. If you have multiple options, select the one stating Arduino MKR NB 1500. If non of your ports is labelled that way, disconnect your Arduino MKR NB 1500, reopen the menu, check which COM port disappeared, reconnect the Arduino MKR NB 1500 and choose the previously identified COM port.

### Test your Arduino MKR NB 1500 device

We will now test whether the Arduino MKR NB 1500 device is working by letting a LED blink.

* In the Arduino IDE go to File, under Examples, under 01. Basics, select Blink.
* From the Sketch menu, click Upload or select the big arrow on de left of the Arduio IDE to send the software to the Arduino MKR NB 1500. If all went well it will say Uploading complete in the bottom of the Arduino IDE and the LED on the Arduino MKR NB 1500 board will blink!

![](https://1453626848-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl6RrePMSAjRvOgcHjMBZ%2Fuploads%2Fp0qCM0BZAhJhkBF75w6o%2FPicture3.png?alt=media\&token=e3cd82c5-6725-4ff4-8dc2-a3d1a899686f) ![](https://1453626848-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl6RrePMSAjRvOgcHjMBZ%2Fuploads%2F2NJOgh6ZSrdJz6ZY7K4A%2FPicture4.png?alt=media\&token=b6e83e61-a8a3-44d5-aff0-e2e739943a88)

### Test the LTE-M module on the Arduino MKR NB 1500

The LTE-M connectivity on your Arduino MKR NB 1500 device is managed by the uBlox SARA-R410M-02B module. With the following steps we check whether this module works correctly.

* In the Arduino IDE select from the sketch menu, under Include Library select Manage Libraries or click on the library icon on the left side of the IDE. Search for MKRNB and select the 1.6.0 version.

![](https://1453626848-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl6RrePMSAjRvOgcHjMBZ%2Fuploads%2FhPpBkMLtXcswbPHpzYGo%2FPicture5.png?alt=media\&token=2610c794-516f-4480-b089-32cb18634f81)&#x20;

* After the library is downloaded go to File, under Examples, under MKRNB select Tools and select TestModem.

<figure><img src="https://1453626848-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl6RrePMSAjRvOgcHjMBZ%2Fuploads%2FcbRQxHQQ540e6wCD3Fqe%2FPicture6.png?alt=media&#x26;token=a9ee6470-d5bb-4d8e-bc79-b2da7c927d40" alt=""><figcaption></figcaption></figure>

* Upload the sketch to the Arduio MKR NB 1500.
* Meanwhile, from the **Tools** menu, open the Serial Monitor. Here we will find the unique IMEI. **Store the value in a text file**. You'll need it when adding the device to KPN Things.

<div align="left"><figure><img src="https://1453626848-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl6RrePMSAjRvOgcHjMBZ%2Fuploads%2FGlQJ5ameeHLx8yyewkEc%2FPicture7.png?alt=media&#x26;token=b88e9cbf-3eb4-481c-9ddd-7aad2d305061" alt=""><figcaption></figcaption></figure></div>

## 2. Register your Arduino MKR NB 1500 to KPN Things

### Add device

Open the [KPN Things Portal](https://portal.kpnthings.com). Go to the **All Devices** page and click on **Add new Device**.

<div align="center" data-full-width="false"><figure><img src="https://1453626848-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl6RrePMSAjRvOgcHjMBZ%2Fuploads%2FXCyJjZd24Tiuw2UcfPwq%2FPicture8.png?alt=media&#x26;token=51d9b298-a794-4e32-bbb3-561af32c85f3" alt=""><figcaption></figcaption></figure></div>

1. Select the **Own M2M device** device type&#x20;

   <div align="center" data-full-width="true"><figure><img src="https://1453626848-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl6RrePMSAjRvOgcHjMBZ%2Fuploads%2FupblCwt56LnagHUk6wIU%2FPicture9.png?alt=media&#x26;token=85013dd4-3562-4c07-b4c9-1c593dce72f4" alt=""><figcaption></figcaption></figure></div>
2. **Enter a name** for your Arduino MKR NB 1500 device
3. Click **Add Device** to continue

### Provide network information

<figure><img src="https://1453626848-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl6RrePMSAjRvOgcHjMBZ%2Fuploads%2FZEbVKUu5xDOmPPT85JkS%2FKPNThings_add_M2M_device.png?alt=media&#x26;token=38f55512-caba-4d9d-b39f-8e516bce0bbd" alt=""><figcaption></figcaption></figure>

1. **IMEI**: the value you retrieved from the Ublox module in the step Test the LTE-M module on the Arduino MKR NB 1500
2. **ICCID:** you must use the ICCID form the simcard you ordered via KPNThings:
3. **Shared secret**: Every device should have its own unique shared secret You can generate a unique secret by pressing Generate:

{% hint style="info" %}
Store these three values somewhere, because you will be needing them to program your device later on.
{% endhint %}

### Check your newly created Device

You are now on the Device Detail Page. On this page you can see the **network status**. If everything is done the status should be *Activated*. This means your device is correctly registered to the network.

### Create a flow

To receive data in the KPNThings portal you must create a flow. Click on Flows and  then on Link to another Flow.

<figure><img src="https://1453626848-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl6RrePMSAjRvOgcHjMBZ%2Fuploads%2FBbdUM2SgrfOSW09W4Lk2%2FPicture10.png?alt=media&#x26;token=d4968e83-72a3-4764-938b-ce69e3f17251" alt=""><figcaption></figcaption></figure>

Select My first Flow.

<figure><img src="https://1453626848-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl6RrePMSAjRvOgcHjMBZ%2Fuploads%2Fjz8V7fcgyVhZA50BJcf3%2FPicture11.png?alt=media&#x26;token=49e284ad-8fde-4750-9d64-5b62fa3843af" alt=""><figcaption></figcaption></figure>

### Enable the ThingsML decoder

The flow is now created and you must add a decoder to the flow to decode the payloads from the device.

Click on  **My first flow**.&#x20;

<figure><img src="https://1453626848-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl6RrePMSAjRvOgcHjMBZ%2Fuploads%2FYdbZQXyRWtT0biU7gktD%2FPicture12.png?alt=media&#x26;token=e0ddd062-5236-4f94-ac79-e55d4d436fb0" alt=""><figcaption></figcaption></figure>

Click on **Data Processing**

<figure><img src="https://1453626848-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl6RrePMSAjRvOgcHjMBZ%2Fuploads%2FhPMsqiJdaQOigAs62kCf%2FPicture13.png?alt=media&#x26;token=e981b1a4-4844-4983-b6ef-8ff608945233" alt=""><figcaption></figcaption></figure>

Enable the switch **Decoded ThingsML** **and raw SenML data (v2)**.

<figure><img src="https://1453626848-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl6RrePMSAjRvOgcHjMBZ%2Fuploads%2FfkIMbFuusUIyiP577l2N%2FPicture14.png?alt=media&#x26;token=92724c63-bfb0-4ca6-b61c-6363f8d6715f" alt=""><figcaption></figcaption></figure>

The decoder is now enabled and device data send by the Arduino MKR NB 1500 will be decoded and visible in the Device twin.

### Add a destination

The decoded data can be send to a destination. For testing you can use the KPN Test Endpoint destination.

Click on **Destination** on the left side on the screen, next click on **Add new Destination** in the upper right side of the screen.

<figure><img src="https://1453626848-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl6RrePMSAjRvOgcHjMBZ%2Fuploads%2FvDsYnVC5BEPD6jBX7Xif%2FPicture15.png?alt=media&#x26;token=8a2746dd-f5ef-439f-9839-bb74900eef69" alt=""><figcaption></figcaption></figure>

Select the **Test Endpoint** destination. Give it a name and click on **Create Test Endpoint**. The endpoint is created and there is a button and link to view the destination. Later the endpoint can always be accessed via the destination menu option on the left side of the main screen.

### Program your device to send a message

#### Install the ThingsML and TemperatureZero library

**·**         From the **Sketch** menu in your Arduino IDE click on Include Library, **Manage Libraries... or click on the library icon on the left side of the IDE.**

<div align="left"><figure><img src="https://1453626848-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl6RrePMSAjRvOgcHjMBZ%2Fuploads%2FLcXUuYEbf88BKt827Zks%2FPicture16.png?alt=media&#x26;token=897cbad2-2cb1-4657-83c9-b805317efa9f" alt="" width="375"><figcaption></figcaption></figure></div>

Now, in the **Library Manager**, search for ThingsML and click **Install**.

Search for TemperatureZero and click install. When the installation is finished, click on the Library manager icon to close the left window.

<div align="left"><figure><img src="https://1453626848-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl6RrePMSAjRvOgcHjMBZ%2Fuploads%2FEADxNTWntuNzcLSCdKZM%2FThingsml_Arduino_lib.png?alt=media&#x26;token=ef56a043-f16f-4100-955b-71d1ea043b86" alt="" width="345"><figcaption></figcaption></figure> <figure><img src="https://1453626848-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl6RrePMSAjRvOgcHjMBZ%2Fuploads%2FrShTNuTkI2oIoK0KH859%2FTemperaturezero_Arduino_lib.png?alt=media&#x26;token=885f89aa-2d7a-49c0-adee-99cf620cd934" alt="" width="343"><figcaption></figcaption></figure></div>

### Upload a sketch

From the **File** menu, click on **Examples.**

Now find **ThingsML**, then select Arduino, **MKR\_NB\_1500,** and within that choose **mkr\_nb\_1500\_uplink\_example.**

<figure><img src="https://1453626848-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl6RrePMSAjRvOgcHjMBZ%2Fuploads%2FuadTs8uYgVHsS3o039c6%2FArduino_MKR_NB_1500_example.png?alt=media&#x26;token=c30c4b2e-1f81-44ba-b76f-27e33552253c" alt=""><figcaption></figcaption></figure>

A sketch will open. Now update the values for the variables `IMEI`, and `shared secret` in the code with the values you get earlier from the device and the KPNThings.

<div align="left"><figure><img src="https://1453626848-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl6RrePMSAjRvOgcHjMBZ%2Fuploads%2F7WOElW2TSZIaIGkx1AUn%2FDevice_URN_and_key.png?alt=media&#x26;token=604e94d7-0ecb-4b3f-a872-7396d6871ec4" alt=""><figcaption></figcaption></figure></div>

### Run the sketch

**Upload** the sketch to your Arduino MKR NB 1500 and open the **Serial Monitor**. You will see the AT commands and some other information. Check incoming data in the Portal.

Now your Arduino MKR NB 1500 is sending data, you could visit the **Device twin** tab on your **Device Detail Page** in the Portal. You should see the measured temperature.

<figure><img src="https://1453626848-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl6RrePMSAjRvOgcHjMBZ%2Fuploads%2FnnGoWXIjJ7ug8vukeMs8%2FDevice_twin.png?alt=media&#x26;token=51def42d-24ec-4561-9dd7-664a430abaac" alt=""><figcaption></figcaption></figure>

If the Test endpoint was setup the data from de device is also visible there.

<figure><img src="https://1453626848-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl6RrePMSAjRvOgcHjMBZ%2Fuploads%2FM0DbX5Mz9X0VjrYalWcV%2FKPN_test_endpoint.jpg?alt=media&#x26;token=a62de1f4-1354-4137-94ff-53ef7db0b4a4" alt=""><figcaption></figcaption></figure>
