Avoid the ? in the msg.payload

Hii,

The data coming from the serial monitor has ? error coming in between the msg.payload:string

I have no idea how to avoid those.

Screenshot 2023-06-23 110417

What value (s) are you expecting?

Is this a specific protocol?

What is on the other end of the serial port?

Hi,

Actually a sensor value from the Arduino via Serial in node with delay of 1000ms.

Did you write the code in the Arduino?

Show us what it sends.

I wanted these auto log in csv file. with timestamp and these sensor values.
But the thing is these data(s) are in string which I want it to be in numbers. Hence yet I haven't come up with any solution yet.

Did you?

If you had answered the above, I would suggest you send JSON data as it can be converted into actual meaningful values.

e.g. if you send

{
  "deviceId": "44:3f:25:a1:4e:3e",
  "dataId": "temperature"
  "value": 23.6
}

You can simply send this through a JSON node and get actual object with correct numbers and strings all automagically parsed out for you. And it is extensible so if you add "UoM" af a future point, nothing breaks.

{
  "deviceId": "44:3f:25:a1:4e:3e",
  "dataId": "temperature"
  "value": 23.6,
  "UoM": "°C"
}

Dear Concern,

I have just read data from AnalogPin. Same I have fetched via serial in.

ok, that doesnt mean you cannot transmit valid JSON from aurduino to make the Node-RED side cleaner and easier to consume and auto parse/convert numbers and strings back into the intended format/types.

Also, if you "just read data from AnalogPin" and send that, then your issue is in the arduino program - it is possible you need to do something different to the data to generate correct transmission format.

Thanks for the insight!! I will try with ArduinoJson

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.