How to send a downlink to your mote via ttn network using ttn.js


Does any one know how to publish a message to the TTN using the code below:

var ttn = require(‘ttn’);
var appEUI = ‘xxxxxxxxxx’;
var accessKey = ‘********************************************’;
var client = new ttn.Client(‘’, appEUI, accessKey);

client.on(‘uplink’, function (msg) {
console.log(‘Received message’, msg);

client.on(‘activation’, function (msg) {
console.log(‘Device activated:’, msg.devEUI);

(Gonzalo Casas) #2

Looks like the ttn.js SDK doesn't support that at the moment.

(Mike Aski) #3

Any info about ETA of downlink?

(Gonzalo Casas) #4

@MikeAski: ok, now I see why you said you didn't find a definitive answer to whether downlink is supported or not. So, to clarify a bit more: downlink is supported as of today, support is limited to Class A devices.

This forum topic refers to downlink support in the node.js SDK, not in the network itself. And between the last answer and now, downlink support has been added also to the SDK:


(Mike Aski) #5

Ok, thanks a lot for this clarification :+1:

(Niek Beijloos) #6

Downlink with node.js :

client.send(devID, "01",1)

devID = speaks for itself.
“01” = string with the data you want to send.
1 = port you are communicating with ( see your data in the console).

Compleet example:

var ttn = require("ttn")

var appID = "****"
var accessKey = "****", accessKey)
  .then(function (client) {
    client.on("uplink", function (devID, payload) {
      console.log("Received uplink from ", devID)
      client.send(devID, "01",1)
  .catch(function (error) {
    console.error("Error", error)

(Arjan) #7

Just for future readers, as per the documentation:

  • payload (PayloadArray | PayloadRaw | String | PayloadFields) The raw payload as a Buffer, an Array of numbers, a hex string or an object of payload fields.