Skip to content
Stand with Ukraine flag

Smartico V-LR

Smartico V-LR

Smartico V-LR

Smartico

Platform
ThingsBoard
Hardware Type
Sensors
Connectivity
LoRaWAN
Industry
Energy Management, Smart Cities, Smart Buildings
Use Case
Smart Energy, Smart Metering

Introduction

The Smartico V-LR is a gas shutoff valve designed for remotely cutting off the gas supply in low-pressure gas networks. It operates on an autonomous power supply and includes a special valve activation mechanism for safe gas supply recovery. Sealed mounting points prevent unauthorized access to the power source and ensure the valve cannot be dismantled from the pipeline without detection. Data is transmitted wirelessly over LoRaWAN in the license-free frequency range.

This guide describes how to receive telemetry from the Smartico V-LR over LoRaWAN using ChirpStack and a ThingsBoard MQTT integration, and visualize the data on a dashboard.

Prerequisites

Configure ChirpStack

Register the Smartico V-LR in ChirpStack and verify the device is transmitting. The device should appear on the Applications page with its serial number (like 0000129).

The uplink data converter decodes the Base64-encoded payload from the V-LR into ThingsBoard telemetry format.

  1. Download uplink_gas_valve.json.
  2. Go to Integrations center > Data converters and click + Add data converter > Import converter.
  3. Drag and drop the downloaded uplink_gas_valve.json file.
  4. Click Import.
/** Decoder **/
var payloadStr = decodeToString(payload);
var data = JSON.parse(payloadStr);
var deviceType = 'Gas Valve';
var res = _base64ToArrayBuffer(data.data);
if (res.length < 6)
return null;
var dateTime = GetCurrentDateTime();
var serial = GetSerial(res[3], res[4], res[5]);
var valveModel = GetModel(res[2]);
var stsValve = GetStsValve(res[2]);
var stsValveCode = GetStsValveCode(res[2]);
var deviceName = serial;
var low_bat = GetFlagError(res[1], 1);
var motion_detect = GetFlagError(res[1], 2);
var magnet_detect = GetFlagError(res[1], 3);
var tamper_detect = GetFlagError(res[1], 4);
var power_on = GetFlagError(res[1], 5);
var power_bat = GetFlagError(res[1], 6);
var err_time = GetFlagError(res[1], 7);
var cfg_done = GetFlagError(res[1], 8);
var result = {
deviceName: deviceName,
deviceType: deviceType,
attributes: {
integrationName: metadata['integrationName'],
},
telemetry: {
NAME_DEV: "Gas Shutoff Valve LoRaWAN 'Smartico V-LR'",
REAL_TIME: dateTime,
SERIAL: serial,
VALVE_MODEL: valveModel,
STS_VALVE: stsValve,
STS_VALVE_CODE: stsValveCode,
FLG_LOW_BAT: low_bat,
FLG_MOTION_DETECT: motion_detect,
FLG_MAGNET_DETECT: magnet_detect,
FLG_TAMPER_DETECT: tamper_detect,
FLG_POWER_ON: power_on,
FLG_POWER_BAT: power_bat,
FLG_ERR_TIME: err_time,
FLG_CFG_DONE: cfg_done
}
};
/** Helper functions **/
function decodeToString(payload) {
return String.fromCharCode.apply(String, payload);
}
function decodeToJson(payload) {
var str = decodeToString(payload);
return JSON.parse(str);
}
function _base64ToArrayBuffer(base64) {
var binary_string = atob(base64);
var len = binary_string.length;
var bytes = new Uint8Array(len);
for (var i = 0; i < len; i++) {
bytes[i] = binary_string.charCodeAt(i);
}
return bytes;
}
function GetCurrentDateTime() {
var a = new Date();
var year = a.getFullYear().toString();
var month = (a.getMonth() + 1).toString();
if (month.length == 1) month = "0" + month;
var date = a.getDate().toString();
if (date.length == 1) date = "0" + date;
var hour = a.getHours().toString();
if (hour.length == 1) hour = "0" + hour;
var min = a.getMinutes().toString();
if (min.length == 1) min = "0" + min;
var sec = a.getSeconds().toString();
if (sec.length == 1) sec = "0" + sec;
return date + '.' + month + '.' + year + ' ' + hour + ':' + min + ':' + sec;
}
function GetSerial(byte1, byte2, byte3) {
var value1 = parseInt(byte1, 10).toString(16);
while (value1.length < 2) value1 = '0' + value1;
var value2 = parseInt(byte2, 10).toString(16);
while (value2.length < 2) value2 = '0' + value2;
var value3 = parseInt(byte3, 10).toString(16);
while (value3.length < 2) value3 = '0' + value3;
var value = value1 + value2 + value3;
var res = parseInt(value, 16).toString();
while (res.length < 7) res = '0' + res;
return res;
}
function GetModel(byte1) {
var value = parseInt(byte1, 10).toString(2);
while (value.length < 8) value = '0' + value;
var val = value[0] + value[1];
var res = parseInt(val, 2);
if (res == 0) return "Gas";
if (res == 1) return "Water";
return "Undefined";
}
function GetStsValve(byte1) {
var value = parseInt(byte1, 10).toString(2);
while (value.length < 8) value = '0' + value;
var val = value[5] + value[6] + value[7];
var res = parseInt(val, 2);
if (res == 0) return "Undefined";
if (res == 1) return "Close";
if (res == 2) return "Ready to open";
if (res == 3) return "Open";
return "Error";
}
function GetStsValveCode(byte1) {
var value = parseInt(byte1, 10).toString(2);
while (value.length < 8) value = '0' + value;
var val = value[5] + value[6] + value[7];
return parseInt(val, 2);
}
function GetFlagError(byte1, num) {
var value = parseInt(byte1, 10).toString(2);
while (value.length < 8) value = '0' + value;
if (num == 1) return Number(value[7]);
if (num == 2) return Number(value[6]);
if (num == 3) return Number(value[5]);
if (num == 4) return Number(value[4]);
if (num == 5) return Number(value[3]);
if (num == 6) return Number(value[2]);
if (num == 7) return Number(value[1]);
if (num == 8) return Number(value[0]);
return null;
}
return result;

You can test the converter before connecting the device. Open the Uplink Gas Valve converter, enter edit mode and click the Test decoder function tab. Paste the sample input below into the Payload content field and press Test.

Sample input payload (Base64-encoded)
{
"applicationID": "6",
"applicationName": "Smartico_gaz_valves",
"deviceName": "VALVE_0000129",
"devEUI": "02aaaa0100000081",
"rxInfo": [{
"gatewayID": "647fdafffe00d228",
"uplinkID": "bebb9711-3fe0-4ddd-ad16-9815af9c0f42",
"name": "tectelic_micro_lite_TECH",
"rssi": -72,
"loRaSNR": 9.8,
"location": {
"latitude": 48.44229794818326,
"longitude": 35.014479160308845,
"altitude": 144
}
}],
"txInfo": {
"frequency": 868100000,
"dr": 0
},
"adr": true,
"fCnt": 12,
"fPort": 2,
"data": "BkABAACB"
}
Expected decoded output
{
"deviceName": "0000129",
"deviceType": "Gas Valve",
"attributes": {
"integrationName": "Gas Valve"
},
"telemetry": {
"NAME_DEV": "Gas Shutoff Valve LoRaWAN 'Smartico V-LR'",
"REAL_TIME": "26.08.2020 10:25:20",
"SERIAL": "0000129",
"VALVE_MODEL": "Gas",
"STS_VALVE": "Close",
"STS_VALVE_CODE": 1,
"FLG_LOW_BAT": 0,
"FLG_MOTION_DETECT": 0,
"FLG_MAGNET_DETECT": 0,
"FLG_TAMPER_DETECT": 0,
"FLG_POWER_ON": 0,
"FLG_POWER_BAT": 0,
"FLG_ERR_TIME": 1,
"FLG_CFG_DONE": 0
}
}

Create the integration

For more information about MQTT integrations in ThingsBoard, see the MQTT integration documentation.

  1. Go to Integrations center ⇾ Integrations and click + Add integration.
  2. Basic settings:
    • Set Integration type to MQTT.
    • Enable integration and Allow create devices or assets are on by default.
    • Click Next.
  3. Uplink data converter:
    • Select existing — choose the previously created Uplink Gas Valve from the list.
    • Click Next.
  4. Downlink data converter:
    • Click Skip — only needed for RPC; can be added later.
  5. Connection:
    • Set your MQTT broker Host and Port.
    • Select the Credentials type (e.g. Anonymous).
    • Add at least one topic filter with QoS (e.g. application/6/device/+/rx, QoS 0 — At most once).
  6. Click Add to complete the integration setup.

Verify data

After the V-LR transmits its first packet, a new device named after its serial number (like 0000129) appears automatically in Entities > Devices. You can also verify input and output data in Data converters > Uplink Gas Valve > Events.

Create an asset

To display data on the dashboard, create an asset and add the device as a relation.

  1. Go to Entities ⇾ Assets and create a new asset named Gas Valve with asset type gas-valve.

  2. Open the asset, go to the Relations tab, and add a relation to the device.

Import the rule chain

In addition to valve status, the device reports flags for low battery, tamper detection, and magnetic field exposure. These are displayed in an Alarm widget. Import the rule chain first to enable alarm processing.

  1. Download alarms_gas_valve.json and import it in Rule chains.

  2. Open the Root Rule Chain, add a link to the imported Alarms Gas Valve rule chain, and save.

Import the dashboard

  1. Download dashboard_gas_valve.json and import it in Dashboards. See the dashboard import instructions.

  2. After importing, edit the dashboard alias and set it to the Gas Valve asset created in the previous step.

The dashboard now displays live valve status and device health data from the Smartico V-LR.