I’m back to this thread after a year. I completed my Opto22 Premium Training last week, and I must admit, I’m a little embarrassed to look at my earlier Node-RED example—it’s a perfect example of how not to use it!
In this post, I’m sharing my updated Node-RED flow, which takes data from PAC Control and transfers it to an MSSQL database. I’ve also attached the Node-RED code for anyone who might find it useful for a similar project.
To explain the flow: I use a trigger variable from PAC Control that retrieves all the necessary data, which I then save into a local database on my PC. The setup helps me automate the process of pulling and storing this data seamlessly.
Feel free to take the code, tweak it, and improve upon it for your own use cases. Also, a big thank you to @Beno and @torchard for clearing up all my doubts during the factory training—your guidance was invaluable!
[{"id":"f704e565.cd5f6","type":"tab","label":"SQL Database","disabled":false,"info":""},{"id":"52a4658172968669","type":"inject","z":"f704e565.cd5f6","name":"","props":[],"repeat":"1","crontab":"","once":true,"onceDelay":0.1,"topic":"","x":210,"y":280,"wires":[[]]},{"id":"3abc83ef34f73f36","type":"pac-read","z":"f704e565.cd5f6","device":"4608f02f8d4f60fe","dataType":"string-variable","tagName":"uoLogStartTime","tableStartIndex":"","tableLength":"","value":"startTime","valueType":"msg","topic":"","topicType":"none","name":"Start Time","x":770,"y":200,"wires":[["e215d52dd55eeca5"]]},{"id":"81e088be22055ee8","type":"pac-read","z":"f704e565.cd5f6","device":"4608f02f8d4f60fe","dataType":"string-variable","tagName":"uoLogProgram","tableStartIndex":"","tableLength":"","value":"programName","valueType":"msg","topic":"","topicType":"none","name":"Program Name","x":1220,"y":200,"wires":[["688c8d428ad495a5"]]},{"id":"4e8a80bf8b250a2e","type":"pac-read","z":"f704e565.cd5f6","device":"4608f02f8d4f60fe","dataType":"string-variable","tagName":"uoLogGroup","tableStartIndex":"","tableLength":"","value":"groupName","valueType":"msg","topic":"","topicType":"none","name":"Valve Group Name","x":650,"y":260,"wires":[["fd814c44f788577b"]]},{"id":"fd814c44f788577b","type":"pac-read","z":"f704e565.cd5f6","device":"4608f02f8d4f60fe","dataType":"int32-variable","tagName":"uoLogTimeZone","tableStartIndex":"","tableLength":"","value":"scheduleNumber","valueType":"msg","topic":"","topicType":"none","name":"Schedule Number","x":850,"y":260,"wires":[["29097393ed528ca2"]]},{"id":"29097393ed528ca2","type":"pac-read","z":"f704e565.cd5f6","device":"4608f02f8d4f60fe","dataType":"string-variable","tagName":"uoLogValves","tableStartIndex":"","tableLength":"","value":"valveNumber","valueType":"msg","topic":"","topicType":"none","name":"Valve Number","x":1040,"y":260,"wires":[["c3792717c3f68d62"]]},{"id":"c3792717c3f68d62","type":"pac-read","z":"f704e565.cd5f6","device":"4608f02f8d4f60fe","dataType":"string-variable","tagName":"uoLogEvent","tableStartIndex":"","tableLength":"","value":"eventName","valueType":"msg","topic":"","topicType":"none","name":"Event Name","x":1210,"y":260,"wires":[["bc9816a66ab7afb8"]]},{"id":"bc9816a66ab7afb8","type":"pac-read","z":"f704e565.cd5f6","device":"4608f02f8d4f60fe","dataType":"string-variable","tagName":"uoLogTrigger","tableStartIndex":"","tableLength":"","value":"triggerType","valueType":"msg","topic":"","topicType":"none","name":"Trigger Type","x":1370,"y":260,"wires":[["fae081c766cf1a0a"]]},{"id":"08589794e47fe894","type":"pac-read","z":"f704e565.cd5f6","device":"4608f02f8d4f60fe","dataType":"float-variable","tagName":"uoLogLiters","tableStartIndex":"","tableLength":"","value":"waterUsed","valueType":"msg","topic":"","topicType":"none","name":"Water Used","x":1710,"y":260,"wires":[["bd531937a3d84892"]]},{"id":"688c8d428ad495a5","type":"pac-read","z":"f704e565.cd5f6","device":"4608f02f8d4f60fe","dataType":"string-variable","tagName":"uoLogRecipeName","tableStartIndex":"","tableLength":"","value":"recipeName","valueType":"msg","topic":"","topicType":"none","name":"Recipe Name","x":1400,"y":200,"wires":[["4e8a80bf8b250a2e"]]},{"id":"92d13d4eb9615111","type":"pac-read","z":"f704e565.cd5f6","device":"4608f02f8d4f60fe","dataType":"string-variable","tagName":"uoLogStopTime","tableStartIndex":"","tableLength":"","value":"stopTime","valueType":"msg","topic":"","topicType":"none","name":"End Time","x":1060,"y":200,"wires":[["81e088be22055ee8"]]},{"id":"bd531937a3d84892","type":"pac-read","z":"f704e565.cd5f6","device":"4608f02f8d4f60fe","dataType":"float-table","tagName":"uoLogInjectorStroke","tableStartIndex":"0","tableLength":"1","value":"injectorStroke1","valueType":"msg","topic":"","topicType":"none","name":"Inj #1 Stroke","x":630,"y":320,"wires":[["920f9066f4f361be"]]},{"id":"920f9066f4f361be","type":"pac-read","z":"f704e565.cd5f6","device":"4608f02f8d4f60fe","dataType":"float-table","tagName":"uoLogInjectorStroke","tableStartIndex":"1","tableLength":"1","value":"injectorStroke2","valueType":"msg","topic":"","topicType":"none","name":"Inj #2 Stroke","x":790,"y":320,"wires":[["5d3159d34a1f2784"]]},{"id":"5d3159d34a1f2784","type":"pac-read","z":"f704e565.cd5f6","device":"4608f02f8d4f60fe","dataType":"float-table","tagName":"uoLogInjectorStroke","tableStartIndex":"2","tableLength":"1","value":"injectorStroke3","valueType":"msg","topic":"","topicType":"none","name":"Inj #3 Stroke","x":950,"y":320,"wires":[["be46cdf5121e0ce6"]]},{"id":"be46cdf5121e0ce6","type":"pac-read","z":"f704e565.cd5f6","device":"4608f02f8d4f60fe","dataType":"float-table","tagName":"uoLogInjectorStroke","tableStartIndex":"3","tableLength":"1","value":"injectorStroke4","valueType":"msg","topic":"","topicType":"none","name":"Inj #4 Stroke","x":1110,"y":320,"wires":[["3909f4b3c4a4a7cf"]]},{"id":"3909f4b3c4a4a7cf","type":"pac-read","z":"f704e565.cd5f6","device":"4608f02f8d4f60fe","dataType":"float-table","tagName":"uoLogInjectorStroke","tableStartIndex":"4","tableLength":"1","value":"injectorStroke5","valueType":"msg","topic":"","topicType":"none","name":"Inj #5 Stroke","x":1270,"y":320,"wires":[["15e1f1f4228a25f0"]]},{"id":"15e1f1f4228a25f0","type":"pac-read","z":"f704e565.cd5f6","device":"4608f02f8d4f60fe","dataType":"float-table","tagName":"uoLogInjectorStroke","tableStartIndex":"5","tableLength":"1","value":"injectorStroke6","valueType":"msg","topic":"","topicType":"none","name":"Inj #6 Stroke","x":1430,"y":320,"wires":[["34662d680988ba6d"]]},{"id":"34662d680988ba6d","type":"pac-read","z":"f704e565.cd5f6","device":"4608f02f8d4f60fe","dataType":"float-table","tagName":"uoLogInjectorStroke","tableStartIndex":"6","tableLength":"1","value":"injectorStroke7","valueType":"msg","topic":"","topicType":"none","name":"Inj #7 Stroke","x":630,"y":380,"wires":[["22267acbf98a1324"]]},{"id":"22267acbf98a1324","type":"pac-read","z":"f704e565.cd5f6","device":"4608f02f8d4f60fe","dataType":"float-table","tagName":"uoLogInjectorStroke","tableStartIndex":"7","tableLength":"1","value":"injectorStroke8","valueType":"msg","topic":"","topicType":"none","name":"Inj #8 Stroke","x":790,"y":380,"wires":[["b0b21728ab78c52e"]]},{"id":"b0b21728ab78c52e","type":"pac-read","z":"f704e565.cd5f6","device":"4608f02f8d4f60fe","dataType":"float-table","tagName":"uoLogInjectorStroke","tableStartIndex":"8","tableLength":"1","value":"injectorStroke9","valueType":"msg","topic":"","topicType":"none","name":"Inj #9 Stroke","x":950,"y":380,"wires":[["0c2beee45a15e919"]]},{"id":"0c2beee45a15e919","type":"pac-read","z":"f704e565.cd5f6","device":"4608f02f8d4f60fe","dataType":"float-table","tagName":"uoLogInjectorStroke","tableStartIndex":"9","tableLength":"1","value":"injectorStroke10","valueType":"msg","topic":"","topicType":"none","name":"Inj #10 Stroke","x":1120,"y":380,"wires":[["2d29ec2d1c4fdcf5"]]},{"id":"2d29ec2d1c4fdcf5","type":"pac-read","z":"f704e565.cd5f6","device":"4608f02f8d4f60fe","dataType":"float-table","tagName":"uoLogInjectorStroke","tableStartIndex":"10","tableLength":"1","value":"injectorStroke11","valueType":"msg","topic":"","topicType":"none","name":"Inj #11 Stroke","x":1300,"y":380,"wires":[["188220ca257411ec"]]},{"id":"188220ca257411ec","type":"pac-read","z":"f704e565.cd5f6","device":"4608f02f8d4f60fe","dataType":"float-table","tagName":"uoLogInjectorStroke","tableStartIndex":"11","tableLength":"1","value":"injectorStroke12","valueType":"msg","topic":"","topicType":"none","name":"Inj #12 Stroke","x":1480,"y":380,"wires":[["fd80d0835f68d73f"]]},{"id":"53318f297862d588","type":"MSSQL","z":"f704e565.cd5f6","mssqlCN":"349d7e7b6a84c1bd","name":"","query":"-- Check if the Fertigation Manager database exists, and create it if not\nIF NOT EXISTS (SELECT * FROM sys.databases WHERE name = 'FertigationManager')\nBEGIN\n CREATE DATABASE FertigationManager;\nEND;\n\n-- Use the Fertigation Manager database\nUSE FertigationManager;\n\n-- Check if the Chamber_1 table exists, and create it if not\nIF NOT EXISTS (SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'IrrigationLog')\nBEGIN\n CREATE TABLE IrrigationLog (\n ID INT IDENTITY(1,1) PRIMARY KEY,\n DateTimeStamp DATETIME,\n [Start Date] VARCHAR(MAX),\n [Start Time] VARCHAR(MAX),\n [End Date] VARCHAR(MAX),\n [End Time] VARCHAR(MAX),\n [Program Name] VARCHAR(MAX),\n [Recipe Name] VARCHAR(MAX),\n [Valve Group Name] VARCHAR(MAX),\n [Schedule Number] INT,\n [Valve Number] VARCHAR(MAX),\n [Event Name] VARCHAR(MAX),\n [Trigger Type] VARCHAR(MAX),\n [Irrigation Mode] VARCHAR(MAX),\n [Water Used] FLOAT,\n [Injector 1 Volume] FLOAT,\n [Injector 2 Volume] FLOAT,\n [Injector 3 Volume] FLOAT,\n [Injector 4 Volume] FLOAT,\n [Injector 5 Volume] FLOAT,\n [Injector 6 Volume] FLOAT,\n [Injector 7 Volume] FLOAT,\n [Injector 8 Volume] FLOAT,\n [Injector 9 Volume] FLOAT,\n [Injector 10 Volume] FLOAT,\n [Injector 11 Volume] FLOAT,\n [Injector 12 Volume] FLOAT,\n [Injector 1 pulse count] INT,\n [Injector 2 pulse count] INT,\n [Injector 3 pulse count] INT,\n [Injector 4 pulse count] INT,\n [Injector 5 pulse count] INT,\n [Injector 6 pulse count] INT,\n [Injector 7 pulse count] INT,\n [Injector 8 pulse count] INT,\n [Injector 9 pulse count] INT,\n [Injector 10 pulse count] INT,\n [Injector 11 pulse count] INT,\n [Injector 12 pulse count] INT \n );\nEND;\n\n--Declare variables\nDECLARE @storeStartDate VARCHAR(MAX)\nDECLARE @storeStartTime VARCHAR(MAX)\nDECLARE @storeStopDate VARCHAR(MAX)\nDECLARE @storeStopTime VARCHAR(MAX)\nDECLARE @storeProgramName VARCHAR(MAX)\nDECLARE @storeRecipeName VARCHAR(MAX)\nDECLARE @storeValveGroupName VARCHAR(MAX)\nDECLARE @storeSchedulerNumber INT\nDECLARE @storeValveNumber VARCHAR(MAX)\nDECLARE @storeEventName VARCHAR(MAX)\nDECLARE @storeTriggerType VARCHAR(MAX)\nDECLARE @storeIrrigationMode VARCHAR(MAX)\nDECLARE @storeWaterUsed FLOAT\n\nDECLARE @storeInjector1Stroke FLOAT\nDECLARE @storeInjector2Stroke FLOAT\nDECLARE @storeInjector3Stroke FLOAT\nDECLARE @storeInjector4Stroke FLOAT\nDECLARE @storeInjector5Stroke FLOAT\nDECLARE @storeInjector6Stroke FLOAT\nDECLARE @storeInjector7Stroke FLOAT\nDECLARE @storeInjector8Stroke FLOAT\nDECLARE @storeInjector9Stroke FLOAT\nDECLARE @storeInjector10Stroke FLOAT\nDECLARE @storeInjector11Stroke FLOAT\nDECLARE @storeInjector12Stroke FLOAT\n\nDECLARE @storeInjector1Pulse INT\nDECLARE @storeInjector2Pulse INT\nDECLARE @storeInjector3Pulse INT\nDECLARE @storeInjector4Pulse INT\nDECLARE @storeInjector5Pulse INT\nDECLARE @storeInjector6Pulse INT\nDECLARE @storeInjector7Pulse INT\nDECLARE @storeInjector8Pulse INT\nDECLARE @storeInjector9Pulse INT\nDECLARE @storeInjector10Pulse INT\nDECLARE @storeInjector11Pulse INT\nDECLARE @storeInjector12Pulse INT\n\n--Set the values\nSET @storeStartDate = '{{{startDate}}}';\nSET @storeStartTime = '{{{startTime}}}';\nSET @storeStopDate = '{{{stopDate}}}';\nSET @storeStopTime = '{{{stopTime}}}';\nSET @storeProgramName = '{{{programName}}}';\nSET @storeRecipeName = '{{{recipeName}}}';\nSET @storeValveGroupName = '{{{groupName}}}';\nSET @storeSchedulerNumber = {{{scheduleNumber}}};\nSET @storeValveNumber = {{{valveNumber}}};\nSET @storeEventName = '{{{eventName}}}';\nSET @storeTriggerType = '{{{triggerType}}}';\nSET @storeIrrigationMode = '{{{irrigationMode}}}';\nSET @storeWaterUsed = {{{waterUsed}}};\n\nSET @storeInjector1Stroke = {{{injectorStroke1}}};\nSET @storeInjector2Stroke = {{{injectorStroke2}}};\nSET @storeInjector3Stroke = {{{injectorStroke3}}};\nSET @storeInjector4Stroke = {{{injectorStroke4}}};\nSET @storeInjector5Stroke = {{{injectorStroke5}}};\nSET @storeInjector6Stroke = {{{injectorStroke6}}};\nSET @storeInjector7Stroke = {{{injectorStroke7}}};\nSET @storeInjector8Stroke = {{{injectorStroke8}}};\nSET @storeInjector9Stroke = {{{injectorStroke9}}};\nSET @storeInjector10Stroke = {{{injectorStroke10}}};\nSET @storeInjector11Stroke = {{{injectorStroke11}}};\nSET @storeInjector12Stroke = {{{injectorStroke12}}};\n\nSET @storeInjector1Pulse = {{{injectorPulse1}}};\nSET @storeInjector2Pulse = {{{injectorPulse2}}};\nSET @storeInjector3Pulse = {{{injectorPulse3}}};\nSET @storeInjector4Pulse = {{{injectorPulse4}}};\nSET @storeInjector5Pulse = {{{injectorPulse5}}};\nSET @storeInjector6Pulse = {{{injectorPulse6}}};\nSET @storeInjector7Pulse = {{{injectorPulse7}}};\nSET @storeInjector8Pulse = {{{injectorPulse8}}};\nSET @storeInjector9Pulse = {{{injectorPulse9}}};\nSET @storeInjector10Pulse = {{{injectorPulse10}}};\nSET @storeInjector11Pulse = {{{injectorPulse11}}};\nSET @storeInjector12Pulse = {{{injectorPulse12}}};\n\n-- Insert data into the IrrigationLog table\nINSERT INTO IrrigationLog (\n DateTimeStamp,\n [Start Date],\n [Start Time],\n [End Date],\n [End Time],\n [Program Name],\n [Recipe Name],\n [Valve Group Name],\n [Schedule Number],\n [Valve Number],\n [Event Name],\n [Trigger Type],\n [Irrigation Mode],\n [Water Used],\n [Injector 1 Volume],\n [Injector 2 Volume],\n [Injector 3 Volume],\n [Injector 4 Volume],\n [Injector 5 Volume],\n [Injector 6 Volume],\n [Injector 7 Volume],\n [Injector 8 Volume],\n [Injector 9 Volume],\n [Injector 10 Volume],\n [Injector 11 Volume],\n [Injector 12 Volume],\n [Injector 1 pulse count],\n [Injector 2 pulse count],\n [Injector 3 pulse count],\n [Injector 4 pulse count],\n [Injector 5 pulse count],\n [Injector 6 pulse count],\n [Injector 7 pulse count],\n [Injector 8 pulse count],\n [Injector 9 pulse count],\n [Injector 10 pulse count],\n [Injector 11 pulse count],\n [Injector 12 pulse count] \n)\nVALUES (\n GETDATE(),\n @storeStartDate,\n @storeStartTime,\n @storeStopDate,\n @storeStopTime,\n @storeProgramName,\n @storeRecipeName,\n @storeValveGroupName,\n @storeSchedulerNumber,\n @storeValveNumber,\n @storeEventName,\n @storeTriggerType,\n @storeIrrigationMode,\n @storeWaterUsed,\n @storeInjector1Stroke, \n @storeInjector2Stroke,\n @storeInjector3Stroke,\n @storeInjector4Stroke, \n @storeInjector5Stroke, \n @storeInjector6Stroke, \n @storeInjector7Stroke, \n @storeInjector8Stroke, \n @storeInjector9Stroke, \n @storeInjector10Stroke, \n @storeInjector11Stroke, \n @storeInjector12Stroke, \n @storeInjector1Pulse,\n @storeInjector2Pulse,\n @storeInjector3Pulse,\n @storeInjector4Pulse,\n @storeInjector5Pulse,\n @storeInjector6Pulse,\n @storeInjector7Pulse,\n @storeInjector8Pulse, \n @storeInjector9Pulse,\n @storeInjector10Pulse,\n @storeInjector11Pulse,\n @storeInjector12Pulse\n);\n","outField":"payload","x":1580,"y":500,"wires":[["5ffb0cb7e81a7eef"]]},{"id":"49dd113bd95427a3","type":"switch","z":"f704e565.cd5f6","name":"","property":"LogStart","propertyType":"msg","rules":[{"t":"eq","v":"1","vt":"num"}],"checkall":"true","repair":false,"outputs":1,"x":470,"y":200,"wires":[["751f74373972e96a"]]},{"id":"b3d1c5c515be4e5a","type":"pac-read","z":"f704e565.cd5f6","device":"4608f02f8d4f60fe","dataType":"int32-variable","tagName":"uoLogStart","tableStartIndex":"","tableLength":"","value":"LogStart","valueType":"msg","topic":"","topicType":"none","name":"","x":350,"y":280,"wires":[["49dd113bd95427a3"]]},{"id":"5ffb0cb7e81a7eef","type":"debug","z":"f704e565.cd5f6","name":"debug 2","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"timestamp","targetType":"msg","statusVal":"","statusType":"auto","x":1720,"y":500,"wires":[]},{"id":"751f74373972e96a","type":"pac-read","z":"f704e565.cd5f6","device":"4608f02f8d4f60fe","dataType":"string-variable","tagName":"uoLogStartDate","tableStartIndex":"","tableLength":"","value":"startDate","valueType":"msg","topic":"","topicType":"none","name":"Start Date","x":620,"y":200,"wires":[["3abc83ef34f73f36"]]},{"id":"e215d52dd55eeca5","type":"pac-read","z":"f704e565.cd5f6","device":"4608f02f8d4f60fe","dataType":"string-variable","tagName":"uoLogStopDate","tableStartIndex":"","tableLength":"","value":"stopDate","valueType":"msg","topic":"","topicType":"none","name":"End Date","x":920,"y":200,"wires":[["92d13d4eb9615111"]]},{"id":"fae081c766cf1a0a","type":"pac-read","z":"f704e565.cd5f6","device":"4608f02f8d4f60fe","dataType":"string-variable","tagName":"uoLogIrrigationMode","tableStartIndex":"","tableLength":"","value":"irrigationMode","valueType":"msg","topic":"","topicType":"none","name":"Irrigation Mode","x":1540,"y":260,"wires":[["08589794e47fe894"]]},{"id":"fd80d0835f68d73f","type":"pac-read","z":"f704e565.cd5f6","device":"4608f02f8d4f60fe","dataType":"int32-table","tagName":"uoLogInjectorPulseCount","tableStartIndex":"0","tableLength":"1","value":"injectorPulse1","valueType":"msg","topic":"","topicType":"none","name":"Inj #1 Pulse","x":630,"y":440,"wires":[["fec432c7f88b0cf9"]]},{"id":"fec432c7f88b0cf9","type":"pac-read","z":"f704e565.cd5f6","device":"4608f02f8d4f60fe","dataType":"int32-table","tagName":"uoLogInjectorPulseCount","tableStartIndex":"1","tableLength":"1","value":"injectorPulse2","valueType":"msg","topic":"","topicType":"none","name":"Inj #2 Pulse","x":790,"y":440,"wires":[["1ad338b40e4c94d4"]]},{"id":"1ad338b40e4c94d4","type":"pac-read","z":"f704e565.cd5f6","device":"4608f02f8d4f60fe","dataType":"int32-table","tagName":"uoLogInjectorPulseCount","tableStartIndex":"2","tableLength":"1","value":"injectorPulse3","valueType":"msg","topic":"","topicType":"none","name":"Inj #3 Pulse","x":950,"y":440,"wires":[["e89537cb19403243"]]},{"id":"e89537cb19403243","type":"pac-read","z":"f704e565.cd5f6","device":"4608f02f8d4f60fe","dataType":"int32-table","tagName":"uoLogInjectorPulseCount","tableStartIndex":"3","tableLength":"1","value":"injectorPulse4","valueType":"msg","topic":"","topicType":"none","name":"Inj #4 Pulse","x":1110,"y":440,"wires":[["4b2270c156138047"]]},{"id":"4b2270c156138047","type":"pac-read","z":"f704e565.cd5f6","device":"4608f02f8d4f60fe","dataType":"int32-table","tagName":"uoLogInjectorPulseCount","tableStartIndex":"4","tableLength":"1","value":"injectorPulse5","valueType":"msg","topic":"","topicType":"none","name":"Inj #5 Pulse","x":1270,"y":440,"wires":[["bb61e7087c31567c"]]},{"id":"bb61e7087c31567c","type":"pac-read","z":"f704e565.cd5f6","device":"4608f02f8d4f60fe","dataType":"int32-table","tagName":"uoLogInjectorPulseCount","tableStartIndex":"5","tableLength":"1","value":"injectorPulse6","valueType":"msg","topic":"","topicType":"none","name":"Inj #6 Pulse","x":1430,"y":440,"wires":[["4d3e599bb15e9a55"]]},{"id":"4d3e599bb15e9a55","type":"pac-read","z":"f704e565.cd5f6","device":"4608f02f8d4f60fe","dataType":"int32-table","tagName":"uoLogInjectorPulseCount","tableStartIndex":"6","tableLength":"1","value":"injectorPulse7","valueType":"msg","topic":"","topicType":"none","name":"Inj #7 Pulse","x":630,"y":500,"wires":[["9aa18a0780f5c122"]]},{"id":"9aa18a0780f5c122","type":"pac-read","z":"f704e565.cd5f6","device":"4608f02f8d4f60fe","dataType":"int32-table","tagName":"uoLogInjectorPulseCount","tableStartIndex":"7","tableLength":"1","value":"injectorPulse8","valueType":"msg","topic":"","topicType":"none","name":"Inj #8 Pulse","x":790,"y":500,"wires":[["34b811e0cba87150"]]},{"id":"34b811e0cba87150","type":"pac-read","z":"f704e565.cd5f6","device":"4608f02f8d4f60fe","dataType":"int32-table","tagName":"uoLogInjectorPulseCount","tableStartIndex":"8","tableLength":"1","value":"injectorPulse9","valueType":"msg","topic":"","topicType":"none","name":"Inj #9 Pulse","x":950,"y":500,"wires":[["ec6d0643a76bee0b"]]},{"id":"ec6d0643a76bee0b","type":"pac-read","z":"f704e565.cd5f6","device":"4608f02f8d4f60fe","dataType":"int32-table","tagName":"uoLogInjectorPulseCount","tableStartIndex":"9","tableLength":"1","value":"injectorPulse10","valueType":"msg","topic":"","topicType":"none","name":"Inj #10 Pulse","x":1110,"y":500,"wires":[["8458744ae2feef2a"]]},{"id":"8458744ae2feef2a","type":"pac-read","z":"f704e565.cd5f6","device":"4608f02f8d4f60fe","dataType":"int32-table","tagName":"uoLogInjectorPulseCount","tableStartIndex":"10","tableLength":"1","value":"injectorPulse11","valueType":"msg","topic":"","topicType":"none","name":"Inj #11 Pulse","x":1270,"y":500,"wires":[["9f9b1c84b57f0080"]]},{"id":"9f9b1c84b57f0080","type":"pac-read","z":"f704e565.cd5f6","device":"4608f02f8d4f60fe","dataType":"int32-table","tagName":"uoLogInjectorPulseCount","tableStartIndex":"11","tableLength":"1","value":"injectorPulse12","valueType":"msg","topic":"","topicType":"none","name":"Inj #12 Pulse","x":1430,"y":500,"wires":[["53318f297862d588"]]},{"id":"09f9f263024e1384","type":"inject","z":"f704e565.cd5f6","name":"","props":[],"repeat":"10","crontab":"","once":true,"onceDelay":0.1,"topic":"","x":210,"y":740,"wires":[[]]},{"id":"43bf4af643141c51","type":"pac-read","z":"f704e565.cd5f6","device":"4608f02f8d4f60fe","dataType":"float-variable","tagName":"fFlowRate","tableStartIndex":"","tableLength":"","value":"Flowrate","valueType":"msg","topic":"","topicType":"none","name":"Flow Rate","x":340,"y":740,"wires":[["073457424a29b839"]]},{"id":"ac165f144df66bc2","type":"pac-read","z":"f704e565.cd5f6","device":"4608f02f8d4f60fe","dataType":"float-variable","tagName":"fCurrentEC","tableStartIndex":"","tableLength":"","value":"ECOut","valueType":"msg","topic":"","topicType":"none","name":"EC out","x":1310,"y":740,"wires":[["0fbd23506da716d1"]]},{"id":"dc5bbc9c969237a6","type":"pac-read","z":"f704e565.cd5f6","device":"4608f02f8d4f60fe","dataType":"float-variable","tagName":"fAuxPH","tableStartIndex":"","tableLength":"","value":"PHIn","valueType":"msg","topic":"","topicType":"none","name":"pH In","x":950,"y":740,"wires":[["04238e3043e461a4"]]},{"id":"073457424a29b839","type":"pac-read","z":"f704e565.cd5f6","device":"4608f02f8d4f60fe","dataType":"float-variable","tagName":"fCurrentTEMP","tableStartIndex":"","tableLength":"","value":"Temperature","valueType":"msg","topic":"","topicType":"none","name":"Temperature","x":490,"y":740,"wires":[["4f1dd184c7bef72b"]]},{"id":"aaae2a5b94258471","type":"pac-read","z":"f704e565.cd5f6","device":"4608f02f8d4f60fe","dataType":"float-variable","tagName":"fAuxEC","tableStartIndex":"","tableLength":"","value":"ECIn","valueType":"msg","topic":"","topicType":"none","name":"EC In","x":1190,"y":740,"wires":[["ac165f144df66bc2"]]},{"id":"4f1dd184c7bef72b","type":"pac-read","z":"f704e565.cd5f6","device":"4608f02f8d4f60fe","dataType":"float-variable","tagName":"fCurrentPRESSURE_Int","tableStartIndex":"","tableLength":"","value":"PressureInt","valueType":"msg","topic":"","topicType":"none","name":"Pressure Int","x":650,"y":740,"wires":[["834b2e37f6412604"]]},{"id":"0fbd23506da716d1","type":"MSSQL","z":"f704e565.cd5f6","mssqlCN":"349d7e7b6a84c1bd","name":"","query":"-- Check if the Fertigation Manager database exists, and create it if not\nIF NOT EXISTS (SELECT * FROM sys.databases WHERE name = 'FertigationManager')\nBEGIN\n CREATE DATABASE FertigationManager;\nEND;\n\n-- Use the Fertigation Manager database\nUSE FertigationManager;\n\n-- Check if the SensorReading table exists, and create it if not\nIF NOT EXISTS (SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'SensorReading')\nBEGIN\n CREATE TABLE SensorReading (\n ID INT IDENTITY(1,1) PRIMARY KEY,\n DateTimeStamp DATETIME,\n [Flow Rate] FLOAT,\n Temperature FLOAT,\n [Pressure Int] FLOAT,\n [Pressure Ext] FLOAT,\n [pH In] FLOAT,\n [pH Out] FLOAT,\n [EC In] FLOAT,\n [EC Out] FLOAT \n );\nEND;\n\n-- Insert data into the SensorReading table\nINSERT INTO SensorReading (\n DateTimeStamp,\n [Flow Rate],\n Temperature,\n [Pressure Int],\n [Pressure Ext],\n [pH In],\n [pH Out],\n [EC In],\n [EC Out]\n)\nVALUES (\n GETDATE(),\n {{Flowrate}},\n {{Temperature}},\n {{PressureInt}},\n {{PressureExt}},\n {{PHIn}},\n {{PHOut}},\n {{ECIn}},\n {{ECOut}}\n);\n","outField":"payload","x":1440,"y":740,"wires":[["443c6229f6288446"]]},{"id":"443c6229f6288446","type":"debug","z":"f704e565.cd5f6","name":"debug 1","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1580,"y":740,"wires":[]},{"id":"834b2e37f6412604","type":"pac-read","z":"f704e565.cd5f6","device":"4608f02f8d4f60fe","dataType":"float-variable","tagName":"fCurrentPRESSURE_Ext","tableStartIndex":"","tableLength":"","value":"PressureExt","valueType":"msg","topic":"","topicType":"none","name":"Pressure Ext","x":810,"y":740,"wires":[["dc5bbc9c969237a6"]]},{"id":"04238e3043e461a4","type":"pac-read","z":"f704e565.cd5f6","device":"4608f02f8d4f60fe","dataType":"float-variable","tagName":"fCurrentPH","tableStartIndex":"","tableLength":"","value":"PHOut","valueType":"msg","topic":"","topicType":"none","name":"pH out","x":1070,"y":740,"wires":[["aaae2a5b94258471"]]},{"id":"4608f02f8d4f60fe","type":"pac-device","address":"localhost","protocol":"https","msgQueueFullBehavior":"DROP_OLD"},{"id":"349d7e7b6a84c1bd","type":"MSSQL-CN","name":"SQL Database","server":"192.168.1.26","encyption":false,"database":""}]