How to send a downlink to nodes via python and MQTT?

(Bismarck) #1

I used example on TTN ( to build a python SDK to send and receive message. I have successfully received uplink message and stored them. However, I had no idea about how to use codes in this website ( especially the code following:


In addition, do I need this code to set? And how to use this?

(Juan Montoya) #2

Hi Bismarck,

a) I had the same problem. I just resolved by sending the message in base64 instead of hexadeximal. This means: 0 is “AA==” and 1 is “AQ==”. I think there is some bug in TTN because I couldn’t send it with hexadecimal.

Now, the following script sends a downlink with value 1:

import ttn
app_id = "app_id_XX"
access_key = "access_key_XXX"
handler = ttn.HandlerClient(app_id, access_key)
mqtt_client =
mqtt_client.send(dev_id="dev_id_xxx",  pay= "AQ==", port=1, conf=True, sched="replace")

b) You don’t need to use “set_downlink_callback”.

Best regards,


(Bismarck) #3

Thanks a lot! I have worked it out a few days ago. But your suggestion about not using “set_downlink_callback” is very useful.
By the way, have you figured out what is the function of “set_downlink_callback” ? Is it about ACK confirmed?

(system) #4

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