# Python to automatically send a downlink to a v3 device using the HTTP webhook

**URL:** <https://www.thethingsnetwork.org/forum/t/python-to-automatically-send-a-downlink-to-a-v3-device-using-the-http-webhook/49776>\
**Category:** End Devices (Nodes)\
**Created:** [July 14, 2021, 12:39pm UTC](https://www.thethingsnetwork.org/forum/t/python-to-automatically-send-a-downlink-to-a-v3-device-using-the-http-webhook/49776 "2021-07-14T12:39:38Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![ecosoph](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/ecosoph/32/35697_2.png) [@ecosoph](https://www.thethingsnetwork.org/forum/u/ecosoph)\
**Post date:** [July 14, 2021, 12:39pm UTC](https://www.thethingsnetwork.org/forum/t/python-to-automatically-send-a-downlink-to-a-v3-device-using-the-http-webhook/49776/1 "2021-07-14T12:39:38Z")

</div>

Hi Guys,

I am currently working on a web interface where the user can program custom sending intervals and transmit them via downlink to a v3 device.

For this project, I am using a [LDDS75 distance sensor from Dragino](https://www.dragino.com/products/distance-level-sensor/item/161-ldds75.html):

- [datasheet](https://www.dragino.com/downloads/index.php?dir=LoRa_End_Node/LDDS75/)
- [description for downlink commands](https://wiki.dragino.com/index.php?title=End_Device_Downlink_Command)

Here is a sample code for the payload:

> Downlink Command: 0x01
> 
> Format: Command Code (0x01) followed by 3 bytes time value.
> 
> If the downlink payload=0100003C, it means set the END Node’s Transmit Interval to 0x00003C=60(S), while type code is 01.
> 
> ```
> Example 1: Downlink Payload: 0100001E // Set Transmit Interval (TDC) = 30 seconds
> Example 2: Downlink Payload: 0100003C // Set Transmit Interval (TDC) = 60 seconds
> 
> ```

I have found following ressources  
[- outdated python sdk for ttn](https://www.thethingsnetwork.org/forum/t/how-to-send-a-downlink-to-nodes-via-python-and-mqtt/22992)

I think this is the most recent and relevant resource on the subject [downlink programming with http, mqtt etc.](https://www.thethingsindustries.com/docs/devices/downlink-queue-ops/)

And this documentation provides the [http example](https://www.thethingsindustries.com/docs/integrations/webhooks/scheduling-downlinks/) that I think fits my needs best.

Is there a python example for sending the post request?

---

<div class="post-metadata">

**Author:** ![descartes](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/descartes/32/47220_2.png) [@descartes](https://www.thethingsnetwork.org/forum/u/descartes)\
**Post date:** [July 14, 2021, 2:12pm UTC](https://www.thethingsnetwork.org/forum/t/python-to-automatically-send-a-downlink-to-a-v3-device-using-the-http-webhook/49776/2 "2021-07-14T14:12:58Z")

</div>

> [@ecosoph](#):
>
> Is there a python example for sending the post request?

Not yet, because I don’t do downlinks, but if (OK, when) I do, it will appear here:

> **[GitHub - descartes/TheThingsStack-Integration-Starters: Starter / Template...](https://github.com/descartes/TheThingsStack-Integration-Starters)**
>
> Starter / Template code for various The Things Stack (v3) integrations - descartes/TheThingsStack-Integration-Starters

You can see how to send requests for data in the Data Storage example - downlinks are the same, just a different incantation - the computer doesn’t know you are sending a downlink rather than requesting data so don’t worry about the direction.

---

<div class="post-metadata">

**Author:** ![ecosoph](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/ecosoph/32/35697_2.png) [@ecosoph](https://www.thethingsnetwork.org/forum/u/ecosoph)\
**Post date:** [July 14, 2021, 2:16pm UTC](https://www.thethingsnetwork.org/forum/t/python-to-automatically-send-a-downlink-to-a-v3-device-using-the-http-webhook/49776/3 "2021-07-14T14:16:01Z")

</div>

@descartes thank you for the friendly help as always. I’ll just try to implement it. There shouldn’t be too many hurdles with the provided documentation.

---

<div class="post-metadata">

**Author:** ![ecosoph](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/ecosoph/32/35697_2.png) [@ecosoph](https://www.thethingsnetwork.org/forum/u/ecosoph)\
**Post date:** [August 18, 2021, 1:23pm UTC](https://www.thethingsnetwork.org/forum/t/python-to-automatically-send-a-downlink-to-a-v3-device-using-the-http-webhook/49776/4 "2021-08-18T13:23:16Z")

</div>

@descartes I’m progressing a bit with my application that schedules a downlink using python. Right now, i can schedule a downlink with following payload:  
“frm\_payload”:“vu8=”

As provided in the documentation.

And I also see the data arriving:  
 ![image](https://www.thethingsnetwork.org/forum/uploads/default/original/3X/1/b/1b14ac2fbe1e1e343a133a91b6e6abc0af1a6944.png)

But what kind of format is vu8=?

I would like to transmit the payload 0x00003C as provided here on page 27: [https://www.dragino.com/downloads/downloads/LoRa\_End\_Node/LDDS75/LoRaWAN\_LDDS75\_User%20Manual\_v1.4.pdf](https://www.dragino.com/downloads/downloads/LoRa_End_Node/LDDS75/LoRaWAN_LDDS75_User%20Manual_v1.4.pdf) to change the sending interval.

---

<div class="post-metadata">

**Author:** ![Jeff-UK](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/jeff-uk/32/35697_2.png) [@Jeff-UK](https://www.thethingsnetwork.org/forum/u/Jeff-UK)\
**Post date:** [August 18, 2021, 1:35pm UTC](https://www.thethingsnetwork.org/forum/t/python-to-automatically-send-a-downlink-to-a-v3-device-using-the-http-webhook/49776/5 "2021-08-18T13:35:37Z")

</div>

That’s isn’t progress that is regression for all! As just posted in the other thread

“_When thinking of downlinks and especially automating the process have in mind the TTN FUP … limit is 10 per day… and as Nick of these parts says whenever a downlink happens a puppy goes hungry. Downlinks render the gw deaf to uplinks…your convenience is a nightmare for all other community users in range of said gw!_

One every 6 mins? 😱🙀 💣

---

<div class="post-metadata">

**Author:** ![ecosoph](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/ecosoph/32/35697_2.png) [@ecosoph](https://www.thethingsnetwork.org/forum/u/ecosoph)\
**Post date:** [August 18, 2021, 1:42pm UTC](https://www.thethingsnetwork.org/forum/t/python-to-automatically-send-a-downlink-to-a-v3-device-using-the-http-webhook/49776/6 "2021-08-18T13:42:03Z")

</div>

Don’t worry, I’m prototyping this in my office plus I’m also just sending uplinks/downlinks to gateways that we brought out in the field.

---

<div class="post-metadata">

**Author:** ![Jeff-UK](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/jeff-uk/32/35697_2.png) [@Jeff-UK](https://www.thethingsnetwork.org/forum/u/Jeff-UK)\
**Post date:** [August 18, 2021, 1:59pm UTC](https://www.thethingsnetwork.org/forum/t/python-to-automatically-send-a-downlink-to-a-v3-device-using-the-http-webhook/49776/7 "2021-08-18T13:59:47Z")

</div>

Sorry but no! Response here

> [@Downlink scheduling using http post requests and python with flask or django](https://www.thethingsnetwork.org/forum/t/downlink-scheduling-using-http-post-requests-and-python-with-flask-or-django/50756/3):
>
> @Jeff-UK don’t worry, using downlinks will be an exception and we also extend the coverage by bringing out gateways in the field. I can now send downlinks but I don’t understand the payload format provided in the documentation: frm\_payload":“vu8=” I receive this downlink as follows: [image] Please note that I have also pumped this [thread](https://www.thethingsnetwork.org/forum/t/python-to-automatically-send-a-downlink-to-a-v3-device-using-the-http-webhook/49776). to avoid double posting
