Trouble sending data to TTN Device Downlink via MQTT Out

I a looking to troubleshoot sending commands to my downlink of my device on the TTN network.

In the TTN console I do this and it works:

But from Node Red I have the following in a function feeding into a MQTT Out and it does not work: [Device and App ID are of course REPLACED as to not share them]

// TTN downliank settings
var dev_id = "REPLACED"; // from previous MQTT received message in this case;
var dlPort = 2; // downlink port in this application
var dlConfirmed = true;
var dlScheduled = "replace"; // allowed values: "replace" (default), "first", "last"

// MQTT settings
msg.topic = "v3/REPLACED@ttn/devices/" + dev_id + "/down/push";
msg.qos = 0;
msg.retain = false;

var payload_raw = Buffer.alloc(2, 0);
payload_raw[1] = 0x12c; // Changed uplink fequency to 5min (300 sec in Hex)
var base64data = payload_raw.toString('base64');

// use payload fields
var message = {
    port: dlPort,
    confirmed: dlConfirmed,
    schedule: dlScheduled,
    payload_raw: base64data,

msg.payload = message;

return msg;

I was referencing this post:

and this post:

as starting points but have hit a dead end for now. Any help is appeciated.

I wondered if my example was too old so I looked up The Things Stack current documentation and found it here:

So I updated my function node to this:

msg.topic = "v3/REPLACED@ttn/devices/REPLACED/down/push";
var base64data = msg.payload;

msg.payload = {
    "f_port": 2,
    "frm_payload": base64data,
    "priority": "NORMAL"

return msg;

And I am passing the base64 encoded values for the seconds in as the msg.payload.

Possible values I am passing:
Hex			Time			Base64
0100012C = 300 secs (5 mins)	xKw=
01000258 = 600 secs (10 mins)	yZg=
01000384 = 900 sec (15 mins)	zoQ=
010004B0 = 1200 sec (20 mins)	0rA=
01000708 = 1800 sec (30 mins)	3Ig=
01000E10 = 3600 sec (1hr)		4LiQ

Here is part of the debug output to show a payload example.

But even still I have yet to seem to get this to work.

And thoughts on how to even troubleshoot this would be good as I do not even know if the command from Node Red is reaching the TTN application. None of the live data views show it.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.