Function to decrypt Base64 data from Node-Red and display on dashboard

Hello,
Please, i am a bit confused on my project now. I am building a Lora communication system for sensor monitoring, I have 2 nodes which have Voltage and Current sensors connected to them at different frequencies. The nodes send those sensor values to the Lora gateway which i do not want to forward to TTN. so I use a combination of TCPDUMP and Node-Red to trap the data traffic and now i have them on the Node-Red with the flow i just showed. my TCPDUMP log is also shown with the data and also the Node-Red debug result is also shown.
My challenge is to separate the data for the different frequencies which is highlighted in the picture and is in Base64 format and be decrypted to be able to post on the dashboard.
Please,I need help with the function to carry this out.

Your help is truely appreciated

First you need to make that into a Javascript object so pass it through a JSON node - then there’s a great page in the docs that will explain how to use the debug panel to find the right path to any data item.

https://nodered.org/docs/user-guide/messages

and there is also a node-red-node-base64 to unpack a base64 message... -

but there are also some TTN nodes that may do it all for you on flows.nodered.org.

Thank you very much for your reply,
I am really confused as i am new to node red. how do i go about making it into a Javascript object

as per I said above...

please what setting do i use on the JSON node bcause i have don that and now i get no output at the debug

nothing to set - connect it before the debug that gave you

i have done as you requested and below is my output.

If you look at you screenshot of your debug

The JSON node can cope with the first
You would need to filter the second (use a switch node)
But the third one contains noise before the JSON.
Is that noise always the same?

please which of the debug are you referring to

See the attachment to your first post: https://global.discourse-cdn.com/flex016/uploads/nodered/original/2X/b/bb6511fa9a53aa5d968d5a534a60f6278b0cdec4.png

It shows 3 debug messages. The first shown in node Type debug is a JSON string. The second for node tcpdump debug is a regular string, not JSON, and has a : in position 2 (zero indexed) which would explain your error. The third debug message is again for tcpdump debug and now has a JSON string, but starts with a bunch of noise. What @ukmoose is asking is if the noise for this 3rd debug message is consistent, because if so you can use a function node to cut it all off. However seeing the 2nd message it means that the noise is not consistent because that one had a header message for the incoming TCP data.

The problem that you're dealing with is that the data that's coming in through the TCPDump node does not have just JSON strings, but noise and other data in between. Meaning you have to filter out the noise first, until you keep a clean JSON string. Then push that clean string through a JSON node. If you keep having questions, go back to the basics of Node-RED. The user guide is a good place to getting started, and the link for dealing with messages that Dave posted (as seen below) is essential reading material.

The forum software adds a helpful badge next to a link to show how many times it has been clicked. Dave's post is still missing the badge meaning the link has not been clicked. Going (back) to the documentation and starting there would be a good way to figure out how to solve your problem, especially if you are new to Node-RED like you said.

Good luck, and ask again if needed, but don't forget to go back to suggestions you've received before. After all, everything can help in the end :slight_smile:

On top of that a question. I don't have a TTN gateway myself, but I'm waiting for a PyCom LoRa gateway to arrive. This one is capable of keeping messages local, and not forwarding them to TTN. Because of my lack of owning a TTN gateway, I'm wondering if that's not a common thing. Is it possible to set up your gateway so that it will not forward these to TTN itself, but rather keep them local? That way you wouldn't have to mess with TCP dump.

Thanks all, i will look into your suggestions and get back to you with any developments

Hello,
Thanks for all your contributions, now am stuck again. I now have the object being displayed on the debug as i have shown in the images with the various components. My aim is to extract the data for each frequency and then convert from base64 before displaying on the dashboard. I have tried alot of option from the guide but to no avail. please if anyone can help me to be able to extract these data for the different frequencies so that i can make guages for each frequencyobject object%202

If you want them on different pieces of the dashboard your first step should be to separate messages from different frequencies.

You can do this with the standard switch node set to the frequency

Thanks @ukmoose so you mean in the switch node i just type the needed frequency or what because to get to this i just used the node and typed this {"rxpk": in the contains area. please if there is an exact thing to type you can let me know

Take a look at the "working with messages" page in the docs which will show you how to use the debug node and panel in order to find the correct path to any piece of data.

Thank you @ukmoose for suggestions. i followed them and now i have two debug nodes show my values. but i have on last problem. These values are separated by a comma, the first value is current followed by the comma and the voltage. now i want to display this on a dashboard but do not know how to go about this. my output is as shown below in the diagramdata

Well that will depend on how you want to display it on the dashboard.
But first you will need to convert the string into a javascript object. Which you could do in a function node ( which I see you are already used to using so I'm sure you can work out how)

But step one would be to read the dashboard nodes info panel so you can see what data format they take for the different type of displays.

Yea boss,
but my problem is how i can separate the numbers based on the comma between them, how can i say this current and voltage

There are lots of tutorials online
https://www.google.com/search?q=how+to+split+on+comma+in+node-red