Stand with Ukraine flag
Try it now Pricing
Professional Edition
How to connect WS202 PIR & Light LoRaWAN® Sensor to ThingsBoard?
Getting Started Documentation Devices Library Guides Installation Architecture API FAQ
On this page

How to connect WS202 PIR & Light LoRaWAN® Sensor to ThingsBoard?

Introduction

WS202 PIR & Light LoRaWAN® Sensor WS202 PIR & Light Sensor is a PIR sensor based on passive infrared technology to detect a motion or occupancy.
WS202 can detect whether there is a movement within the range of 6-8 m.
Besides, WS202 equips with a light sensor which can link PIR detection results to trigger scenes.
WS202 can be widely used in smart homes, smart offices, schools, warehouses, etc.
Sensor data are transmitted in real-time using the standard LoRaWAN® protocol.
LoRaWAN® enables encrypted radio transmissions over long distances while consuming very little power.

Doc info icon
ThingsBoard PE Feature

Only Professional Edition supports Platform Integrations feature.
Use ThingsBoard Cloud or install your own platform instance.


Prerequisites

To continue with this guide we will need the following:

Device connection

According to the official user manual, we need a smartphone with NFC enabled and the ToolBox application to connect the sensor.
Since this device can only be operated using a LoRaWAN® gateway, we must first connect it to a network server that has an integration configured with ThingsBoard.
Afterward, it can be provisioned to ThingsBoard.

Device configuration

To connect and send data we should configure the device and network server.
At first we are going to configure the device, and save required information for network server configuration.
To add a device to network server and get information from it, we will need the following device parameters:

  • Device EUI - device identifier
  • Application EUI - Application identifier
  • Application Key - Application key to identify device. We recommend to use a generated key, not from the example!

The parameters above are required for connection.

Depending on the network server, you may also need to provide join type (OTAA), LoRaWAN version.

To configure device via NFC, you will need to hold your smartphone like on the picture below:
NFC zone

To read and write configuration on the device you may follow next steps on your smartphone:

  • Open ToolBox application.

  • Click on NFC Read button and hold your smartphone near the device.

  • Go to tab Setting, set and save required fields and any other configuration that you need.

  • Press Write button and hold your smartphone near the device.

If you have some issues with configuring the device and your smartphone in the case - it is recommended by vendor to try to configure the smartphone without case.

Now, the device is able to send a data to the network server.

To configure the device we also need to add it to a network server, so select the network server your gateway is connected to:

Add a device on the Chirpstack

We need to add a device on the Chirpstack.

To add a device, you can follow next steps:

  • Login to Chirpstack server.

  • Go to the Device profiles page and click on Add device profile button.

  • Fill the fields and click on Submit button.

  • Go to the Applications page, click on your application and press Add device button.

  • Fill parameters with values from the device configuration. Then choose previously created device profile and click on Submit button.

  • Put your Application key to the field and click on Submit button to save the device.

Step 1: Download the JSON file

Download the JSON file with the uplink converter settings by clicking the button below.

Download uplink converter for ChirpStack integration.


Step 2: Import the Uplink converter into ThingsBoard

After downloading the file with the Uplink converter configuration, import it into ThingsBoard:

  • Navigate to the “Data converters” page in the “Integration center” section.
  • Click the “+” icon in the top-right corner of the page and select “Import converter” from the drop-down menu.
  • Drag and drop the downloaded JSON file (containing the uplink converter configuration) into the import window, then click “Import”.
  • The uplink converter is now successfully imported.


Step 3: Replace the Uplink converter in the ChirpStack integration

Now, let's update your ChirpStack integration to use the new uplink converter:

  • Go to the “Integrations” page in the “Integration center” section.
  • Click on your ChirpStack integration to open its details window.
  • Enter edit mode by clicking the orange pencil button in the top-right corner.
  • Replace the existing uplink converter with the imported one.
  • Don't forget to save your changes!

Add a device on The Things Stack Community Edition

We need to add a device on The Things Stack Community Edition.

To add a device, you can follow next steps:

  • Login to the cloud and open your console.

  • Go to the Applications page. Then select your application and click on its name.

  • Click on the Register end device button.

  • Put the APP EUI value to the JoinEUI field. Press the Confirm button.

  • Fill the rest parameters and press Register end device button.

Step 1: Download the JSON file

Download the JSON file with the uplink converter settings by clicking the button below.

Download uplink converter for The Things Stack integration.


Step 2: Import the Uplink converter into ThingsBoard

After downloading the file with the Uplink converter configuration, import it into ThingsBoard:

  • Navigate to the “Data converters” page in the “Integration center” section.
  • Click the “+” icon in the top-right corner of the page and select “Import converter” from the drop-down menu.
  • Drag and drop the downloaded JSON file (containing the uplink converter configuration) into the import window, then click “Import”.
  • The uplink converter is now successfully imported.


Step 3: Replace the Uplink converter in the The Things Stack integration

Now, let's update your The Things Stack integration to use the new uplink converter:

  • Go to the “Integrations” page in the “Integration center” section.
  • Click on your The Things Stack integration to open its details window.
  • Enter edit mode by clicking the orange pencil button in the top-right corner.
  • Replace the existing uplink converter with the imported one.
  • Don't forget to save your changes!

Add a device on The Things Industries

We need to add a device on The Things Industries cloud.

To add a device, you can follow next steps:

  • Login to the cloud and open your console.

  • Go to the Applications page. Then select your application and click on its name.

  • Click on the Register end device button.

  • Put the APP EUI value to the JoinEUI field. Press the Confirm button.

  • Fill the rest parameters and press Register end device button.

Step 1: Download the JSON file

Download the JSON file with the uplink converter settings by clicking the button below.

Download uplink converter for The Things Industries integration.


Step 2: Import the Uplink converter into ThingsBoard

After downloading the file with the Uplink converter configuration, import it into ThingsBoard:

  • Navigate to the “Data converters” page in the “Integration center” section.
  • Click the “+” icon in the top-right corner of the page and select “Import converter” from the drop-down menu.
  • Drag and drop the downloaded JSON file (containing the uplink converter configuration) into the import window, then click “Import”.
  • The uplink converter is now successfully imported.


Step 3: Replace the Uplink converter in the The Things Industries integration

Now, let's update your The Things Industries integration to use the new uplink converter:

  • Go to the “Integrations” page in the “Integration center” section.
  • Click on your The Things Industries integration to open its details window.
  • Enter edit mode by clicking the orange pencil button in the top-right corner.
  • Replace the existing uplink converter with the imported one.
  • Don't forget to save your changes!

Add a device on the Loriot

We need to add a device on the Loriot.

To add a device, you can follow next steps:

  • Login to Loriot server. We use eu2.loriot.io, but it depends on chosen region during registration.

  • Go to the “Applications” page in left menu.

  • Open your application, in our case it is “SampleApp”.

  • Go to the “Enroll Device” page. Fill in the fields, with a configuration from your device. Then click the “Enroll” button.

Step 1: Download the JSON file

Download the JSON file with the uplink converter settings by clicking the button below.

Download uplink converter for Loriot integration.


Step 2: Import the Uplink converter into ThingsBoard

After downloading the file with the Uplink converter configuration, import it into ThingsBoard:

  • Navigate to the “Data converters” page in the “Integration center” section.
  • Click the “+” icon in the top-right corner of the page and select “Import converter” from the drop-down menu.
  • Drag and drop the downloaded JSON file (containing the uplink converter configuration) into the import window, then click “Import”.
  • The uplink converter is now successfully imported.


Step 3: Replace the Uplink converter in the Loriot integration

Now, let's update your Loriot integration to use the new uplink converter:

  • Go to the “Integrations” page in the “Integration center” section.
  • Click on your Loriot integration to open its details window.
  • Enter edit mode by clicking the orange pencil button in the top-right corner.
  • Replace the existing uplink converter with the imported one.
  • Don't forget to save your changes!

Check data on ThingsBoard

So, the device was added and if it sends any data - it should appear in Devices.
To check it you may open Devices page in Entities section. The device should be in devices list. You can check the data by click on it and open tab Attributes or Latest telemetry.

Check telemetry on device


In order to get more user-friendly view - you can use dashboards.
You can download a simple dashboard for this device, it is configured to display a data from “pir”, “light” and “battery” telemetry keys for device with name “eui-24e124538b223213”.

ThingsBoard provides the ability to create and customize interactive visualizations (dashboards) for monitoring and managing data and devices.
Through ThingsBoard dashboards, you can efficiently manage and monitor your IoT devices and data. So, we will create the dashboard, for our device.

To add the dashboard to ThingsBoard, we need to import it. To import a dashboard, follow these steps:

  • Navigate to the “Dashboards” page. By default, you navigate to the dashboard group “All”. Click on the “+” icon in the top right corner. Select “Import dashboard”.

  • In the dashboard import window, upload the JSON file and click “Import” button.

  • Dashboard has been imported.

To open the imported dashboard, click on it. Then you should specify your device in entity alias of the dashboard.

To do this, follow these steps:

  • Open the dashboard and enter edit mode. Click the “Entity aliases” icon, then in the pop-up window click the “Edit alias” icon next to the alias.

  • In edit alias window select your device from dropdown list and save entity alias.

  • Apply all changes.

Now you should be able to see the data from the device.

Example of the dashboard with data:

Dashboard

Conclusion

With the knowledge outlined in this guide, you can easily connect your WS202 PIR & Light LoRaWAN® Sensor and send data to ThingsBoard.

Explore the platform documentation to learn more about key concepts and features. For example, configure alarm rules or dashboards.