JavaScript MQTT Client

The WEGnology JavaScript MQTT Client is a library for Node.js compatible compute modules. The library is open source and available on GitHub.


The JavaScript MQTT Client is installed using npm:

npm install wegnology-mqtt

JavaScript MQTT Example

Below is a basic example demonstrating how to connect, send state, and subscribe to commands.

var Device = require('wegnology-mqtt').Device

// Construct device
var device = new Device({
  id: 'my-device-id',
  key: 'my-app-access-key',
  secret: 'my-app-access-secret',

// Connect to WEGnology.

// Listen for commands.
device.on('command', function(command) {
  console.log('Command received.')

// Send temperature once every second.
setInterval(function() {
  device.sendState({ temperature: readAnalogIn() })
}, 1000)

Please refer to the repository for detailed documentation and examples.