# Required Hex format in Serialwrite Node

**URL:** <https://forums.losant.com/t/required-hex-format-in-serialwrite-node/1898>\
**Category:** Help\
**Tags:** edge\
**Created:** [June 18, 2019, 7:17am UTC](https://forums.losant.com/t/required-hex-format-in-serialwrite-node/1898 "2019-06-18T07:17:38Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![sivasankari\_s](https://avatars.discourse-cdn.com/v4/letter/s/d26b3c/32.png) [@sivasankari\_s](https://forums.losant.com/u/sivasankari_s)\
**Post date:** [June 18, 2019, 7:17am UTC](https://forums.losant.com/t/required-hex-format-in-serialwrite-node/1898/1 "2019-06-18T07:17:38Z")

</div>

Hi,  
When we send Hex value from Losant Framework using  
Serial Write Node(in Edge Work Flow),it will transmit the ASCII Value,But we need Hex value.Do we have any specific format for sending Hex value?  
For the same here I have shared my screen shots.  
Screenshot 1:  
 ![SerialWritenode1](https://us1.discourse-cdn.com/flex015/uploads/getstructure/original/2X/6/6f5d8a30d189c98be5e8141e43c76bbb9e17818b.gif)  
Screenshot 2:

 ![Bug%20in%20Losant%20Serial_Write](https://us1.discourse-cdn.com/flex015/uploads/getstructure/original/2X/3/352238c98c53b57d0309069749ee578c112a1a24.gif)

If you have any specific format for sending Hexvalue in SerialWriteNode,  
Kindly share me the details.

Thanks  
Sivasankari S

---

<div class="post-metadata">

**Author:** ![JuliaKempf](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.losant.com/juliakempf/32/2446_2.png) [@JuliaKempf](https://forums.losant.com/u/JuliaKempf)\
**Post date:** [June 18, 2019, 3:59pm UTC](https://forums.losant.com/t/required-hex-format-in-serialwrite-node/1898/2 "2019-06-18T15:59:57Z")

</div>

Hi @sivasankari_s,

I believe the problem could be related to the spaces you have in the Write Template, so I would test that first. Since you denoted hex, I believe the template is looking for only 16 characters. Try removing the spaces and see if the Serial Write Node performs as expected.

Thanks!  
Julia

---

<div class="post-metadata">

**Author:** ![sivasankari\_s](https://avatars.discourse-cdn.com/v4/letter/s/d26b3c/32.png) [@sivasankari\_s](https://forums.losant.com/u/sivasankari_s)\
**Post date:** [June 19, 2019, 9:15am UTC](https://forums.losant.com/t/required-hex-format-in-serialwrite-node/1898/3 "2019-06-19T09:15:18Z")

</div>

Hi Julia,  
Thanks for your prompt reply. I have tried with space and without space and 0x prefix in each Hex value,But It’s not working.

if I send this value via serial write node with following configuration  
Serial Path:/dev/ttyUSB0  
BaudRate:9600  
Write Template :0A 03 00 81 00 02 95 58(with space Example)  
Result in coolTerm : 30 41 20 30 33 20 30 30 20 38 31 20 30 30 20 30 32 20 39 35 20 35 28

which means losant transmit the Hex value in following method.

0 A Space 0 3 space 0 0 space  
30 41 20 30 33 20 30 30 20 38 31 20 30 30 20 30 32 20 39 35 20 35 28.

if I send Hex Value without space like this 0A03008100029558,My result  
was 30 41 30 33 30 30 38 31 30 30 30 32 39 35 35 28.  
Only space Hex value 20 removed in cool term.

But My Correct device(Energy meter) result is when i send 8byte in write node the result should come 9 bytes,which is the correct format.

Thanks  
Sivasankari S

---

<div class="post-metadata">

**Author:** ![anaptfox](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.losant.com/anaptfox/32/873_2.png) [@anaptfox](https://forums.losant.com/u/anaptfox)\
**Post date:** [June 19, 2019, 4:08pm UTC](https://forums.losant.com/t/required-hex-format-in-serialwrite-node/1898/4 "2019-06-19T16:08:53Z")

</div>

Hi @sivasankari_s,

The “Write Encoding” here is converting the string you have into it’s `Hex` representation. Since it’s already encoded have you tried sending it using `utf8` as the “Write Encoding”?

---

<div class="post-metadata">

**Author:** ![sivasankari\_s](https://avatars.discourse-cdn.com/v4/letter/s/d26b3c/32.png) [@sivasankari\_s](https://forums.losant.com/u/sivasankari_s)\
**Post date:** [July 13, 2019, 1:58pm UTC](https://forums.losant.com/t/required-hex-format-in-serialwrite-node/1898/5 "2019-07-13T13:58:09Z")

</div>

> [@anaptfox](#):
>
> The “Write Encoding” here is converting the string you have into it’s `Hex` representation. Since it’s already encoded have you tried sending it using `utf8` as the “Write Encoding”?

I have tried ‘utf8’ but still not working.  
if i send ascii method in serial writenode its working perfectly but if i send Hex method  
in serial write node its not working.  
I have listed my process below.  
In my ‘Energy Meter’ Only accept Hex Code.if i write 0A 03 00 81 00 02 95 58 in serial write node and deployed edge gateway and I got serial result true.But my serial read node not reply to me this is because of Hex Code not sending Hexformat ,losant serial write node considered Hex Code as ASCII.  
please share me how to write HexCode in Serialwrite Node.

Thanks  
Sivasankari S.

---

<div class="post-metadata">

**Author:** ![JuliaKempf](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.losant.com/juliakempf/32/2446_2.png) [@JuliaKempf](https://forums.losant.com/u/JuliaKempf)\
**Post date:** [July 14, 2019, 10:56pm UTC](https://forums.losant.com/t/required-hex-format-in-serialwrite-node/1898/6 "2019-07-14T22:56:46Z")

</div>

Hi @sivasankari_s,

Could you provide a screenshot of your current node configuration, and any other relevant screenshots?

Thanks!  
Julia

---

<div class="post-metadata">

**Author:** ![sivasankari\_s](https://avatars.discourse-cdn.com/v4/letter/s/d26b3c/32.png) [@sivasankari\_s](https://forums.losant.com/u/sivasankari_s)\
**Post date:** [July 15, 2019, 6:02am UTC](https://forums.losant.com/t/required-hex-format-in-serialwrite-node/1898/7 "2019-07-15T06:02:05Z")

</div>

![Bug%20in%20Losant%20Serial_Write](https://us1.discourse-cdn.com/flex015/uploads/getstructure/original/2X/3/352238c98c53b57d0309069749ee578c112a1a24.gif)

I have deployed the above work flow to my edge gateway.  
I have Connected My “Energymeter” to this port “/dev/ttyUSB0” and  
my Energy Meter only accept the Hex Code not ASCII and others.  
I got “serialwriteresult:true” but i didn’t get any reply from the Energy Meter.  
I have tried with space and without space in write template but it is not working.

Thanks  
Sivasankari S

---

<div class="post-metadata">

**Author:** ![JuliaKempf](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.losant.com/juliakempf/32/2446_2.png) [@JuliaKempf](https://forums.losant.com/u/JuliaKempf)\
**Post date:** [July 16, 2019, 7:37pm UTC](https://forums.losant.com/t/required-hex-format-in-serialwrite-node/1898/8 "2019-07-16T19:37:50Z")

</div>

Hi @sivasankari_s,

The configuration you currently have is going to hex encode the string is your Write Template. Since you have your hex value in the Write Template, this hex value will be hex encoded _again_, resulting in the long hex value on your device:

```auto
0A 03 00 81 00 02 95 58->Hex Encode->30 41 20 30 33 20 30 30 20 38 31 20 30 30 20 30 32 20 39 35 20 35 28

```

If you remove the spaces from your write Write Template (0A03008100029558) and set your Write Encoding to `UTF8`, what do you see in your serial monitor and workflow?

Thanks!  
Julia

---

<div class="post-metadata">

**Author:** ![sivasankari\_s](https://avatars.discourse-cdn.com/v4/letter/s/d26b3c/32.png) [@sivasankari\_s](https://forums.losant.com/u/sivasankari_s)\
**Post date:** [July 19, 2019, 10:54am UTC](https://forums.losant.com/t/required-hex-format-in-serialwrite-node/1898/9 "2019-07-19T10:54:32Z")

</div>

![SerialWrite](https://us1.discourse-cdn.com/flex015/uploads/getstructure/original/2X/2/2c235c7f0a81bbffba3ca2faba58774668c15c6f.png)

 ![SerialRead](https://us1.discourse-cdn.com/flex015/uploads/getstructure/original/2X/0/04f171bca77630cfa56091c33857066d3aedb146.png) ![SerialWriteResult](https://us1.discourse-cdn.com/flex015/uploads/getstructure/original/2X/e/e217e58a4bb6f8eb45568848844826a4c785f6e7.png)

Hi Julia,  
I have set my write encoding as UTF8 and I got SerialWriteResult true but My Energymeter not replied anything, regarding this i have enclosed the above screens.if you have any suggesstion for the above screen ,kindly share me.

Thanks,  
Sivasankari S
