---
# System prepended metadata

title: Kallskänken
tags: [pilotcase]

---

# LoRaWAN Networks 
In this project, Helium and Actility (via Kalmar energy's portal) were used. 


# Table of contents 
[TOC]

## Helium 
Helium uses a low-cost, decentralized network where users pay with Helium tokens to send data. People can buy tokens, or earn them by hosting devices called Hotspots, which provide network coverage. It's a cost-effective and community-driven solution for IoT data transmission.

[Data credit calculator](https://helium.plus/data-credits-calculator)

Since Helium's coverage relies on community members who host Helium Hotspots. The more Hotspots there are in an area, the better the coverage.

[Hotspot map](https://explorer.helium.com/)

### Log in 
1. Make sure that you are logged in to [gmail](https://mail.google.com/) with the adress listed in [Credentials](#Credentials).
3. Go to: https://console-vip.helium.com/
4. Click 'continue with google' and use the gmail adress listed in [Credentials](#Credentials)

### Add device Helium

1. To the left there is a list of options, if not, click on the menu buton in the top left corner.

4. Click on 'Devices' in the list of options to the left.
5. Click on the icon marked with red.![](https://hackmd.io/_uploads/Hy35sY093.png)
6. Give the device a descriptive name.
7. Dev EUI, App EUI and App Key can be found in diferent ways depending in the device.
8. Optional: Add label. Labels allow you to group sensors together and apply the same setings to a whole group.
9. Save device.

### Send downlink

Downlinks can be used to configure some of the sensors. The section [Sensors](#Sensors) describe what should be sent in order to configure the device. 

1. Go to "Devices"
2. Click the device you want to send a downlink to.

4. Click on the icon marked with red. ![](https://hackmd.io/_uploads/Hy85FaO23.png)
5. Enter the payload and the port that it should be sent to. Click the icon marked with red to put the downlink on que to be sent. The downlink will be sent the next time the sensor sends an uplink.
    ![](https://hackmd.io/_uploads/ryxK8G933.png)

### Link device to Datacake

When a device is added, it can be linked to Datacake. The data from the device is sent from Helium to Datacake, were it can be visualised. 
1. Go to "Flows".
2. Click on the pluss sign next to "NODES". ![](https://hackmd.io/_uploads/Sy-1Xw532.png)
3. You will find the device in "Devices" or "Labels", labels can contain many devices.
4. Drag and drop the device out on the work-area.
5. Draw a line between the new device and the existing datacake node. ![](https://hackmd.io/_uploads/S1wQSD9h2.png)

For the data to show up on Datacake, the device needs to be added on Datacake. See [Add device Datacake](#Add-device-Datacake) for instructions.

### Rename Helium device
1. Go to 'Devices'.
2. Click the device you want to rename.
3. Click on the pen icon next to the name. ![](https://hackmd.io/_uploads/HJWVDzKnh.png).

5. Update the name, be careful to remember which device it is.

## Actility

Actility is an IoT connectivity provider offering a platform for connecting and managing Internet of Things devices.

Actility powers [Stadshuben](https://kalmarenergi.se/kalmarstadshubb/) which is an IoT platform provided by Kalmar Energi.


### Portal 
![](https://hackmd.io/_uploads/rJgNpSGAh.png)

It is possible to filter out sensors that are outside a set range on optional channels that the sensors send. The latest sensor value is then also displayed in the map view, as shown in the image below.

![](https://hackmd.io/_uploads/Bk4L6SM0n.png)

To do this, click on `filter channels` in the upper right corner of the map, and select the channel/value you want to filter based on. 
![](https://hackmd.io/_uploads/rytLDUzAh.png)



### API 

It is also possible to use your login credentials (used to log in to Stadshubben) to log in to our API portal - perhaps you will need to complete the registration to be able to access the API portal:

Follow these steps to login to the API portal: 
 
1. Navigate to: https://ke-apim.developer.azure-api.net/ .
2. Click on `sign in`:

![](https://hackmd.io/_uploads/S1lXHKCph.png)

3. Go to Azzure Active Directory B2C, and use the credentials to log in. See the picture:

![](https://hackmd.io/_uploads/Hks4SY0T3.png)

At this stage it is clear. Explore the APIs and see all other endpoints.


To obtain the authentication token through the APIs, one needs to use the Customer Identity API:

 
POST: /v1/resource-owner/token 


When it comes to authentication via HTTPS Request, you must call the following endpoint https://api.kalmarenergi.se/customer-identity/v1/resource-owner/token with the following info in the Request:


- Username: "xxxx"
- Passsword: "yyyy"           
-	responseType: "token id_token"            
-	scope: "openid offline_access https://kalmarenergib2c.onmicrosoft.com/6b6a459a-2596-4213-b42b-153f1e0a9af7/Device.Read.Add"
-	grantType: "passowrd"

Se the image below for an example of how to fetch your token: 

![](https://hackmd.io/_uploads/By6c8If0h.png)

Header is: 

![](https://hackmd.io/_uploads/SJzhULM0n.png)


To refresh the token itself:
POST:  /v1/resource-owner/token 

The payload should be like this:
-	refreshToken: "xxxx"
-	grantType: "refresh_token"



The Node Id can be obtained through the APIs or from the URL which is in the last part of the URL and it starts right after the slash. The user must log in to Stadshubben to go to Nodes and then click on the target node. When the target node's page is opened, the Id can be obtained from the URL. See below:
![](https://hackmd.io/_uploads/Sy-u8YCp2.png)

The node ID for the example above is: 469f0f0f-12fc-440a-81db-56295513151w



#### Device API
- To call all the nodes to see what they have for Id, ChannelId, ModelId, etc. make a GET request on the following endpoint:
GET https://api.kalmarenergi.se/device/v1/nodes 
 
- To call a node to see what it has for Id, ChannelId, ModelId, etc. make a GET Request on the following endpoint:
GET https://api.kalmarenergi.se/device/v1/nodes/{NodeId}
 
 
#### Device Data API
-	To fetch data from a node:
GET https://api.kalmarenergi.se/device-data/v1/message-values?nodeId={NodeId}6&pageIndex=1&pageSize=-1&sortBy=Message.CreatedAt&sortDescending=false&channelIds={ChannelId}&channelIds={ChannelId}&channelIds={ChannelId} 
GET https://api.kalmarenergi.se/device-data/v1/message-values?NodeId={NodeId}
GET https://api.kalmarenergi.se/device-data/v1/message-values?ChannelIds={ChannelId}&NodeId={NodeId} 
 
 
 
#### Device Data Latest API
-	To retrieve only the most recent message (data) that arrived from a node:
GET https://api.kalmarenergi.se/device-data-latest/v1/message-values?nodes={NodeId}&pageIndex=1&pageSize=100
 


# Sensors
There is a large number of sensors available that are LoRa compatible.

## Sensative strips
Strips from Sensative are descrete sensors that are available for a number of use-cases. The ones we use are called +comfort. They have temperature, humidity and ambient light sensors. They can also be used as door sensors. The strips are made for indoor use, but they can handle temperatures between -20 and 60 C, so it could be possible to place them in the fridge.

### Included strips
Six strips are included in the project, each has already been added to a network, Three are on [Helium](#Helium) and the other three on [Actility/Stadshubben](#Actility). The ones connected to Helium are labeled "H1-3". The ones conected to Actility/Stadshubben are labeled "SH1-3". They have also been configured to send relevant data. They should be ready to be installed wherever they are needed. 

### Unpacking new strips 
When the strips are brand new they come with two magnets atatched to them. When the magnets are removed for the first time the strips try to connect to a network. Wait with removing the magnets untill you have added the strips to a network as described in [Add device Helium](#Add-device-Helium). Information needed to add the sensor is included on a sticker inside the box. 

### Configure the strips
When the strips are new, they are set to work as a door sensor only. They need to be configured to read temperature, humidity and ambient light. The sensors are configured by sending a downlink to them. The sensative website has a ['Strips configuration aplication'](https://strips-lora-config-app.service.sensative.net/profiles) that provide the correct payloads to send with the downlinks in order to configure the Strip.
#### Use Strips configuration aplication
1. Go to ['Strips configuration aplication'](https://strips-lora-config-app.service.sensative.net/profiles).
1. Device model is 'Strips multi sensor +comfort'.
2. Select the profile that fits your use case.
3. The generator will describe the selected profile, continue by clicking "proceed". In these steps it is possible to alter the profile, but this can affect the baterylife of the device.
4. In the last step a payload is shown on top of the page. The payload is in hexadecimal form, under the payload is a switch that turns it base 64 encoded. Which format it should be depends on what network is used for the device. ![](https://hackmd.io/_uploads/SJVgNUUs3.png)

6. Send the payload to your device: [Send downlink(Helium)](#Send-downlink).
### Install strips
The strips can be atatched to the wall in a location where measurements are desired. Once they are installed, it could be a good idea to update the name of the strips in [Datacake](#Rename-Datacake-device) and [Helium](#Rename-Helium-device), to something that describes where they are located.
## Sound Sensor
ERS sound is measuring sound and also many other things like temperature, humidity, light intensity.

### Installation 
Remove the back panel of the sensor to install the two batteries. the type of batteries is 3.6V lithium AA.

### Sensor Configuration 
All sensor settings can be configured via a smartphone application with NFC or over the air via the network server and downlink data to the sensor.

#### NFC configuration
1. Download ELSYS “Sensor Settings” application from Google Play and install it on a smartphone or tablet. The device must support NFC.
2. Enable NFC on the device and start the application.
3. Place your device on top of the NFC antenna on the sensor.
4. Remove the device. Current settings will be displayed in the application.
5. Use the application to change any settings if needed.
6. Quickly tap the device on top of the NFC antenna to give the new settings to the sensor. Make sure that the application confirms your new settings.
7. Wait for the sensor to reboot (5 sec), indicated by the LED flashing. Sensor settings have been updated.

#### Over the air configuration
All settings may be configured over the air via your LoRaWAN® infrastructure.
Please visit the support section on this [webpage](https://www.elsys.se/en/downlink-generator/) for more information regarding downlink protocol. The generator creates a downlink that can be sent to the device, for example via [Helium](#Send-downlink).


### Application parameters
All parameters for the “Sensor settings” application can be found in the settings
document. 
Please visit the support section on this [webpage](https://www.elsys.se/en/application-settings/) for more information.

# Data Visualisation
Datacake was used to visualise data from the sensors on the helium network. To see the visualised data click on a device, or on a dashboard.


## Login

1. Go to https://app.datacake.de/login
2. Use the emailadress and password listed in [Credentials](#credentials)![](https://hackmd.io/_uploads/SJM4kbY33.png)

## Add device Datacake

1. Go to devices and click "+ Add Device"

3. Select "LoRaWAN" and click "Next".
4. Select "New Product from template"
5. Search and see if there exist a template for the device. ![](https://hackmd.io/_uploads/H1w58wqh2.png)
6. Select the corect template, click "Next".
7. Select the network that the device is connected to, for example Helium. Click "Next"
8. Add det device by writing its DevEUI, and giving it a name. It can also be given a Location, for example "Dining area".
9. It is possible to add several devices at once by clicking "+ Add another device".

## Rename Datacake device

1. Go to 'Devices'.

3. Click the device you want to rename.
4. Click "configuration". ![](https://hackmd.io/_uploads/r17wYzYn3.png)
5. Update the name, be careful to remember which device it is.
6. Save!

## Dashboards

Datacake allows you to create dashbords where the data from the sensors can be visualised. For this project, two dashbords hes been created: "Kallskanken history" and "Kallskänken live" . 

### Create Dashbords

1. Click "+Add Dashboard" in the menu to the laft.

3. Name the dashboard and decide who gets access to it.
4. To edit the dashboard, click the icon marked with red. ![](https://hackmd.io/_uploads/Syjbozc2h.png)
5. Click "Add Widget" to explore what can be added to the dashboard and how the data can be visualised.

Tip: A good way to learn what can be done is to edit existing dashboards and investigate the widgets that are already set up there. ![](https://hackmd.io/_uploads/rkKuYIc3h.png)


# Linking to google sheets
If you want to use your data, you can have it on google sheets. You can then consult them easily and do what you want with them.
## How it works
We collect the data from the portal and then process it with a decoder to send it.

The decoder is a code that takes a part of the data called the "payload" and processes it to extract the desired value.

Before receiving the data in the document, we need to use a questionnaire. In this case, we are using google forms in which we have to put questions for each piece of data we want to obtain.

![](https://hackmd.io/_uploads/rk9CEX0a2.png)

Then google forms will transfer the data to google sheets.

## Example of datas
Here's what you'll see on the google sheets: Date, Temperature, Light and Humidity.
Sometimes some data is missing because it hasn't changed since the last measurement.

![](https://hackmd.io/_uploads/BJEyjfRTn.png)




# Credentials
Credentials needed to manage the sensors on the previously mentioned platforms.
## Gmail
**adress:** lnu.kallskanken.iot@gmail.com
**password:** IoT-123-



