MQTT Topic TTN

I don’t think that is the decoder you are using as your message clearly contains a number with the additional “mm” and that is not added in this decoder.

To store the distance in a usable format I think you need just a number. That way you can use it for calculations and graphs, if you store it as a string (which would be required to store the mm) you can’t use it without transformation so no way to have the database calculate average, min, max etc. Or use a tool like grafana to create graphs.

Yes I wasn’t using that decoder you are 100% right. but after your tip I changed the decoder. I copied the Dragino Decoder and deleted the “mm” now I’m getting the distance without the “mm”.

Okay, this makes a lot of sense… So it would be dump to store it with that because I want to store it to visualise it in Grafana

I will now have a look if I can get it to work but I also think there is an additional problem with my “Influxdb Node”.

But Thank you for your help and your tips!

Good morning.
Now im getting my data as a “number” in the "
msg.Distanz"
Screenshot (26)

I used a change node to write the Distance as a number into the msg.Distanz.
I assume this is exactly the data type I need and I can write into the Db, right?
Now I want to write the distant into the databank.
But with the settings in my “influxdb out” node I’m getting an parsing error:

Error: A 400 Bad Request error occurred: {"error":"unable to parse 'distanzquelle

Screenshot (29)
Screenshot (30)
Screenshot (32)

How is your change node set up?

Good morning.
its a basic setting where i just writing the distance into the msg.Distanz.
I assume the “influxdb” Node is still getting the whole string?

Thank you very much in advance!
Screenshot (33)

image
Can’t see 1/2 a of the “msg.payload.uplink_me…”

If you don’t answer the questions asked originally and following some guides and post1/2 information, nobody can guess or help you.

If you posted the correct information, could have helped you 6 day ago.

1 Like

Oh yes, you are right…completely forgot… I wanted to send the msg…
I’m sorry for this…

payload.uplink_message.decoded_payload.Distance

I’m very sorry for being that complicated about this and I want to apologise for this and also want to thank you for your time and nerves about this.
But I did my best to give you guys everything you want.

Which information you are referring to right now?
Well as I said before I’m sorry for this but I was trying my best…

Post this so we can make sure the decoder is working correctly.

Then we can give attention to the change node and last to make sure the data is correct in the DB.

Good morning.
In the screenshot below you can see the payload directly after the “MQTT node” as requested.
Screenshot (36)
As you can see the payload is decoded as a Java object payload and the distance is printed without the mm.

Thank you very much in advance.

Ok.

Now make sure your change node does it’s job correctly. For the two highlighted fields I will copy and past from the JSON, as typos are easy to be made.

There is a button on the right of the debug window that does this job.
85R6RbPvqs

I will wright the EUI and the sensor value to the DB, if I were you.

image

Now check the JSON form the change node and see if that is correct.

Thank you for your reply as well in this topic!

Im saving both of them so I now exactly which device made this measurement?

You mean I need to check what I’m getting after the change node?
As far as I understand what you want me to know I made to debug nodes. One with the “msg.payload” and one with the “msg.dev_eui”.
is this what you meant?

Thank you very much in advance!

Yes, as you can use the same DB for all your sensors.

Put the debug node and post the JSON

Thank you for your reply!

Screenshot (38)
As you can see I’m having some trouble with the change node or to be more precise with the “dev_eui”.
I configured the change node as I posted in the picture before but I’m getting the message that the “msg.dev_eui” is undefined.

I’m not sure why…

Cool!

Did you use the “Copy Path” button in node-red?

Yes, I did and it copied the path I posted before.
I will try to copy the application_id for identification. there’s only one Node in this application and there will be no other Node.
That should be okay to identify the device.

Are there a value in the “dev_eui”? As TTN always forwards this…

What happens if you decide you need a second device?

Screenshot (39)
Yes there is a value in the “dev_eui” row.

Then everything would be broken…
You are right… in two years or so I probably don’t know this anymore and would add another device…

But im not sure why this is happening… I meant there is a dev_eui so why is it saying its undefined?

What bugs me is that you getting two separate JSON, one for the “Distance” and “dev_eui” out of the change node, that all should be in the same JSON.

Well, I’m getting them in two because we are making two or am I wrong?
msg.payload and msg.dev_eui.

Copy and past your flow from node-red, then I can look.

Don’t worry Node-red leaves all the keys and passwords out.