I have an Arduino connected serially to my Raspberry Pi where I have node-red running. Arduino is sensing temperature data from the sensor and is send to Raspberry Pi.
Everything is working perfect but I have one question, in the debug I am having data in String format with "length=7" but in debug window, the msg.payload shows the String of "length=9" shown in figure below.
Why there is an extra character in msg.payload?
With the information you have given it is impossible to say, it is not even clear which debug node on the flow is showing that data. If you can select just the nodes needed to show the problem and Export those and paste them here, and explain in more detail what you are seeing, that may help. Read this for help with how to paste a flow here
Better if you can show us how you build the strings, as Colin mentioned above. My guess is that your logic is somehow encoding an escaped null characther (just a guess). This is typical of C (the language) strings.
I am sorry I was not able to clear my point. I have temperature data coming serially from Arduino and I am just observing the output as msg.payload. The temperature data is in String format and I want to find the length of that string.
The problem is when I get this string data, in the debug window(please see the figure below) you can see in red box e.g the temperature data is "24.69,2", which should have the length of 7 but in actual it is 9. There is one "arrow" character in the green box(it has two characters), I want get rid of these additional characters.
Yes, exactly! Can I get rid of this null character? I am 100% sure that the data coming from Arduino has no additional line or null character like "\0" or "\n".