I am reading accelerometer data from chip and sending it to the server and my node red is subscribed to the topic that reads the accelerometer data.
In Node Red, I am using function node with the following code:
var NewBuffer = Buffer.from(msg.payload, 'base64');
var decoded_msg = NewBuffer.toString('ascii');
//To remove u+Z from the start of output string
decoded_msg = decoded_msg.substr(3,msg.payload.length);
msg.payload = decoded_msg;
I can see the output string decoded into ASCII but sometimes when I gave sudden movements to accelerometer chip, my output data starts collecting miscellaneous characters in the end.
I could not find the reason why it is collecting the random data at the end of string.
I would really appreciate any help.