# Node-RED-Modbus RTU CRC error

**URL:** <https://discourse.nodered.org/t/node-red-modbus-rtu-crc-error/40877>\
**Category:** Industrial\
**Created:** [12 February 2021 16:04 UTC](https://discourse.nodered.org/t/node-red-modbus-rtu-crc-error/40877 "2021-02-12T16:04:09Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![F\_R](https://avatars.discourse-cdn.com/v4/letter/f/e99b99/32.png) [@F\_R](https://discourse.nodered.org/u/F_R)\
**Post date:** [12 February 2021 16:04 UTC](https://discourse.nodered.org/t/node-red-modbus-rtu-crc-error/40877/1 "2021-02-12T16:04:09Z")

</div>

Hello,

i am new in using Node-RED, i try to communicate with a TH-AP Sensor with Modbus RTU. I get a Request on the Bus but the is any error in the Data Flow. Here you can see my settings from the USB-RS485 Interface and from my work Flow and the Errors. I hope i can geet anny help about my problem.

 ![2021-02-12 16_59_59-Window](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/e/1/e11ca0f065c56d0e6180eb21476c51f37e0d2a59.png) ![2021-02-12 17_00_25-Window](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/6/f61efaf7eb2f865be1e16805ad652ff144440255.png)

---

<div class="post-metadata">

**Author:** ![F\_R](https://avatars.discourse-cdn.com/v4/letter/f/e99b99/32.png) [@F\_R](https://discourse.nodered.org/u/F_R)\
**Post date:** [12 February 2021 16:06 UTC](https://discourse.nodered.org/t/node-red-modbus-rtu-crc-error/40877/2 "2021-02-12T16:06:23Z")

</div>

![2021-02-12 17_02_06-Window](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/1/611157b33cff724f6379a75d7d6dd05003b928ad.png)

The Datasheet from the device is.

> **[download](https://www.elsner-elektronik.de/shop/de/fileuploader/download/download/?d=1&file=custom%2Fupload%2F30170_30172_T-AP-Modbus_TH-AP-Modbus_Datenblatt.pdf)**
>
> 504.16 KB

---

<div class="post-metadata">

**Author:** ![F\_R](https://avatars.discourse-cdn.com/v4/letter/f/e99b99/32.png) [@F\_R](https://discourse.nodered.org/u/F_R)\
**Post date:** [12 February 2021 16:44 UTC](https://discourse.nodered.org/t/node-red-modbus-rtu-crc-error/40877/3 "2021-02-12T16:44:02Z")

</div>

Here is the flow export:  
[{"id":"96a6adf6.fea4d8","type":"modbus-read","z":"22176d01.2807aa","name":"","topic":"","showStatusActivities":true,"logIOActivities":true,"showErrors":true,"unitid":"1","dataType":"InputRegister","adr":"0","quantity":"3","rate":"1","rateUnit":"s","delayOnStart":false,"startDelayTime":"","server":"c798025a.13bcf8","useIOFile":true,"ioFile":"c7b5fb16.23291","useIOForPayload":true,"emptyMsgOnFail":false,"x":310,"y":340,"wires":[["330cf08f.d193b","cd4b95dd.699d5"],["775859f2.3e6f1","ec01dacb.70f0b","6a3aef4f.ff668"]]},{"id":"c798025a.13bcf8","type":"modbus-client","name":"","clienttype":"serial","bufferCommands":true,"stateLogEnabled":true,"queueLogEnabled":true,"tcpHost":"127.0.0.1","tcpPort":"502","tcpType":"DEFAULT","serialPort":"/dev/ttyUSB1","serialType":"RTU","serialBaudrate":"19200","serialDatabits":"8","serialStopbits":"1","serialParity":"even","serialConnectionDelay":"100","unit\_id":"1","commandDelay":"1","clientTimeout":"1000","reconnectOnTimeout":true,"reconnectTimeout":"2000","parallelUnitIdsAllowed":true},{"id":"c7b5fb16.23291","type":"modbus-io-config","name":"mod","path":"mod.log","format":"utf8","addressOffset":""}]

---

<div class="post-metadata">

**Author:** ![UnborN](https://avatars.discourse-cdn.com/v4/letter/u/4491bb/32.png) [@UnborN](https://discourse.nodered.org/u/UnborN)\
**Post date:** [12 February 2021 22:59 UTC](https://discourse.nodered.org/t/node-red-modbus-rtu-crc-error/40877/4 "2021-02-12T22:59:29Z")

</div>

Hi .. from the documentation it seems that the temperature is a 16bit value read only from one address 0

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/a/3adafaff378f1828b9d84c54f34e8a8a6aaa51bd.png)

What happens if you change in your settings instead of Quantity 3 to only **1**

---

<div class="post-metadata">

**Author:** ![F\_R](https://avatars.discourse-cdn.com/v4/letter/f/e99b99/32.png) [@F\_R](https://discourse.nodered.org/u/F_R)\
**Post date:** [13 February 2021 09:29 UTC](https://discourse.nodered.org/t/node-red-modbus-rtu-crc-error/40877/5 "2021-02-13T09:29:30Z")

</div>

Hello,

thanks fpr the answer i have change the quanti to 1 and i get this erros:  
 ![2021-02-13 10_25_37-Window](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/b/7be15d9ed21a475660b3bc095590e794b7cf387c.png) ![2021-02-13 10_25_55-Window](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/a/1a53cd97dab6bd10b04e1a0577659191684e9475.png)

I don´t understand why it don´t work. on the device is a communication led the LED is blinking orange thats good, because the error led is off. The terminierung is set on the device.

---

<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:** [13 February 2021 09:38 UTC](https://discourse.nodered.org/t/node-red-modbus-rtu-crc-error/40877/6 "2021-02-13T09:38:21Z")

</div>

That might be an issue with your installation or the node. `fs-extra` is either missing from your installation or damaged.

There are a few things to try...

1st, does the modbus nodes have some kinda file logging built in? Turn it off, does the error still happen.

2nd, reinstall the modbus nodes. Do you still get the fs-extra issue?

3rd, manually install fs-extra

---

<div class="post-metadata">

**Author:** ![F\_R](https://avatars.discourse-cdn.com/v4/letter/f/e99b99/32.png) [@F\_R](https://discourse.nodered.org/u/F_R)\
**Post date:** [13 February 2021 10:00 UTC](https://discourse.nodered.org/t/node-red-modbus-rtu-crc-error/40877/7 "2021-02-13T10:00:53Z")

</div>

Hello,

thanks for the fast feedback, i have do no.1 so the first problem is fixed.  
Butt i don´t get anny data is my flow correct? ![2021-02-13 10_59_44-Window](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/6/162e52fabb374bc138a301af48de2e5339e6cb71.png)

---

<div class="post-metadata">

**Author:** ![F\_R](https://avatars.discourse-cdn.com/v4/letter/f/e99b99/32.png) [@F\_R](https://discourse.nodered.org/u/F_R)\
**Post date:** [13 February 2021 10:09 UTC](https://discourse.nodered.org/t/node-red-modbus-rtu-crc-error/40877/8 "2021-02-13T10:09:35Z")

</div>

Can you explin me what i have to do after installing:

> **[fs-extra](https://www.npmjs.com/package/fs-extra)**
>
> fs-extra contains methods that aren't included in the vanilla Node.js fs package. Such as recursive mkdir, copy, and remove.

where i must do the adjustment : const fse = require('fs-extra')

I don´t understand wh my modbus don´t work? The LED on the device shows the correct coommunication/ request. But i dont get data

---

<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:** [13 February 2021 10:46 UTC](https://discourse.nodered.org/t/node-red-modbus-rtu-crc-error/40877/9 "2021-02-13T10:46:54Z")

</div>

> [@F\_R](#):
>
> I don´t understand wh my modbus don´t work?

There could be many reasons but we can clearly see an issue with fs-extra, so solve that first.

> [@F\_R](#):
>
> Can you explin me what i have to do after installing

Restart node-red.

> [@F\_R](#):
>
> where i must do the adjustment : const fse = require('fs-extra')

You don't. So long as you installed fs-extra either in ~/home/pi/.node-red or the modbus folder, it should be found when you restart node-red.

---

<div class="post-metadata">

**Author:** ![F\_R](https://avatars.discourse-cdn.com/v4/letter/f/e99b99/32.png) [@F\_R](https://discourse.nodered.org/u/F_R)\
**Post date:** [13 February 2021 11:06 UTC](https://discourse.nodered.org/t/node-red-modbus-rtu-crc-error/40877/10 "2021-02-13T11:06:23Z")

</div>

Many thanks @Steve-Mcl that was the solution i get some valus after reboot. But somtimes i get CRC error Code

![2021-02-13 12_02_28-Window](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/d/3d086fb3cab75db32dfcbcc63f616aa54981903e.png)

can you explain me how i can change the Data to °C and % ? ![2021-02-13 12_02_28-Window](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/d/3d086fb3cab75db32dfcbcc63f616aa54981903e.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:** [13 February 2021 11:23 UTC](https://discourse.nodered.org/t/node-red-modbus-rtu-crc-error/40877/11 "2021-02-13T11:23:15Z")

</div>

> [@F\_R](#):
>
> But somtimes i get CRC error Code

That could be down to noise (bad cabling) or config settings mismatch.

> [@F\_R](#):
>
> can you explain me how i can change the Data to °C and %

Which value is which?  
What value are you expecting?  
And ultimately, what do you want to do with these values?

---

<div class="post-metadata">

**Author:** ![F\_R](https://avatars.discourse-cdn.com/v4/letter/f/e99b99/32.png) [@F\_R](https://discourse.nodered.org/u/F_R)\
**Post date:** [13 February 2021 12:18 UTC](https://discourse.nodered.org/t/node-red-modbus-rtu-crc-error/40877/12 "2021-02-13T12:18:10Z")

</div>

![2021-02-13 13_16_45-Window](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/9/f9fd59d25285325ed2ab7643bad502b5646d0d2b.png)

Here you can see the Data, i want tp geht the Temperature, Humidity and the drew point temperature. THan i want to show it in a gauge or a chart.

---

<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:** [13 February 2021 13:30 UTC](https://discourse.nodered.org/t/node-red-modbus-rtu-crc-error/40877/13 "2021-02-13T13:30:51Z")

</div>

By the looks of it, just divide each one by 10.

In a function node (after the modbus node) you could...

```auto
msg.data = msg.payload;
msg.payload = {
  temperature: msg.data[0] / 10.0,
  feuchte: msg.data[1] / 10.0,
  taupunkt: msg.data[2] / 10.0,
}
return msg;

```

Ps, if you don't reply to my message I don't get a notification. I only seen your thread reply by accident.

---

<div class="post-metadata">

**Author:** ![F\_R](https://avatars.discourse-cdn.com/v4/letter/f/e99b99/32.png) [@F\_R](https://discourse.nodered.org/u/F_R)\
**Post date:** [13 February 2021 15:18 UTC](https://discourse.nodered.org/t/node-red-modbus-rtu-crc-error/40877/14 "2021-02-13T15:18:15Z")

</div>

Hello,

thanks fpr the solution, but it don´t work is the return correct? or should it return temperature, feuchte, taupunkt;?

---

<div class="post-metadata">

**Author:** ![UnborN](https://avatars.discourse-cdn.com/v4/letter/u/4491bb/32.png) [@UnborN](https://discourse.nodered.org/u/UnborN)\
**Post date:** [13 February 2021 15:38 UTC](https://discourse.nodered.org/t/node-red-modbus-rtu-crc-error/40877/15 "2021-02-13T15:38:51Z")

</div>

Try wiring the Function node with Steve's code in the **top output** of your Modbus read node and not the bottom.

---

<div class="post-metadata">

**Author:** ![F\_R](https://avatars.discourse-cdn.com/v4/letter/f/e99b99/32.png) [@F\_R](https://discourse.nodered.org/u/F_R)\
**Post date:** [13 February 2021 21:37 UTC](https://discourse.nodered.org/t/node-red-modbus-rtu-crc-error/40877/16 "2021-02-13T21:37:54Z")

</div>

i have tried this, but it don´t work

 ![2021-02-13 22_37_02-Window](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/2/22bccb5b5e2d3f0c708e1ee8651f98bfe32f50e1.png)

---

<div class="post-metadata">

**Author:** ![F\_R](https://avatars.discourse-cdn.com/v4/letter/f/e99b99/32.png) [@F\_R](https://discourse.nodered.org/u/F_R)\
**Post date:** [13 February 2021 21:40 UTC](https://discourse.nodered.org/t/node-red-modbus-rtu-crc-error/40877/17 "2021-02-13T21:40:26Z")

</div>

i have tried it, but i dont work i get the answer undefined

---

<div class="post-metadata">

**Author:** ![UnborN](https://avatars.discourse-cdn.com/v4/letter/u/4491bb/32.png) [@UnborN](https://discourse.nodered.org/u/UnborN)\
**Post date:** [13 February 2021 21:43 UTC](https://discourse.nodered.org/t/node-red-modbus-rtu-crc-error/40877/18 "2021-02-13T21:43:56Z")

</div>

Its because in your Debug node (the one after the function) you are trying to log `msg.payload.function`

Use ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/4/9484c5a5f14ad6d744ec13f738140cf421b896ac.png)

Thats where the msg is .. `msg.payload.function` doesnt exist .. _undefined_

Watch this detailed [video playlist](https://www.youtube.com/watch?v=ksGeUD26Mw0&list=PLyNBB9VCLmo1hyO-4fIZ08gqFcXBkHy-6) by the developers of Node-red.  
It will solve most of your questions on basic msg manipulation.

---

<div class="post-metadata">

**Author:** ![F\_R](https://avatars.discourse-cdn.com/v4/letter/f/e99b99/32.png) [@F\_R](https://discourse.nodered.org/u/F_R)\
**Post date:** [13 February 2021 22:27 UTC](https://discourse.nodered.org/t/node-red-modbus-rtu-crc-error/40877/19 "2021-02-13T22:27:29Z")

</div>

thanks that was the solution the modbus communication work well:-)

 ![2021-02-13 23_26_45-Window](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/8/881d9441a07c3417ea8d34bcf33a9387f45b820e.png)

---

<div class="post-metadata">

**Author:** ![F\_R](https://avatars.discourse-cdn.com/v4/letter/f/e99b99/32.png) [@F\_R](https://discourse.nodered.org/u/F_R)\
**Post date:** [14 February 2021 08:58 UTC](https://discourse.nodered.org/t/node-red-modbus-rtu-crc-error/40877/20 "2021-02-14T08:58:21Z")

</div>

Hello, i have two questions, if i want to get data from different modbus devices should i use some modbus read nodes with different adresses? Whats the best solutuion to read data from different modbus devices?

In the Dasboard Layout i don´t can change the size and the place from my gauge or chart!?  
I have tryied to unlook the chart but i don´t can move or change the size.

[Next page](https://discourse.nodered.org/t/node-red-modbus-rtu-crc-error/40877.md?page=2)
