This project reads tag values from an OPC UA server and logs them into a MySQL database at a configurable interval. Tag details are loaded from a CSV file, and all configuration is managed via a JSON config file.
server.js
— Main script for reading OPC UA data and logging to MySQLconfig.json
— Configuration file for endpoint, credentials, polling interval, database/table, and CSV filetags.csv
— CSV file listing tag names and nodeIds to readEdit config.json
to set your parameters:
{
"opcuaEndpoint": "opc.tcp://localhost:4840",
"opcuaUsername": "", // optional
"opcuaPassword": "", // optional
"mysqlDbName": "test",
"mysqlTableName": "tag_data",
"mysqlHost": "127.0.0.1",
"mysqlUser": "root",
"mysqlPassword": "toor",
"pollIntervalMs": 1000,
"tagsCsvFile": "tags.csv"
}
Example tags.csv
:
name,nodeId
Constant,ns=3;i=1001
Counter,ns=3;i=1002
Random,ns=3;i=1003
npm install
node server.js
config.json
.34.03$