# Avoid the ? in the msg.payload

**URL:** <https://discourse.nodered.org/t/avoid-the-in-the-msg-payload/79360>\
**Category:** General\
**Created:** [23 June 2023 05:37 UTC](https://discourse.nodered.org/t/avoid-the-in-the-msg-payload/79360 "2023-06-23T05:37:12Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vaibhavi27](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/vaibhavi27/32/70897_2.png) [@Vaibhavi27](https://discourse.nodered.org/u/Vaibhavi27)\
**Post date:** [23 June 2023 05:37 UTC](https://discourse.nodered.org/t/avoid-the-in-the-msg-payload/79360/1 "2023-06-23T05:37:12Z")

</div>

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](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/0/006a9d29dc788d4e232e3dcaf289c2bfdfc953ca.png)

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [23 June 2023 05:46 UTC](https://discourse.nodered.org/t/avoid-the-in-the-msg-payload/79360/2 "2023-06-23T05:46:37Z")

</div>

What value (s) are you expecting?

Is this a specific protocol?

What is on the other end of the serial port?

---

<div class="post-metadata">

**Author:** ![Vaibhavi27](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/vaibhavi27/32/70897_2.png) [@Vaibhavi27](https://discourse.nodered.org/u/Vaibhavi27)\
**Post date:** [23 June 2023 06:01 UTC](https://discourse.nodered.org/t/avoid-the-in-the-msg-payload/79360/3 "2023-06-23T06:01:16Z")

</div>

Hi,

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

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [23 June 2023 06:02 UTC](https://discourse.nodered.org/t/avoid-the-in-the-msg-payload/79360/4 "2023-06-23T06:02:20Z")

</div>

Did you write the code in the Arduino?

Show us what it sends.

---

<div class="post-metadata">

**Author:** ![Vaibhavi27](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/vaibhavi27/32/70897_2.png) [@Vaibhavi27](https://discourse.nodered.org/u/Vaibhavi27)\
**Post date:** [23 June 2023 06:03 UTC](https://discourse.nodered.org/t/avoid-the-in-the-msg-payload/79360/5 "2023-06-23T06:03:43Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Vaibhavi27](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/vaibhavi27/32/70897_2.png) [@Vaibhavi27](https://discourse.nodered.org/u/Vaibhavi27)\
**Post date:** [23 June 2023 06:05 UTC](https://discourse.nodered.org/t/avoid-the-in-the-msg-payload/79360/6 "2023-06-23T06:05:27Z")

</div>

![Screenshot 2023-06-23 113436](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/6/86f7e714163cfd52222dde56f208de9b48508fe1.png)

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [23 June 2023 08:33 UTC](https://discourse.nodered.org/t/avoid-the-in-the-msg-payload/79360/7 "2023-06-23T08:33:11Z")

</div>

> [@Steve-Mcl](#):
>
> Did you write the code in the Arduino?

Did you?

> [@Vaibhavi27](#):
>
> But the thing is these data(s) are in string which I want it to be in numbers.

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

```auto
{
  "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.

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

```

---

<div class="post-metadata">

**Author:** ![Vaibhavi27](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/vaibhavi27/32/70897_2.png) [@Vaibhavi27](https://discourse.nodered.org/u/Vaibhavi27)\
**Post date:** [23 June 2023 08:58 UTC](https://discourse.nodered.org/t/avoid-the-in-the-msg-payload/79360/8 "2023-06-23T08:58:47Z")

</div>

Dear Concern,

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

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [23 June 2023 09:17 UTC](https://discourse.nodered.org/t/avoid-the-in-the-msg-payload/79360/9 "2023-06-23T09:17:59Z")

</div>

> [@Vaibhavi27](#):
>
> I have just read data from AnalogPin

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.

---

<div class="post-metadata">

**Author:** ![Vaibhavi27](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/vaibhavi27/32/70897_2.png) [@Vaibhavi27](https://discourse.nodered.org/u/Vaibhavi27)\
**Post date:** [23 June 2023 11:08 UTC](https://discourse.nodered.org/t/avoid-the-in-the-msg-payload/79360/11 "2023-06-23T11:08:52Z")

</div>

Thanks for the insight!! I will try with ArduinoJson

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [22 August 2023 11:09 UTC](https://discourse.nodered.org/t/avoid-the-in-the-msg-payload/79360/12 "2023-08-22T11:09:45Z")

</div>

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