barnacles-sparkplug

May 10, 2026 ยท View on GitHub

barnacles-sparkplug distributes ambient IoT sensor data via MQTT observing the Eclipse Sparkplug specification.

Overview of barnacles-sparkplug

barnacles-sparkplug ingests a real-time stream of dynamb objects from barnacles which it publishes via MQTT as Sparkplug B payloads. It couples seamlessly with reelyActive's Pareto Anywhere open source IoT middleware.

barnacles-sparkplug is a lightweight Node.js package that can run on resource-constrained edge devices as well as on powerful cloud servers and anything in between.

Pareto Anywhere integration

A common application of barnacles-sparkplug is to publish IoT data from pareto-anywhere as Sparkplug B payloads via MQTT. Simply follow our Create a Pareto Anywhere startup script tutorial using the script below:

#!/usr/bin/env node

const ParetoAnywhere = require('../lib/paretoanywhere.js');

// Edit the options to customise the server
const BARNACLES_SPARKPLUG_OPTIONS = {};

// ----- Exit gracefully if the optional dependency is not found -----
let BarnaclesSparkplug;
try {
  BarnaclesSparkplug = require('barnacles-sparkplug');
}
catch(err) {
  console.log('This script requires barnacles-sparkplug.  Install with:');
  console.log('\r\n    "npm install barnacles-sparkplug"\r\n');
  return console.log('and then run this script again.');
}
// -------------------------------------------------------------------

let pa = new ParetoAnywhere();
pa.barnacles.addInterface(BarnaclesSparkplug, BARNACLES_SPARKPLUG_OPTIONS);

Quick Start

Clone this repository, then from its root folder, install dependencies with npm install. Start the Sparkplug client with the following command:

npm start

If a MQTT broker is running on localhost, the client should connect (without authentication) and publish a NBIRTH message. For convenience, a script to subscribe to Sparkplug messages (topic: spBv1.0/#) on localhost and print these to the console is provided, and can be started with the following command:

npm run subscribe

When both programs are run simultaneously, the latter will echo all Sparkplug messages to the console, starting with the NBIRTH message which will have the following format:

Topic: spBv1.0/iot/NBIRTH/paretoanywhere
{
  timestamp: Long { low: 1735707600, high: 404, unsigned: true },
  metrics: [],
  seq: Long { low: 0, high: 0, unsigned: true }
}

Simulated Data

The following simulated devices/sensors are supported for interface testing.

Minew S1

To simulate a Minew S1 temperature/humidity sensor, start barnacles-sparkplug with the following command:

npm run minew-s1

Simulated sensor c30000000051 will expose the following metrics:

nametype
temperatureDouble
relativeHumidityDouble
batteryPercentageDouble

Supported dynamb properties

barnacles-sparkplug converts standard dynamb properties into the following Protobuf data types:

PropertyData TypeConversion
accelerationDataSet of Double1, 2 or 3-column (xyz)
amperageDoublenone
ammoniaConcentrationDoublenone
angleOfRotationDoublenone
angularVelocityDoublenone
amperagesDataSet of DoubleMulti-column (0..n)
batteryPercentageDoublenone
batteryVoltageDoublenone
carbonDioxideConcentrationDoublenone
carbonMonoxideConcentrationDoublenone
countUInt32none
countsDataSet of UInt32Multi-column (0..n)
distanceDoublenone
durationDoublenone
durationsDataSet of DoubleMulti-column (0..n)
elevationDoublenone
energyDoublenone
headingDoublenone
heartRateDoublenone
illuminanceDoublenone
isButtonPressedBooleanLogical OR (if many)
isButtonPressedCycleUInt32none
isCarbonMonoxideDetectedBooleanLogical OR (if many)
isCarbonMonoxideDetectedCycleUInt32none
isContactDetectedBooleanLogical OR (if many)
isContactDetectedCycleUInt32none
isGasDetectedBooleanLogical OR (if many)
isGasDetectedCycleUInt32none
isHealthyBooleannone
isInputDetectedBooleanLogical OR (if many)
isInputDetectedCycleUInt32none
isLightDetectedBooleanLogical OR (if many)
isLightDetectedCycleUInt32none
isLiquidDetectedBooleanLogical OR (if many)
isLiquidDetectedCycleUInt32none
isMotionDetectedBooleanLogical OR (if many)
isMotionDetectedCycleUInt32none
isOccupancyDetectedBooleanLogical OR (if many)
isOccupancyDetectedCycleUInt32none
isSmokeDetectedBooleanLogical OR (if many)
isSmokeDetectedCycleUInt32none
isTamperDetectedBooleanLogical OR (if many)
isTamperDetectedCycleUInt32none
levelPercentageDoublenone
luminousFluxDoublenone
magneticFieldDataSet of Double1, 2 or 3-column (xyz)
methaneConcentrationDoublenone
nitrogenDioxideConcentrationDoublenone
nitrogenOxidesIndexUInt32none
numberOfOccupantsUInt32none
numberOfOccupantsCycleUInt32none
numberOfReceivedDevicesUInt32none
numberOfStrongestReceivedDevicesUInt32none
passageCountsDataSet of UInt321 or 2-column
passageCountsCycleUInt32none
pHDoublenone
pm1.0Doublenone
pm2.5Doublenone
pm10Doublenone
positionDataSet of Double1, 2 or 3-column (xyz)
powerDoublenone
pressureDoublenone
pressuresDataSet of DoubleMulti-column (0..n)
relativeHumidityDoublenone
speedDoublenone
temperatureDoublenone
temperaturesDataSet of DoubleMulti-column (0..n)
txCountUInt32none
txCycleUInt32none
uptimeUInt32none
velocityOverallDataSet of Double1, 2 or 3-column (xyz)
volatileOrganicCompoundsConcentrationDoublenone
voltageDoublenone
voltagesDataSet of DoubleMulti-column (0..n)

Integrations

The Eclipse Sparkplug specification "ensures open and interoperable IIoT" enabling barnacles-sparkplug, and hence Pareto Anywhere, to integrate seamlessly with the following platforms.

ThingsBoard

barnacles-sparkplug will automatically publish data to the MQTT broker of a ThingsBoard instance running on localhost (on port 1883). Configure the MQTT Sparkplug API with a device profile that uses MQTT ClientId ParetoAnywhereEdgeNode to receive the data in ThingsBoard. Follow our ThingsBoard Sparkplug Integration tutorial for step-by-step instructions.

For advanced integrations with ThingsBoard, configure the barnacles-sparkplug options, listed below.

Options

barnacles-sparkplug supports the following options:

PropertyDefaultDescription
url"mqtt://localhost"Local MQTT broker
groupId"iot"See Sparkplug specification
edgeNodeId"paretoanywhere"See Sparkplug specification
clientId"ParetoAnywhereEdgeNode"Unique id of MQTT client
usernamenullOptional for MQTT authentication
passwordnullOptional for MQTT authentication
deviceTimeoutMilliseconds60000Activity timeout for DDEATH
reconnectMilliseconds15000For initial MQTT connection error
eventsToStore{ dynamb: {} }For filtering
printErrorsfalsePrint MQTT errors?

eventsToStore

The eventsToStore option determines which events (i.e. dynamb) are to be published, and any event-specific options such as filter parameters. For instance, to store only dynamb objects with temperature:

{
  dynamb: {
    filterParameters: { acceptedProperties: [ 'temperature' ] }
  }
}

Consult the dynamb-filter documentation for the respective parameters.

barnacles-sparkplug can also publish valid position data from raddec and/or spatem events. For instance, to store only position data from any source:

{
  raddec: {},
  dynamb: {
    filterParameters: { acceptedProperties: [ 'position' ] }
  },
  spatem: {}
}

Consult the raddec-filter and spatem-filter documentation for their respective parameters.

Acknowledgements

barnacles-sparkplug is based on the sparkplug-client open source Node.js package of the Eclipse Tahu project which is licensed under the Eclipse Public License v2.0 (EPL-2.0), and which we invite you to consider supporting at sparkplug.eclipse.org.

Contributing

Discover how to contribute to this open source project which upholds a standard code of conduct.

Security

Consult our security policy for best practices using this open source software and to report vulnerabilities.

License

MIT License

Copyright (c) 2025-2026 reelyActive

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.