# Marvin development board

This is an old development board which is no longer available for purchase and should not be used for new designs.

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

![](https://1453626848-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl6RrePMSAjRvOgcHjMBZ%2Fuploads%2FPOMP5mP8EhIbEDr3xzNs%2Fimage.png?alt=media\&token=ce175be0-d789-482e-84e8-706b7dcc0e58)

## 1. Setup your Marvin&#x20;

> This part of the getting started is based on the [Getting Started by the IoT Academy](https://github.com/iotacademy/marvin/tree/master/Software#getting-started).

### 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 Marvin.
* Connect your Marvin to your computer.

### Test your Marvin device

We will now test whether the Marvin device is working by letting a LED blink.

* Download [blinky.ino](https://github.com/iotacademy/marvin/blob/master/Software/MarvinBlink/MarvinBlink.ino) and open it in the Arduino IDE, or copy-paste the code into an empty Arduino IDE sketch.
* From the **Tools** menu, under **Board**, select **Arduino Leonardo**

<figure><img src="https://1453626848-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl6RrePMSAjRvOgcHjMBZ%2Fuploads%2FPh17LBd4GaOxSrbKJTRN%2Fimage.png?alt=media&#x26;token=8ef3891e-7e98-4c8a-aff4-3cab24eeea04" alt=""><figcaption></figcaption></figure>

* 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 Leonardo*. If non of your ports is labelled that way, disconnect your Marvin, reopen the menu, check which COM port disappeared, reconnect the Marvin and choose the previously identified COM port.
* From the **Sketch** menu, click **Upload** to send the software to the Marvin. If all went well it will say *Uploading complete* in the bottom of the Arduino IDE and *the second LED* on the Marvin board will blink!

<figure><img src="https://1453626848-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl6RrePMSAjRvOgcHjMBZ%2Fuploads%2FeUfQ2FDV6aVLTl32Of1W%2Fimage.png?alt=media&#x26;token=c0c1aa67-776b-46cf-8eb3-aabec6f64b71" alt=""><figcaption></figcaption></figure>

### Test the LoRa module on the Marvin

The LoRa connectivity on your Marvin device is managed by the Microchip RN2483 module. With the following steps we check whether this module works correctly.

* Download [MarvinMultiSerial.ino](https://github.com/iotacademy/marvin/blob/master/Software/MarvinMultiSerial/MarvinMultiSerial.ino) and open it in the Arduino IDE, or copy-paste the code into an empty Arduino IDE sketch. With this program we can communicate directly with the LoRa module.
* **Upload** the sketch to your Marvin.
* Meanwhile, from the **Tools** menu, open the Serial Monitor

<figure><img src="https://1453626848-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl6RrePMSAjRvOgcHjMBZ%2Fuploads%2FTquWmgbDo9aTHv2E9JKB%2Fimage.png?alt=media&#x26;token=e8fca42d-8e99-4452-9df4-a007afd8993d" alt=""><figcaption></figcaption></figure>

* In the Serial Monitor, set the baud rate to **57600 baud** (same as detailed in the sketch) and select **Both NL & CR** (#1 in the screenshot below).

<figure><img src="https://1453626848-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl6RrePMSAjRvOgcHjMBZ%2Fuploads%2Fr30oHhwbf2U3wIVeFGOR%2Fimage.png?alt=media&#x26;token=b66e23ed-d976-4eab-80f2-3c35f15aba48" alt=""><figcaption></figcaption></figure>

Now you can directly speak to the LoRa module and get a response! #2 in the screenshot above shows you where to enter commands you want to send, and #3 highlights where answers from the module will be shown.

* If you for instance send `sys get ver`, the module will return its firmware version back. This will be 1.0.1 with some historic date.
* Now execute the command `sys get hweui` to retrieve the DevEUI that is stored in the module. **Store the value in a text file**. You'll need it when adding the device to KPN Things.

Possible other commands can be find in the module [data sheet](https://ww1.microchip.com/downloads/en/DeviceDoc/40001784B.pdf) or in [one of the many](https://www.disk91.com/2015/technology/networks/first-step-in-lora-land-microchip-rn2483-test/) [examples](https://thinginnovations.uk/getting-started-with-microchip-rn2483-lorawan-modules) [by others](http://kotahi.net/configure-microchip-rn2483-module/).

## 2. Register your Marvin to KPN Things

### Open the KPN Things Portal

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

<figure><img src="https://1453626848-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl6RrePMSAjRvOgcHjMBZ%2Fuploads%2Ft7xoI5lo7RRxIDsVG9eI%2Fimage.png?alt=media&#x26;token=43e4e831-5c39-47fa-a877-80423227e90f" alt=""><figcaption></figcaption></figure>

### Fill in your device information

1. Select the **Own LoRa device (preset connectivity)** device type
2. **Enter a name** for your Marvin device
3. Click **Add Device** to continue

<figure><img src="https://1453626848-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl6RrePMSAjRvOgcHjMBZ%2Fuploads%2FCx3A0pGSh3u1JCtyaflL%2Fimage.png?alt=media&#x26;token=28281403-5dc2-4d84-b416-6d27c4b70594" alt=""><figcaption></figcaption></figure>

### Provide Network Information

1. **DevEUI**: the value you retrieved from the LoRa module in the step [*Test the LoRa module on the Marvin*](#test-the-lora-module-on-the-marvin)*.*
2. **AppEUI:** you can use the following value: `0059AC00000FFFFF`
3. **AppKey**: Every device should have its own unique AppKey, since it is the root security key of your device. You can generate a unique AppKey here: <https://www.loratools.nl/#/keys>

Store these three values somewhere, because you will be needing them to program your device later on.

4\. Click **Add Network Info** to save the network information and then **Finish** to continue.

<figure><img src="https://1453626848-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl6RrePMSAjRvOgcHjMBZ%2Fuploads%2FWTboGjKvi1eurg1L9lEf%2Fimage.png?alt=media&#x26;token=70df57b9-828f-4c8c-8c82-e41733185bf9" alt=""><figcaption></figcaption></figure>

### Check your newly created Device

You are now on the Device Detail Page. In the LoRa tab you will see the **network status**. This can temporarily be *Pending creation*, but if you refresh the page it should switch to *Active*. This means your device is correctly registered to the network.&#x20;

If the network status sticks to *Pending creation*, you could try to delete the Device and and provision again (Restart at step [Register your Marvin to KPN Things](#2.-register-your-marvin-to-kpn-things)).

{% hint style="danger" %}
If the Network Status ended up in **Failed**, something has gone wrong. Most likely the DevEUI is already registered through another application like Thingpark or the LoRa Developer Portal. Please make sure you remove the device registration from the other application and re-add the device in the Things Portal. For more information consult our [FAQ](https://docs.kpnthings.com/kpn-things/getting-started/frequently-asked).
{% endhint %}

## 3. Program your device to send a LoRa message

### Download the ThingsML library

* From the **Tools** menu in your Arduino IDE click on **Manage Libraries...**

<figure><img src="https://1453626848-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl6RrePMSAjRvOgcHjMBZ%2Fuploads%2FxawzcFmcl2qTpMvC7Gp4%2Fimage.png?alt=media&#x26;token=95183c23-9e00-4601-9ed1-1f4af2b207ec" alt=""><figcaption></figcaption></figure>

* Now, in the **Library Manager**, search for ThingsML and click **Install**. When the installation is finished, click **Close**.

<figure><img src="https://1453626848-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl6RrePMSAjRvOgcHjMBZ%2Fuploads%2F1bpklG3ukZuMJfOOaK2j%2Fimage.png?alt=media&#x26;token=f69dbf52-c621-430e-a6e2-654690c100a6" alt=""><figcaption></figcaption></figure>

### Make a sketch

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

* Now find **ThingsML**, then select **marvin,** and within that choose **marvin\_example**, as such:

<figure><img src="https://1453626848-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl6RrePMSAjRvOgcHjMBZ%2Fuploads%2F7cXXIdTd3VKyzNFykIWL%2Fimage.png?alt=media&#x26;token=45f7021c-d33e-48a1-b214-53b16e22c0b4" alt=""><figcaption></figcaption></figure>

* A sketch will open. Now update the values for the variables `DevEUI`, `AppEUI`, and `AppKey` in the code with the values you entered earlier in the Portal.

<figure><img src="https://1453626848-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl6RrePMSAjRvOgcHjMBZ%2Fuploads%2FsbZ5ooaFXdB4K4uXQej9%2Fimage.png?alt=media&#x26;token=8afcfb9b-693b-4504-92d9-1c5e858603d2" alt=""><figcaption></figcaption></figure>

### Run the sketch

* **Upload** the sketch to your Marvin and open the **Serial Monitor**. You will see a lot of commands being send to the LoRa module to configure it and to join the network. At some point you will see the following:

```
> mac join otaa
< ok
```

This means your Marvin is trying to join the network. After some seconds the following line will appear

```
< accepted
```

This means the device has joined our network!&#x20;

If you see `denied` instead of `accepted` , move closer to your window or walk out into the garden to improve reception from the LoRa network. Then disconnect and reconnect the Marvin to your computer. You probably need some more coverage to be able to join the network.

After joining, your Marvin will send a message every 30 seconds containing an empty temperature measurement in ThingsML format. Read more about [ThingsML](https://docs.kpnthings.com/kpn-things/building-blocks/data-processing/thingsml-and-senml/thingsml).

## 4. Check incoming data in the Portal

Now your Marvin has joined and is sending data, you could visit the **LoRa Data** tab on your **Device Detail Page** in the Portal. You should see your Join request and Join accept appear like in the screenshot below and at this point you will see more data as well. Learn more about [LoRa data history](https://docs.kpnthings.com/kpn-things/building-blocks/connectivity/connecting-lora-devices#lora-data-history).

<figure><img src="https://1453626848-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fl6RrePMSAjRvOgcHjMBZ%2Fuploads%2FU1MbDXsZptTVBvuQ7rmo%2Fimage.png?alt=media&#x26;token=694f8011-14dc-4eb2-a737-2b46f7c5dccb" alt=""><figcaption></figcaption></figure>

## Setup data flow in KPN Things

You now successfully connected your Marvin device to KPN Things! To further setup your data flow in KPN Things, you can go to the next step:


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.kpnthings.com/kpn-things/getting-started/tutorials/connect-devices/marvin-development-board.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
