# Modbus data to CSV file - NAN error occurs

**URL:** <https://discourse.nodered.org/t/modbus-data-to-csv-file-nan-error-occurs/36181>\
**Category:** General\
**Created:** [19 November 2020 08:40 UTC](https://discourse.nodered.org/t/modbus-data-to-csv-file-nan-error-occurs/36181 "2020-11-19T08:40:08Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![Energycharges](https://avatars.discourse-cdn.com/v4/letter/e/e47c2d/32.png) [@Energycharges](https://discourse.nodered.org/u/Energycharges)\
**Post date:** [19 November 2020 08:40 UTC](https://discourse.nodered.org/t/modbus-data-to-csv-file-nan-error-occurs/36181/1 "2020-11-19T08:40:08Z")

</div>

While working with Modbus data to csv file , For every 5 minutes Interval injecting data from Modbus to csv file . Receiving data for parameters from Modbus to csv file , for a random interval NAN error occurs .  
Cannot figure out why NAN error occurs

Can anyone help me out to figure out this issue

NODE-RED Flow for Modbus to Csv file

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

CSV File with NAN error

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/d/2/d2fa8e541714c5e85ba5089c736809f700fa2e7d.jpeg)

Appreciate , your effort in notifying the issue  
Energy charges

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [19 November 2020 09:07 UTC](https://discourse.nodered.org/t/modbus-data-to-csv-file-nan-error-occurs/36181/2 "2020-11-19T09:07:16Z")

</div>

Add debug nodes further back in the flow and work out which node is causing the problem.

---

<div class="post-metadata">

**Author:** ![Energycharges](https://avatars.discourse-cdn.com/v4/letter/e/e47c2d/32.png) [@Energycharges](https://discourse.nodered.org/u/Energycharges)\
**Post date:** [19 November 2020 12:18 UTC](https://discourse.nodered.org/t/modbus-data-to-csv-file-nan-error-occurs/36181/3 "2020-11-19T12:18:49Z")

</div>

Thanks for your response @Colin

I checked by adding debug nodes. Program is running 24\*7 , NAN error occurs once in a while , cant able to figure it out

1. Is there any possible way to log my debug nodes to cross verify , from which node is causing error .

2. In a week once or twice error occurs , rest all time its working fine

Energy charges

---

<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:** [19 November 2020 12:22 UTC](https://discourse.nodered.org/t/modbus-data-to-csv-file-nan-error-occurs/36181/4 "2020-11-19T12:22:47Z")

</div>

this problem will be occuring because the node that generates them data items has not respond with in 7 seconds.

You have set your `join` node to release whatever data is has after 7 seconds (regardless if all values are collected)...

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

---

<div class="post-metadata">

**Author:** ![Energycharges](https://avatars.discourse-cdn.com/v4/letter/e/e47c2d/32.png) [@Energycharges](https://discourse.nodered.org/u/Energycharges)\
**Post date:** [19 November 2020 13:05 UTC](https://discourse.nodered.org/t/modbus-data-to-csv-file-nan-error-occurs/36181/5 "2020-11-19T13:05:41Z")

</div>

Thanks for your timely help @Steve-Mcl

I have a doubt @Steve-Mcl, Data is running 24\*7. Once or Twice in a week error occurs, rest all data is working fine

I will check with Join node

Appreciate , your effort in notifying the issue  
Energy charges

---

<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:** [19 November 2020 13:12 UTC](https://discourse.nodered.org/t/modbus-data-to-csv-file-nan-error-occurs/36181/6 "2020-11-19T13:12:02Z")

</div>

> [@Energycharges](#):
>
> I have a doubt

You can doubt as much as you want but I can tell you what is definitely happening is...  
The flow part that grabs address 24 --\> modbus --\> P/S/Q (and perhaps others) IS NOT giving you a value within 7 seconds. That is what is definitely happening.

Possibly a network or some other interruption is occasionally making things very slow to respond. but definitely - values are not reaching the `join` node before 7 seconds.

---

<div class="post-metadata">

**Author:** ![Energycharges](https://avatars.discourse-cdn.com/v4/letter/e/e47c2d/32.png) [@Energycharges](https://discourse.nodered.org/u/Energycharges)\
**Post date:** [23 November 2020 14:52 UTC](https://discourse.nodered.org/t/modbus-data-to-csv-file-nan-error-occurs/36181/7 "2020-11-23T14:52:15Z")

</div>

Thank you for your response 😃

As per your suggestion, changed value to within **30 seconds** , still I receive a NAN error for a data, rest all data working fine .

Can you please guide me , in what ways it can be rectified.

Regards  
Energy Charges

---

<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 November 2020 15:21 UTC](https://discourse.nodered.org/t/modbus-data-to-csv-file-nan-error-occurs/36181/8 "2020-11-23T15:21:35Z")

</div>

Personally (though I have yet to prove it) I suspect the modbus nodes are occasionally tripping up when you trigger them at the same time.

What I often recommend is they are operated in a sequence (i.e. wire them in series one after another instead of in parallel)

As for handling rows with NaN, you might just have to handle this. E.g. check data before input to database. If you have any NaN, throw it away. Or you could write some logic to retry the modbus node if it doesn't reply within xx Seconds. Or... Many ways to handle it. It depends what you want and how critical the data is.

---

<div class="post-metadata">

**Author:** ![Energycharges](https://avatars.discourse-cdn.com/v4/letter/e/e47c2d/32.png) [@Energycharges](https://discourse.nodered.org/u/Energycharges)\
**Post date:** [23 November 2020 15:48 UTC](https://discourse.nodered.org/t/modbus-data-to-csv-file-nan-error-occurs/36181/9 "2020-11-23T15:48:54Z")

</div>

Thanks for your timely response @Steve-Mcl

Yes, I'm getting NaN error in CSV file and database , but in CSV from **Address 24 - 1024** getting error, **Address 0** working fine .

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

Can you share any docs for my reference.

Appreciate , your effort in notifying the issue  
Energy charges

---

<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 November 2020 15:56 UTC](https://discourse.nodered.org/t/modbus-data-to-csv-file-nan-error-occurs/36181/10 "2020-11-23T15:56:26Z")

</div>

> [@Energycharges](#):
>
> Can you share any docs for my reference.

I have nothing to share with you more than I have already said.

> [@Steve-Mcl](#):
>
> I suspect the modbus nodes are occasionally tripping up when you trigger them at the same time.
> 
> What I often recommend is they are operated in a sequence (i.e. wire them in series one after another instead of in parallel)

So go give that a try - delete the wires from the inject & wire from Modbus to next part like this...

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

* * *

PS, you should REALLY put logging on the output of each of the modbus nodes (log to file, with timestamps) to see what is REALLY happening. It might be the modbus nodes are not responding? it might be the modbus nodes are sending bad data. you should also put a catch node on the form and also write the catch nodes to a log & check for errors.

For logging, I recommend node-red-contrib-flogger (you can store JSON objects in the log & entries are nicely timestamped)

---

<div class="post-metadata">

**Author:** ![Energycharges](https://avatars.discourse-cdn.com/v4/letter/e/e47c2d/32.png) [@Energycharges](https://discourse.nodered.org/u/Energycharges)\
**Post date:** [10 January 2021 07:38 UTC](https://discourse.nodered.org/t/modbus-data-to-csv-file-nan-error-occurs/36181/11 "2021-01-10T07:38:22Z")

</div>

Please guide me to write some logic to retry the modbus node if it doesn't reply within xx Seconds.

Can you share any docs for reference

Regards  
Energy Charges

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [10 January 2021 08:01 UTC](https://discourse.nodered.org/t/modbus-data-to-csv-file-nan-error-occurs/36181/12 "2021-01-10T08:01:10Z")

</div>

It isn't quite as easy as that. How many times do you want to retry? How far apart do you want the retries?  
Normally when using modus you will be polling the device regularly so it will automatically retry at the next poll.

---

<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:** [10 January 2021 08:23 UTC](https://discourse.nodered.org/t/modbus-data-to-csv-file-nan-error-occurs/36181/13 "2021-01-10T08:23:28Z")

</div>

Did you rewire nodes to read in series?

Share a screenshot of your flow & further explain what is happening so I can assess the issue.

---

<div class="post-metadata">

**Author:** ![Energycharges](https://avatars.discourse-cdn.com/v4/letter/e/e47c2d/32.png) [@Energycharges](https://discourse.nodered.org/u/Energycharges)\
**Post date:** [10 January 2021 08:52 UTC](https://discourse.nodered.org/t/modbus-data-to-csv-file-nan-error-occurs/36181/14 "2021-01-10T08:52:30Z")

</div>

Thanks for your timely response

How many times do you want to retry?

I'm not able to figure it out ,NAN error occurs once , next data coming from mod-bus works fine.

If i get a NAN error is it possible to inject the node again , to overcome NAN error problem.

I'm injecting the node for every 5 minutes , and using a join node for 120 seconds

I'm not able to identify from where error occur

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/d/b/dbeaa10e09fca4e5beb67653ffee22c241714d6b.jpeg)  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/e/9ed673725d7635fc63f470a4a1bd2ab869f67905.jpeg)  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/b/8b67c7884e1e51f7dc47e4ba283f361ec64b2aec.jpeg)  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/8/28620285f8ed5a40a49692569376a45df1a22424.jpeg)

Appreciate , your effort in notifying the issue  
Energy charges

---

<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:** [10 January 2021 08:58 UTC](https://discourse.nodered.org/t/modbus-data-to-csv-file-nan-error-occurs/36181/15 "2021-01-10T08:58:23Z")

</div>

You are still triggering the modbus reads in parallel. I have previously explained a few times this can cause an issue. You still ignore my advise to try wiring the nodes in series.

I will not be wasting any more of my time if you do not try what I have suggested (several times).

Best of luck

---

<div class="post-metadata">

**Author:** ![Energycharges](https://avatars.discourse-cdn.com/v4/letter/e/e47c2d/32.png) [@Energycharges](https://discourse.nodered.org/u/Energycharges)\
**Post date:** [10 January 2021 10:33 UTC](https://discourse.nodered.org/t/modbus-data-to-csv-file-nan-error-occurs/36181/16 "2021-01-10T10:33:53Z")

</div>

Extremely Sorry @Steve-Mcl i'm not ignoring your advice.

I'm a beginner working on programming and node-red , quite challenging for me to connect.

I'm not getting a clear understanding on **how to connect the wires in series**. Still working on your suggestion .

Do you have any reference on how to connect in series

Energy charges

---

<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:** [10 January 2021 10:37 UTC](https://discourse.nodered.org/t/modbus-data-to-csv-file-nan-error-occurs/36181/17 "2021-01-10T10:37:17Z")

</div>

@Energycharges I explained how...

> [@Steve-Mcl](#):
>
> So go give that a try - delete the wires from the inject & wire from Modbus to next part like this...
> 
> ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/b/9bb98bd2ed906a56937b5f417ada37ebe4e7e990.png)

It really is as simple as don't wire in parallel. Wire in series.

---

<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:** [11 March 2021 10:37 UTC](https://discourse.nodered.org/t/modbus-data-to-csv-file-nan-error-occurs/36181/18 "2021-03-11T10:37:28Z")

</div>

Closed on 11 March 2021 10:37 UTC

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