Sending Modbus Data to MSSQL

Im trying to send modbus data to MSQL Server, but i dont know where to start. I am inserting query by using insert. But i think i need some function to send modbus data, i just dont know what.
Picture below for flow.
image

The first thing to do is inspect the data you get from MODBUS (turn on the debug output in your green group)
example...

image

Next, using the path to the values, generate a SQL INSERT e.g...

INSERT INTO MyTable (timestamp, volts, curr, temp) VALUES(...) etc

chrome_TbCAREp3r7

Demo Flow (use CTRL+I to import)

image

[{"id":"560772792a1d57f5","type":"inject","z":"85e1791bc0cd6285","name":"ModBus data (faked)","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[4,197,0,181,10,84]","payloadType":"bin","x":1760,"y":80,"wires":[["b836b92b879c896b"]]},{"id":"b836b92b879c896b","type":"buffer-parser","z":"85e1791bc0cd6285","name":"","data":"payload","dataType":"msg","specification":"spec","specificationType":"ui","items":[{"type":"int16be","name":"voltage","offset":0,"length":1,"offsetbit":0,"scale":"/100.0","mask":""},{"type":"int16be","name":"current","offset":2,"length":1,"offsetbit":0,"scale":"/100.0","mask":""},{"type":"int16be","name":"temperature","offset":4,"length":1,"offsetbit":0,"scale":"/100.0","mask":""}],"swap1":"","swap2":"","swap3":"","swap1Type":"swap","swap2Type":"swap","swap3Type":"swap","msgProperty":"payload","msgPropertyType":"str","resultType":"keyvalue","resultTypeType":"return","multipleResult":false,"fanOutMultipleResult":false,"setTopic":true,"outputs":1,"x":1760,"y":140,"wires":[["f5a36fb0ccaa2131","d43ddc0cb87a0896"]]},{"id":"f5a36fb0ccaa2131","type":"debug","z":"85e1791bc0cd6285","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1970,"y":140,"wires":[]},{"id":"d43ddc0cb87a0896","type":"MSSQL","z":"85e1791bc0cd6285","mssqlCN":"491533d6adb397ad","name":"","outField":"payload","returnType":"1","throwErrors":1,"query":"INSERT INTO MyTable \r\n    (timestamp, volts, curr, temp) \r\nVALUES\r\n    (@ts, @v, @c, @t)\r\n","modeOpt":"queryMode","modeOptType":"query","queryOpt":"payload","queryOptType":"editor","paramsOpt":"","paramsOptType":"editor","rows":"rows","rowsType":"msg","params":[{"output":false,"name":"ts","type":"DateTime","valueType":"datetime","value":"0","options":{"nullable":true,"primary":false,"identity":false,"readOnly":false}},{"output":false,"name":"v","type":"Float","valueType":"msg","value":"payload.voltage","options":{"nullable":true,"primary":false,"identity":false,"readOnly":false}},{"output":false,"name":"c","type":"Float","valueType":"msg","value":"payload.current","options":{"nullable":true,"primary":false,"identity":false,"readOnly":false}},{"output":false,"name":"t","type":"Float","valueType":"msg","value":"payload.temperature","options":{"nullable":true,"primary":false,"identity":false,"readOnly":false}}],"x":1780,"y":240,"wires":[["47cda9cbce627b41"]]},{"id":"47cda9cbce627b41","type":"debug","z":"85e1791bc0cd6285","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1950,"y":240,"wires":[]},{"id":"3ed14c2d7304d8d2","type":"catch","z":"85e1791bc0cd6285","name":"","scope":null,"uncaught":false,"x":1800,"y":340,"wires":[["da510def5f9304eb"]]},{"id":"da510def5f9304eb","type":"debug","z":"85e1791bc0cd6285","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1970,"y":340,"wires":[]},{"id":"491533d6adb397ad","type":"MSSQL-CN","tdsVersion":"7_4","name":"","server":"10.176.1.61","port":"1433","encyption":false,"trustServerCertificate":true,"database":"","useUTC":true,"connectTimeout":"15000","requestTimeout":"15000","cancelTimeout":"5000","pool":"5","parseJSON":false,"enableArithAbort":true,"credentials":{"username":"sa","password":"sd1jhb0npb1ptb","domain":""}}]

Canned Text...

As a new user, you will learn many of the tips and tricks I showed you by watching this playlist: Node-RED Essentials. The videos are done by the developers of node-red. They're nice & short and to the point. You will understand a whole lot more in about 1 hour. A small investment for a lot of gain.

Thanks for the help, i got it to work now!!
I will definitely watch the videos!

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