Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions dingtek-dc510/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Changelog

## 1.0.0 - 2026-06-09

- First version of plugin
7 changes: 7 additions & 0 deletions dingtek-dc510/LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Copyright 2026 Thinger.io

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
63 changes: 63 additions & 0 deletions dingtek-dc510/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# DC510 - People Counter

The CNDingtek DC510 is a PIR-based people counter designed for indoor use to calculate the number of people entering or passing through a monitored area. This wireless sensor provides single-direction people flow counting without capturing images or video, ensuring privacy compliance while delivering accurate occupancy data for building management and crowd control applications.

## Features

- **PIR Sensor Technology**: Passive infrared detection for reliable people counting
- **Single-Direction Counting**: Monitors unidirectional people flow
- **Privacy-Focused Design**: No image or video capture
- **LoRaWAN Connectivity**: Low-power wireless communication for long-range data transmission
- **Multi-Protocol Support**: Available with LoRaWAN, NB-IoT, or Sigfox connectivity options
- **IP65 Enclosure**: Dust-tight and water-resistant housing
- **Compact Design**: 110 x 109 x 25 mm dimensions
- **Wide Operating Temperature**: -20°C to 70°C
- **Battery Powered**: Long-lasting operation (up to 1 year typical battery life)

## Use Cases

- Conference rooms and meeting spaces
- Hotels and hospitality venues
- Parks and public spaces
- Factories and industrial facilities
- Retail stores and shopping centers
- Building occupancy monitoring
- Crowd control and flow management
- Capacity limit monitoring and alerts

## Thinger.io Integration

The DC510 people counter can be integrated with Thinger.io through a LoRaWAN network server, enabling real-time monitoring of occupancy data, historical trend analysis, and automated alerting based on people count thresholds.

## Requirements

A LoRaWAN server is required to communicate the CNDingtek DC510 into Thinger.io, some options are:

- [The Things Stack](https://www.thethingsindustries.com/stack/)
- [LORIOT](https://loriot.io/)
- [ChirpStack](https://www.chirpstack.io/)

Alongside, the corresponding plugin for the selected LoRaWAN server needs to be installed in your Thinger.io instance.

## Get Started

### Installation

Look for the plugin in the [Thinger.io Plugin Store](https://marketplace.thinger.io/) and install it in your Thinger.io instance. Once the plugin is installed a new Product will be created for this device.

### Configuration

The Product is already preconfigured, check that the auto provision prefix matches the one selected in your LoRaWAN server plugin in Thinger.io, or change it to your desire.

### Usage

Start sending uplinks for autoprovisioning devices and buckets.
This product also provides a predefined dashboard and downlinks.

## Additional Resources

CNDingtek resources can be found at:

- [Product Page](https://www.dingtek.com/people-counter-dc510)
- [Device Repository - The Things Network](https://www.thethingsnetwork.org/device-repository/devices/dingtek/dc510)
- [Thinger docs](https://docs.thinger.io)
Binary file added dingtek-dc510/assets/dc510.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
134 changes: 134 additions & 0 deletions dingtek-dc510/plugin.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
{
"name": "dingtek_dc510",
"version": "1.0.0",
"description": "The CNDingtek dc510 is a pir people counter for indoor using, which calculate the people number.",
"author": "Thinger.io",
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/thinger-io/plugins.git",
"directory": "dingtek-dc510"
},
"metadata": {
"name": "Dingtek DC510",
"description": "The CNDingtek dc510 is a pir people counter for indoor using, which calculate the people number.",
"image": "assets/dc510.png",
"category": "devices",
"vendor": "dingtek"
},
"resources": {
"products": [
{
"description": "The CNDingtek dc510 is a pir people counter for indoor using, which calculate the people number.",
"enabled": true,
"name": "Dingtek DC510",
"product": "dingtek_dc510",
"profile": {
"api": {
"downlink": {
"enabled": true,
"handle_connectivity": false,
"request": {
"data": {
"path": "/downlink",
"payload": "{\n \"data\" : \"{{payload.data=\"\"}}\",\n \"port\" : {{payload.port=3}},\n \"priority\": {{payload.priority=3}},\n \"confirmed\" : {{payload.confirmed=false}},\n \"uplink\" : {{property.uplink}} \n}",
"payload_function": "",
"payload_type": "",
"plugin": "{{property.uplink.source}}",
"target": "plugin_endpoint"
}
}
},
"uplink": {
"device_id_resolver": "getId",
"enabled": true,
"handle_connectivity": true,
"request": {
"data": {
"payload": "{{payload}}",
"payload_function": "",
"payload_type": "source_payload",
"resource_stream": "uplink",
"target": "resource_stream"
}
}
}
},
"autoprovisions": {
"device_autoprovisioning": {
"config": {
"mode": "pattern",
"pattern": "dc510_[0-9A-Fa-f]{16}"
},
"enabled": true
}
},
"buckets": {
"dingtek_dc510_data": {
"backend": "mongodb",
"data": {
"payload": "{{payload}}",
"payload_function": "",
"payload_type": "source_payload",
"resource_stream": "uplink_decoded",
"source": "resource_stream"
},
"enabled": true,
"retention": {
"period": 3,
"unit": "months"
},
"tags": []
}
},
"code": {
"code": "function decodeThingerUplink(thingerData) {\n // 0. If data has already been decoded, we will return it\n if (thingerData.decodedPayload) return thingerData.decodedPayload;\n \n // 1. Extract and Validate Input\n // We need 'payload' (hex string) and 'fPort' (integer)\n const hexPayload = thingerData.payload || \"\";\n const port = thingerData.fPort || 1;\n\n // 2. Convert Hex String to Byte Array\n const bytes = [];\n for (let i = 0; i < hexPayload.length; i += 2) {\n bytes.push(parseInt(hexPayload.substr(i, 2), 16));\n }\n\n // 3. Dynamic Function Detection and Execution\n \n // CASE A: (The Things Stack v3)\n if (typeof decodeUplink === 'function') {\n try {\n const input = {\n bytes: bytes,\n fPort: port\n };\n var result = decodeUplink(input);\n \n if (result.data) return result.data;\n\n return result; \n } catch (e) {\n console.error(\"Error inside decodeUplink:\", e);\n throw e;\n }\n }\n\n // CASE B: Legacy TTN (v2)\n else if (typeof Decoder === 'function') {\n try {\n return Decoder(bytes, port);\n } catch (e) {\n console.error(\"Error inside Decoder:\", e);\n throw e;\n }\n }\n\n // CASE C: No decoder found\n else {\n throw new Error(\"No compatible TTN decoder function (decodeUplink or Decoder) found in scope.\");\n }\n}\n\n\n// TTN decoder\n//IEEE754 hex to float convert\nfunction hex2float(num) {\n var sign = num & 0x80000000 ? -1 : 1;\n var exponent = ((num >> 23) & 0xff) - 127;\n var mantissa = 1 + (num & 0x7fffff) / 0x7fffff;\n return sign * mantissa * Math.pow(2, exponent);\n}\n\nfunction decodeUplink(input) {\n if (input.fPort != 3) {\n return {\n errors: ['unknown FPort'],\n };\n }\n switch (input.bytes.length) {\n case 18:\n return {\n // Decoded data\n data: {\n peopleCounter: ((input.bytes[5] << 8) + input.bytes[6]),\n alarmCounter: Boolean(input.bytes[11] & 0xF0),\n alarmBattery: Boolean(input.bytes[12] & 0x0F),\n temperature: input.bytes[8],\n volt: ((input.bytes[13] << 8) + input.bytes[14]) / 100,\n frameCounter: (input.bytes[15] << 8) + input.bytes[16],\n },\n };\n case 13:\n return {\n // Decoded data\n data: {\n firmware: input.bytes[5] + \".\" + input.bytes[6],\n uploadInterval: input.bytes[7],\n batteryThreshold: input.bytes[10],\n peopleCounterThreshold: (input.bytes[8] << 8) + input.bytes[9],\n },\n };\n default:\n return {\n errors: ['wrong length'],\n };\n }\n}\n\n// Encode downlink function.\n//\n// Input is an object with the following fields:\n// - data = Object representing the payload that must be encoded.\n// - variables = Object containing the configured device variables.\n//\n// Output must be an object with the following fields:\n// - bytes = Byte array containing the downlink payload.\nfunction encodeDownlink(input) {\n if (input.data.uploadInterval != null && !isNaN(input.data.uploadInterval)) {\n var uploadInterval = input.data.uploadInterval;\n var uploadInterval_high = uploadInterval.toString(16).padStart(2, '0').toUpperCase()[0].charCodeAt(0);\n var uploadInterval_low = uploadInterval.toString(16).padStart(2, '0').toUpperCase()[1].charCodeAt(0);\n if (uploadInterval > 168 || uploadInterval < 1) {\n return {\n errors: ['upload interval range 1-168 hours.'],\n };\n } else {\n return {\n // LoRaWAN FPort used for the downlink message\n fPort: 3,\n // Encoded bytes\n bytes: [0x38, 0x30, 0x30, 0x32, 0x39, 0x39, 0x39, 0x39, 0x30, 0x31, uploadInterval_high, uploadInterval_low, 0x38, 0x31],\n };\n }\n }\n if (input.data.peopleCounterThreshold != null && !isNaN(input.data.peopleCounterThreshold)) {\n var peopleCounterThreshold = input.data.peopleCounterThreshold;\n var peopleCounter_1st = peopleCounterThreshold.toString(16).padStart(4, '0').toUpperCase()[0].charCodeAt(0);\n var peopleCounter_2nd = peopleCounterThreshold.toString(16).padStart(4, '0').toUpperCase()[1].charCodeAt(0);\n var peopleCounter_3rd = peopleCounterThreshold.toString(16).padStart(4, '0').toUpperCase()[2].charCodeAt(0);\n var peopleCounter_4th = peopleCounterThreshold.toString(16).padStart(4, '0').toUpperCase()[3].charCodeAt(0);\n if (peopleCounterThreshold > 65535 || peopleCounterThreshold < 1) {\n return {\n errors: ['people counter range 1-65535.'],\n };\n } else {\n return {\n // LoRaWAN FPort used for the downlink message\n fPort: 3,\n // Encoded bytes\n bytes: [0x38, 0x30, 0x30, 0x32, 0x39, 0x39, 0x39, 0x39, 0x30, 0x32, peopleCounter_1st, peopleCounter_2nd, peopleCounter_3rd, peopleCounter_4th, 0x38, 0x31],\n };\n }\n }\n\n if (input.data.batteryThreshold != null && !isNaN(input.data.batteryThreshold)) {\n var batteryThreshold = input.data.batteryThreshold;\n var batteryThreshold_high = batteryThreshold.toString(16).padStart(2, '0').toUpperCase()[0].charCodeAt(0);\n var batteryThreshold_low = batteryThreshold.toString(16).padStart(2, '0').toUpperCase()[1].charCodeAt(0);\n if (batteryThreshold > 99 || batteryThreshold < 5) {\n return {\n errors: ['battery alarm threshold range 5-99.'],\n };\n } else {\n return {\n // LoRaWAN FPort used for the downlink message\n fPort: 3,\n // Encoded bytes\n bytes: [0x38, 0x30, 0x30, 0x32, 0x39, 0x39, 0x39, 0x39, 0x30, 0x35, batteryThreshold_high, batteryThreshold_low, 0x38, 0x31],\n };\n }\n }\n if (input.data.zeroPeopleCounter != null && !isNaN(input.data.zeroPeopleCounter)) {\n var zeroPeopleCounter = input.data.zeroPeopleCounter;\n if (zeroPeopleCounter != 1) {\n return {\n errors: ['zero people counter: 1.'],\n };\n } else {\n return {\n // LoRaWAN FPort used for the downlink message\n fPort: 3,\n // Encoded bytes\n bytes: [0x38, 0x30, 0x30, 0x32, 0x39, 0x39, 0x39, 0x39, 0x30, 0x39, 0x30, 0x46, 0x38, 0x31],\n };\n }\n }\n if (input.data.factoryReset != null && !isNaN(input.data.factoryReset)) {\n var factoryReset = input.data.factoryReset;\n if (factoryReset != 1) {\n return {\n errors: ['factory reset: 1.'],\n };\n } else {\n return {\n // LoRaWAN FPort used for the downlink message\n fPort: 3,\n // Encoded bytes\n bytes: [0x38, 0x30, 0x30, 0x32, 0x39, 0x39, 0x39, 0x39, 0x30, 0x39, 0x30, 0x44, 0x38, 0x31],\n };\n }\n }\n if (input.data.reset != null && !isNaN(input.data.reset)) {\n var reset = input.data.reset;\n if (reset != 1) {\n return {\n errors: ['reset: 1.'],\n };\n } else {\n return {\n // LoRaWAN FPort used for the downlink message\n fPort: 3,\n // Encoded bytes\n bytes: [0x38, 0x30, 0x30, 0x32, 0x39, 0x39, 0x39, 0x39, 0x30, 0x39, 0x30, 0x32, 0x38, 0x31],\n };\n }\n }\n return {\n errors: ['invalid downlink parameter.'],\n };\n}\n\nfunction decodeDownlink(input) {\n var input_length = input.bytes.length;\n if (input.fPort != 3) {\n return {\n errors: ['invalid FPort.'],\n };\n }\n\n if (\n input_length < 12 ||\n input.bytes[0] != 0x38 ||\n input.bytes[1] != 0x30 ||\n input.bytes[2] != 0x30 ||\n input.bytes[3] != 0x32 ||\n input.bytes[4] != 0x39 ||\n input.bytes[5] != 0x39 ||\n input.bytes[6] != 0x39 ||\n input.bytes[7] != 0x39 ||\n input.bytes[input_length - 2] != 0x38 ||\n input.bytes[input_length - 1] != 0x31\n ) {\n return {\n errors: ['invalid format.'],\n };\n }\n var option = parseInt(String.fromCharCode(input.bytes[8]) + String.fromCharCode(input.bytes[9]), 16);\n if (input_length == 16)\n var value = parseInt(String.fromCharCode(input.bytes[10]) + String.fromCharCode(input.bytes[11]) + String.fromCharCode(input.bytes[12]) + String.fromCharCode(input.bytes[13]), 16);\n else\n var value = parseInt(String.fromCharCode(input.bytes[10]) + String.fromCharCode(input.bytes[11]), 16);\n switch (option) {\n case 1:\n return {\n data: {\n uploadInterval: value,\n },\n };\n case 2:\n return {\n data: {\n peopleCounterThreshold: value,\n },\n };\n case 5:\n return {\n data: {\n batteryThreshold: value,\n },\n };\n\n case 9:\n switch (value) {\n case 0x02:\n return {\n data: {\n reset: 1,\n },\n };\n case 0x0D:\n return {\n data: {\n factoryReset: 1,\n },\n };\n case 0x0F:\n return {\n data: {\n zeroPeopleCounter: 1,\n },\n };\n default:\n return {\n errors: ['invalid parameter value.'],\n };\n }\n default:\n return {\n errors: ['invalid parameter key.'],\n };\n }\n}",
"environment": "javascript",
"storage": "",
"version": "1.0"
},
"flows": {
"dingtek_dc510_decoder": {
"data": {
"payload": "{{payload}}",
"payload_function": "decodeThingerUplink",
"payload_type": "source_payload",
"resource": "uplink",
"source": "resource",
"update": "events"
},
"enabled": true,
"sink": {
"payload": "{{payload}}",
"payload_function": "",
"payload_type": "source_payload",
"resource_stream": "uplink_decoded",
"target": "resource_stream"
},
"split_data": false
}
},
"properties": {
"uplink": {
"data": {
"payload": "{{payload}}",
"payload_function": "",
"payload_type": "source_payload",
"resource": "uplink",
"source": "resource",
"update": "events"
},
"default": {
"source": "value"
},
"enabled": true
}
}
},
"_resources": {
"properties": []
}
}
]
}
}
Loading