> For the complete documentation index, see [llms.txt](https://irnas.gitbook.io/opencollar/-MDJCI9OmpOqWrQzjNIR/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://irnas.gitbook.io/opencollar/-MDJCI9OmpOqWrQzjNIR/manufacturing/provisioning.md).

# Provisioning

## Registering the device

In VS Code open your folder with the latest firmware and other files.

![](https://264302523-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MAfxKpHe9the60UYjxl%2F-MGbGTq4qKVas6wTW9RC%2F-MGbJM5i4fbPmJFLaFMn%2Fimage.png?alt=media\&token=1931d04c-15c1-4dc6-82d6-a30de3496484)

### Step 1

In "config.yml" define the application ID in line 2 and firmware to upload in line 6 (name.dfu).

![](https://264302523-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MAfxKpHe9the60UYjxl%2F-MGbGTq4qKVas6wTW9RC%2F-MGbjL1GYDgaTBTxFw67%2Fimage.png?alt=media\&token=64c8f2f0-d0bf-44ae-b7d5-ba3174f3d1de)

### Step 2

To get the access code for TTN Console open "main.py" and ctrl+click on the link in line 18.

![](https://264302523-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MAfxKpHe9the60UYjxl%2F-MGbGTq4qKVas6wTW9RC%2F-MGbjp4f8KQo9nPQPzJN%2Fimage.png?alt=media\&token=7dcd7ac4-165b-4dac-a877-9c286845c3e9)

## The Things Network Console

### Step 3

Copy the access code in yellow.

![](https://264302523-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MAfxKpHe9the60UYjxl%2F-MGbGTq4qKVas6wTW9RC%2F-MGbK_zOEx7GbCBGbc9e%2Fimage.png?alt=media\&token=9d25b364-11f8-4652-9de3-7f68cba89fb6)

### Step 4

In VS Code open new Terminal and type or copy the following line with the access code and press enter.

```
python main.py --type abp --key "TTNCTL ACCESS CODE" --dtc 4 --ads_calib 1
```

If you want to manually provision the device with OTAA, use the following line with correct values

```
python main.py --type otaa-manual --appkey "KEY" --deveui "DEV" --appeui "APP"
```

### Step 5

Connect STM32 Nucleo to Tag connect programmer adapter.&#x20;

![](https://264302523-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MAfxKpHe9the60UYjxl%2F-MGbGTq4qKVas6wTW9RC%2F-MGbgJpkzvVh4OrVH7aO%2FIMG_20200828_100222.jpg?alt=media\&token=1f09628e-48a6-4cf5-9585-acde78f388de)

Enter device name to register and wait for the process to finish.

{% hint style="info" %}
Device name can NOT be changed in The Things Network Console.
{% endhint %}

![](https://264302523-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MAfxKpHe9the60UYjxl%2F-MGbGTq4qKVas6wTW9RC%2F-MGbKwyiOnfEyrLYgbpw%2Fimage.png?alt=media\&token=3b35d63a-76e5-4722-80d0-84c14c68a264)

## Testing the device

### Step 6

In The Things Network Console go to device overview to change settings.

> Applications -> "Application ID" -> Devices -> Device name

Send confirmed payload with settings to port 3. Under payload choose "fields" and copy the following settings.

#### GPS active (interval 1min)

{% hint style="success" %}
{"system\_status\_interval": 1, "system\_functions": {"accelerometer\_enabled": false, "light\_enabled": false, "temperature\_enabled": false, "humidity\_enabled": false, "charging\_enabled": true}, "lorawan\_datarate\_adr": {"datarate": 3, "confirmed\_uplink": false, "adr": false}, "gps\_periodic\_interval": 1, "gps\_triggered\_interval": 0, "gps\_triggered\_threshold": 10, "gps\_triggered\_duration": 10, "gps\_cold\_fix\_timeout": 200, "gps\_hot\_fix\_timeout": 60, "gps\_min\_fix\_time": 1, "gps\_min\_ehpe": 50, "gps\_hot\_fix\_retry": 5, "gps\_cold\_fix\_retry": 20, "gps\_fail\_retry": 0, "gps\_settings": {"d3\_fix": true, "fail\_backoff": false, "hot\_fix": true, "fully\_resolved": false}, "system\_voltage\_interval": 1, "gps\_charge\_min": 2500, "system\_charge\_min": 3450, "system\_charge\_max": 4000, "system\_input\_charge\_min": 10000, "pulse\_threshold": 3, "pulse\_on\_timeout": 60, "pulse\_min\_interval": 1, "gps\_accel\_z\_threshold": 0}
{% endhint %}

![](https://264302523-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MAfxKpHe9the60UYjxl%2F-MGbGTq4qKVas6wTW9RC%2F-MGbfJ1hgjssLJdUfq2s%2Fimage.png?alt=media\&token=d1b44eb5-4359-4ad0-b1e1-19b7d62ebdba)

Go to Application Data. Wait for settings to be applied (green checkmark and "confirmed ack") and check the next message on port 12 for any errors.

{% hint style="info" %}
To speed up the process of applying settings you can manually reset the device.
{% endhint %}

![](https://264302523-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MAfxKpHe9the60UYjxl%2F-MGbGTq4qKVas6wTW9RC%2F-MGbfMAAid8n1WvOrtTs%2Fimage.png?alt=media\&token=f504c46e-e6fe-43f6-bdad-c18e1debea3b)

![](https://264302523-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MAfxKpHe9the60UYjxl%2F-MGbGTq4qKVas6wTW9RC%2F-MGbff316EW7b-uucGKj%2Fimage.png?alt=media\&token=9b086e58-4ba9-4183-81c4-cecc2a9a472e)

### Step 7

To test the GPS function put the device outside. GPS antenna should face upside as seen on the following image.

![](https://264302523-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MAfxKpHe9the60UYjxl%2F-MGbGTq4qKVas6wTW9RC%2F-MGbgPrYTPnvOQt14Iux%2FIMG_20200828_093630.jpg?alt=media\&token=44a0c959-4ce3-4db3-811e-2d6dedcb6dc0)

![](https://264302523-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MAfxKpHe9the60UYjxl%2F-MSRxwECVp3X0VNHIpZa%2F-MSS-EudPNk6_4fml3rT%2FIMG_20201009_084614.jpg?alt=media\&token=0515700d-5b45-4fc0-8250-2cb35f335663)

![](https://264302523-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MAfxKpHe9the60UYjxl%2F-MGbGTq4qKVas6wTW9RC%2F-MGbflAOiHtiVTBNlCt4%2Fimage.png?alt=media\&token=20614294-e88a-4657-aea9-cdf70501c1aa)

## Device sleep

### Step 8

When you are happy with the results, change settings to save battery. Repeat step 6 with following settings

#### Device sleep:

{% hint style="success" %}
{"system\_status\_interval": 30, "system\_functions": {"accelerometer\_enabled": false, "light\_enabled": false, "temperature\_enabled": false, "humidity\_enabled": false, "charging\_enabled": true}, "lorawan\_datarate\_adr": {"datarate": 3, "confirmed\_uplink": false, "adr": false}, "gps\_periodic\_interval": 0, "gps\_triggered\_interval": 0, "gps\_triggered\_threshold": 10, "gps\_triggered\_duration": 10, "gps\_cold\_fix\_timeout": 200, "gps\_hot\_fix\_timeout": 60, "gps\_min\_fix\_time": 1, "gps\_min\_ehpe": 50, "gps\_hot\_fix\_retry": 5, "gps\_cold\_fix\_retry": 20, "gps\_fail\_retry": 0, "gps\_settings": {"d3\_fix": true, "fail\_backoff": false, "hot\_fix": true, "fully\_resolved": false}, "system\_voltage\_interval": 30, "gps\_charge\_min": 2500, "system\_charge\_min": 3450, "system\_charge\_max": 4000, "system\_input\_charge\_min": 10000, "pulse\_threshold": 3, "pulse\_on\_timeout": 60, "pulse\_min\_interval": 1, "gps\_accel\_z\_threshold": 0}
{% endhint %}

![](https://264302523-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MAfxKpHe9the60UYjxl%2F-MGbGTq4qKVas6wTW9RC%2F-MGbfscVhIbcTzEDFk8t%2Fimage.png?alt=media\&token=b398563f-45b3-4ed9-92f0-3413891981eb)

Next message on port 3 should show values 30 for "system\_status\_interval" and "system\_voltage\_interval".

![](https://264302523-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MAfxKpHe9the60UYjxl%2F-MGbGTq4qKVas6wTW9RC%2F-MGbftw1epNnLMmTDo8w%2Fimage.png?alt=media\&token=2aa37dfa-e35f-4b9a-b4ce-aaa0aff52b43)

## Initial provisioning

![](https://264302523-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MAfxKpHe9the60UYjxl%2F-MKiJ0xR_Lq8k5n-_wTk%2F-MKiJj_48jkIva3gf4fK%2FIMG_20201014_142904.jpg?alt=media\&token=7a942717-b953-4d5f-9944-8f68aec55a40)

![](https://264302523-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MAfxKpHe9the60UYjxl%2F-MKiJ0xR_Lq8k5n-_wTk%2F-MKiJmKMltltkZSf3Tvq%2FIMG_20201023_142304.jpg?alt=media\&token=13aaab74-d747-47b5-8b4c-9ba437a513e8)
