Skip to content

hello-nrfcloud/kartverket-vasstand

Custom sensor data on hello.nrfcloud.com/map

GitHub Actions semantic-release Renovate @commitlint/config-conventional code style: prettier ESLint: TypeScript

Publishes the seawater levels from kartverket.no as custom devices on hello.nrfcloud.com/map.

This project serves as an example of how arbitrary device data can be visualized on hello.nrfcloud.com/map by leveraging LwM2M data objects.

To describe the seawater level readings, the object 14230 has been registered in the protocol repository.

In addition, the device has been described in the model definition kartverket-vasstandsdata in the same repository.

For each water level station (e.g. BGO or TRD) a device has been registered.

Using the credentials created during the registration process, the code in this repository now connects to the API for water level data and fetches the most recent measurements.

The measurements are then converted to the LwM2M object 14230, serialized as SenML and published on the nRF Cloud MQTT API.

The hello.nrfcloud.com/map backend converts these messages then back to LwM2M object so it can be displayed on the map.

Installation in your AWS account

Setup

Provide your AWS credentials.

Install the dependencies:

npm ci

Deploy

npx cdk bootstrap # if this is the first time you use CDK in this account
npx cdk deploy

Configure

Configure the nRF Cloud team ID:

aws ssm put-parameter --name /${STACK_NAME:-kartverket-vasstand}/nrfcloud/account/accountId --type String --value "<team ID>"

Configure the station credentials:

aws ssm put-parameter --name /${STACK_NAME:-kartverket-vasstand}/credentials/<station>/deviceId --type String --value "<deviceId>"
aws ssm put-parameter --name /${STACK_NAME:-kartverket-vasstand}/credentials/<station>/certificate --type String --value "<certificate>"
aws ssm put-parameter --name /${STACK_NAME:-kartverket-vasstand}/credentials/<station>/privateKey --type String --value "<privateKey>"

Continuous Deployment using GitHub Actions

After deploying the stack manually once,

  • configure a GitHub Actions environment named production
  • create the secret AWS_ROLE with the value arn:aws:iam::<account ID>:role/<stack name>-cd and a variable (use the cdRoleArn stack output)
  • create the variable AWS_REGION with the value <region> (your region)
  • create the variable STACK_NAME with the value <stack name> (your stack name)

to enable continuous deployment.