Opto Epic I/O points collected in a data-logger to csv file

I’m trying to build a simple data logger collecting I/O points (mostly just analog values), from the Opto Epic (we have PAC Controller also.

Basically need a timestamp, roughly 10 analog points collected every 5 seconds, put into one CSV file (each day would be a new file name based on date: 2024-01-23) and within the csv file it would have a column for the timestamp, value 1, value 2, value 3…etc.

Much appreciated.

Hi Spencer. Welcome to the Opto Forums!

This video should get you going for Node-RED.

For PAC Control: Opto22 - FTP and Data Logging Example

There are also a lot of CSV logging tips and code in these forums: Search results for 'csv logging' - OptoForums

1 Like

Thanks Beno, I appreciate the information.

Spencer

Hi Beno, this worked, however, I can’t seem to figure a way to add a timestamp to each line of data collected. For example, if I run an interval of 5s, I want to see the date and time for each interval. Any suggestions on how to do this?

Thanks,
Spencer

There are two ways to do this, if you are using an inject node you could set it to inject msg.timestamp = timestamp and have that be a part of the CSV.

Without an inject node you can get the current timestamp at any point with a change node like this:
image

If you need a more specific time format, your best bet is to use a function node, here’s an example:

I have an older forum post you can check out for other ways you can format date and/or time with the JavaScript date functions, it might be useful for you:

Hi Terry, I do have it as an injector for timestamp and it does come up with a timestamp [1706107469370] but needs to be converted using the normal conversion calculation; however, for some reason in Excel 365 I can’t get it to convert - it comes up with #Value. Have you experienced this in MS365 Excel? Any other tools or calculations I can use to get around this - or better yet, can I add something in (not being an experienced programmer) to my nodes to have it populate in proper MM:DD:YYYY hh:mm:ss?

Thanks,
Spencer

Check out this node “node-red-contrib-moment”
It can “humanize” Time/Dates

Another option from @philip is to do the conversion in excel.

He provides the formula here: Convert groov Trend timestamp in Excel

Hi Norm, thanks - I installed this and got the following error:

You will need to install an older version of the node.

From the Node-RED menu in groov Manage…

Once you click on Node Management…

The node will then install.
Next you will need to restart Node-RED from the groov Manage Node-RED menu.

2 Likes

Thanks @Beno - the older version actually worked perfect - problem solved and format is now as needed. I really appreciate your help!

Spencer

2 Likes