# TTN Payload to InluxDB

**URL:** <https://discourse.nodered.org/t/ttn-payload-to-inluxdb/12094>\
**Category:** General\
**Created:** [12 June 2019 07:43 UTC](https://discourse.nodered.org/t/ttn-payload-to-inluxdb/12094 "2019-06-12T07:43:52Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![HaVi](https://avatars.discourse-cdn.com/v4/letter/h/b3f665/32.png) [@HaVi](https://discourse.nodered.org/u/HaVi)\
**Post date:** [12 June 2019 07:43 UTC](https://discourse.nodered.org/t/ttn-payload-to-inluxdb/12094/1 "2019-06-12T07:43:52Z")

</div>

From a LoRaWan TTN node I get next payload:

![payload](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/2/2b4aa9ff815b7dae9ab7bffa1852fe6a555ca842.jpeg)

The path to value 3908 is payload\_fields.echteld.

The value 3908 (“echteld”) must be saved in an Influx DB (without password) on 192.168.2.185 named “waterstanden” via the Influx DB Out Node. These are my settings:

 ![db1](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/7/7b32bfdc3c3d2db811c8b98e396a52910861ac44.jpeg)

 ![db2](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/6/67598d2687f1b302185203510978d42f999a9652.jpeg)

I have tried different measurement field settings like msg.payload.echteld, payload\_fields.echteld and payload.echteld but nothing is written to the database.

Can someone give me some advice how to handle this?

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [12 June 2019 08:05 UTC](https://discourse.nodered.org/t/ttn-payload-to-inluxdb/12094/2 "2019-06-12T08:05:03Z")

</div>

Have you read and understood the Info panel for the influxdb node?

---

<div class="post-metadata">

**Author:** ![HaVi](https://avatars.discourse-cdn.com/v4/letter/h/b3f665/32.png) [@HaVi](https://discourse.nodered.org/u/HaVi)\
**Post date:** [12 June 2019 08:27 UTC](https://discourse.nodered.org/t/ttn-payload-to-inluxdb/12094/3 "2019-06-12T08:27:47Z")

</div>

If have read the info but it turned out I did not understood 🤔

What do you think I'm doing wrong?

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [12 June 2019 08:30 UTC](https://discourse.nodered.org/t/ttn-payload-to-inluxdb/12094/4 "2019-06-12T08:30:35Z")

</div>

I don't think much is right unfortunately. For example, what does it say about how to specify the measurement, and how have you tried to do that?

---

<div class="post-metadata">

**Author:** ![HaVi](https://avatars.discourse-cdn.com/v4/letter/h/b3f665/32.png) [@HaVi](https://discourse.nodered.org/u/HaVi)\
**Post date:** [12 June 2019 08:43 UTC](https://discourse.nodered.org/t/ttn-payload-to-inluxdb/12094/5 "2019-06-12T08:43:16Z")

</div>

Hi Colin. Just tried (again) what is written in the info (see below), but no succes ☹

* * *

Node Help

A simple influxdb output node to write values and tags to an influxdb measurement.

The fields and tags to write are in **msg.payload**. If **msg.payload** is a string, number, or boolean, it will be written as a single value to the specified measurement (called _value_ ).

If **msg.payload** is an object containing multiple properties, the fields will be written to the measurement.

If **msg.payload** is an array containing two objects, the first object will be written as the set of named fields, the second is the set of named tags.

Finally, if **msg.payload** is an array of arrays, it will be written as a series of points containing fields and tags.

If the _measurement_ field is not set in the node configuration, the user can send in data with a specified measurement name in **msg.measurement** to overwrite the _measurement_ field in the configuration of the node.

Check _Advanced Query Options_ to specify a time precision and retention policy for the insertion.

The advanced query options _Time Precision_ and _Retention Policy_ can be overwritten using message properties **msg.precision** and **msg.retentionPolicy**.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [12 June 2019 09:00 UTC](https://discourse.nodered.org/t/ttn-payload-to-inluxdb/12094/6 "2019-06-12T09:00:08Z")

</div>

So what don't you understand?  
If you don't understand the basics of message structure, have a look at the section in the node red docs on messages?  
[https://nodered.org/docs/user-guide/messages](https://nodered.org/docs/user-guide/messages)

---

<div class="post-metadata">

**Author:** ![HaVi](https://avatars.discourse-cdn.com/v4/letter/h/b3f665/32.png) [@HaVi](https://discourse.nodered.org/u/HaVi)\
**Post date:** [12 June 2019 09:21 UTC](https://discourse.nodered.org/t/ttn-payload-to-inluxdb/12094/7 "2019-06-12T09:21:52Z")

</div>

As far as my knowledge goes, even after reading all the info mentioned, I did nothing wrong setting up this node but still it doesn't work. That's why I'm here, asking a more experienced user to check and help me with the specific and right settings.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [12 June 2019 10:00 UTC](https://discourse.nodered.org/t/ttn-payload-to-inluxdb/12094/8 "2019-06-12T10:00:34Z")

</div>

> [@HaVi](#):
>
> If the _measurement_ field is not set in the node configuration, the user can send in data with a specified measurement name in **msg.measurement** to overwrite the _measurement_ field in the configuration of the node.

What have you done to achieve that?

---

<div class="post-metadata">

**Author:** ![HaVi](https://avatars.discourse-cdn.com/v4/letter/h/b3f665/32.png) [@HaVi](https://discourse.nodered.org/u/HaVi)\
**Post date:** [12 June 2019 10:58 UTC](https://discourse.nodered.org/t/ttn-payload-to-inluxdb/12094/9 "2019-06-12T10:58:34Z")

</div>

I've tried them all:

_msg.measurement  
msg.echteld  
echteld  
payload.echteld  
msg.payload  
payload  
object  
payload.object  
payload.object.echteld  
object.echteld_

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [12 June 2019 12:43 UTC](https://discourse.nodered.org/t/ttn-payload-to-inluxdb/12094/10 "2019-06-12T12:43:36Z")

</div>

Show us your flow where you are doing what the info says, which is to provide the measurement name in msg.measurement, or just to put the measurement name in the node if it is fixed. In the image you posted earlier you told the node to use a measurement named "msg.payload.echteld", which I assume is not what the measurement is named.

---

<div class="post-metadata">

**Author:** ![HaVi](https://avatars.discourse-cdn.com/v4/letter/h/b3f665/32.png) [@HaVi](https://discourse.nodered.org/u/HaVi)\
**Post date:** [12 June 2019 15:30 UTC](https://discourse.nodered.org/t/ttn-payload-to-inluxdb/12094/11 "2019-06-12T15:30:37Z")

</div>

The measurement named "msg.payload.echteld" was one of many, please see the list of all I tried in the above post.

Just did a fresh new install of NodeRED but the problem stays the same.

This is my flow (TTN access key edited with xxxxxxxxxx):

```auto
[{"id":"3588197a.a23a96","type":"tab","label":"Testen","disabled":false,"info":""},{"id":"879ea9fe.24c108","type":"ttn uplink","z":"3588197a.a23a96","name":"LSN-50","app":"b1ba9763.8396f8","dev_id":"dragino-nap","field":"","x":190,"y":160,"wires":[["7aa54d21.346504","ce83de4.9a66c2"]]},{"id":"ce83de4.9a66c2","type":"debug","z":"3588197a.a23a96","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":370,"y":260,"wires":[]},{"id":"7aa54d21.346504","type":"influxdb out","z":"3588197a.a23a96","influxdb":"23461b4.ab202e4","name":"Waterstanden","measurement":"echteld","precision":"","retentionPolicy":"","x":400,"y":140,"wires":[]},{"id":"b1ba9763.8396f8","type":"ttn app","z":"","appId":"dragino-nap","accessKey":"ttn-account-v2.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx","discovery":"discovery.thethingsnetwork.org:1900"},{"id":"23461b4.ab202e4","type":"influxdb","z":"","hostname":"192.168.2.185","port":"8086","protocol":"http","database":"waterstanden","name":"Waterstanden","usetls":false,"tls":""}]

```

This is the complete debug output:

 ![payload](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/c/c18672ba542864fee9e3378d0ad72eb8e6fec46a.jpeg)

---

<div class="post-metadata">

**Author:** ![ukmoose](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ukmoose/32/13_2.png) [@ukmoose](https://discourse.nodered.org/u/ukmoose)\
**Post date:** [12 June 2019 15:47 UTC](https://discourse.nodered.org/t/ttn-payload-to-inluxdb/12094/12 "2019-06-12T15:47:18Z")

</div>

this page will explain how to get the right path to data (assuming it’s not a buffer).

[https://nodered.org/docs/user-guide/messages](https://nodered.org/docs/user-guide/messages)

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [12 June 2019 16:07 UTC](https://discourse.nodered.org/t/ttn-payload-to-inluxdb/12094/13 "2019-06-12T16:07:11Z")

</div>

> [@HaVi](#):
>
> The measurement named "msg.payload.echteld" was one of many

Do you mean the actual name of the measurement is msg.payload.echteld or that the measurement name is in msg.payload.echteld?

---

<div class="post-metadata">

**Author:** ![HaVi](https://avatars.discourse-cdn.com/v4/letter/h/b3f665/32.png) [@HaVi](https://discourse.nodered.org/u/HaVi)\
**Post date:** [12 June 2019 16:07 UTC](https://discourse.nodered.org/t/ttn-payload-to-inluxdb/12094/14 "2019-06-12T16:07:48Z")

</div>

Thanks ukmoose but the Influxdb Out Node should work without this all. As far as I know...

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [12 June 2019 16:20 UTC](https://discourse.nodered.org/t/ttn-payload-to-inluxdb/12094/15 "2019-06-12T16:20:05Z")

</div>

> [@HaVi](#):
>
> he Influxdb Out Node should work without this all

You have to put the data in the right attributes of the message as defined in the Info tab for the influx node.

---

<div class="post-metadata">

**Author:** ![HaVi](https://avatars.discourse-cdn.com/v4/letter/h/b3f665/32.png) [@HaVi](https://discourse.nodered.org/u/HaVi)\
**Post date:** [12 June 2019 16:39 UTC](https://discourse.nodered.org/t/ttn-payload-to-inluxdb/12094/16 "2019-06-12T16:39:00Z")

</div>

The node info screen shows the node is not critical because it handles strings, numbers and booleans from "msg.payload". So it should at least write something to the database when the measurement field is filled in with one of the terms as show in the list above. But is does not.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [12 June 2019 18:21 UTC](https://discourse.nodered.org/t/ttn-payload-to-inluxdb/12094/17 "2019-06-12T18:21:11Z")

</div>

Please answer the question that I have asked multiple times: Is the name of the measurement "msg.payload.echteld" or is the name of the measurement to be found _inside_ msg.payload.echteld?

---

<div class="post-metadata">

**Author:** ![HaVi](https://avatars.discourse-cdn.com/v4/letter/h/b3f665/32.png) [@HaVi](https://discourse.nodered.org/u/HaVi)\
**Post date:** [12 June 2019 18:31 UTC](https://discourse.nodered.org/t/ttn-payload-to-inluxdb/12094/18 "2019-06-12T18:31:57Z")

</div>

The name of the measurement is "echteld" and is inside msg.payload.echteld. Please see the image of the complete debug output above, this answers i.m.o. your question or maybe I am wrong?

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [12 June 2019 18:51 UTC](https://discourse.nodered.org/t/ttn-payload-to-inluxdb/12094/19 "2019-06-12T18:51:25Z")

</div>

Right, ok so I see from your flow that you now have echteld in the measurement so that should be ok,  
Next the data to be written to that measurement must be in msg,payload and I see that is `{echteld: 3908}` so that should write that value to the field echteld of the measurement echteld. So when you run it what do you see? Any errors or anything?

---

<div class="post-metadata">

**Author:** ![HaVi](https://avatars.discourse-cdn.com/v4/letter/h/b3f665/32.png) [@HaVi](https://discourse.nodered.org/u/HaVi)\
**Post date:** [12 June 2019 19:07 UTC](https://discourse.nodered.org/t/ttn-payload-to-inluxdb/12094/20 "2019-06-12T19:07:52Z")

</div>

Thanks again! No error messages, NodeRED reports "succesfully deployed". After disabling the debug node no messages or whatever are shown in the debug window which is correct isn't it? When sending a payload via The Things Network no error messages or whatever are shown until I enable the debug node. Thereafter the correct payload is shown in the debug window, but still no error messages.

To be sure I've re-installed InfluxDB on my RPi but this makes no difference.

[Next page](https://discourse.nodered.org/t/ttn-payload-to-inluxdb/12094.md?page=2)
