The problem is when inserting data from modbus into a SQL database. I use phpMyadmin to create the SQL database, that's right. Modbus and Database nodes work well, but I can't pass the array on the function nodes (conversion node) a variable. He dividido el array con el Split node pero no funciona, I would only need two variables but it divides them all. All values that are written to phpMyadmin are zero values, but do not pass the data.
Share your flow and copy the output from debug 2
(use the copy button that appears under your mouse cursor when you hover over the debug message)
Please format the flow code and the debug message between three backticks
```
[{ code here on a new line }]
```
Debug 2 doesn't seem to perform any function, it doesn't work.
Sorry, yes, attach debug 2 to the top output of the modbus. Also, set "debug 2" to "show complete message"
then capture the output as I said before.
I need this (and your flow) to be able to show you where you are going wrong.
@santos I can do nothing with screen shots. I need your flow and I need some demo data from your real device!!!
Select your nodes (draw a box around them) then export your flow (CTRL+E) and paste the flow in a reply.
I also need you to capture the output of the Modbus Node (debug 2 - connected to top output and set to complete message) - THEN - as i said before - "use the copy button that appears under your mouse cursor when you hover over the debug message" then paste that too into a reply.
[{"id":"b0c1ce72.a3a62","type":"debug","z":"a04d7baf.796ac8","name":"Debug 1","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":680,"y":240,"wires":[]},{"id":"a5a9c118.a7cf4","type":"mysql","z":"a04d7baf.796ac8","mydb":"3f07f41d.dbab3c","name":"Data","x":650,"y":360,"wires":[[]]},{"id":"d8670ee5.39841","type":"inject","z":"a04d7baf.796ac8","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":360,"y":240,"wires":[["8b46e5a.93d3818"]]},{"id":"b88d2ed.80bead","type":"modbus-read","z":"a04d7baf.796ac8","name":"Modbus","topic":"","showStatusActivities":false,"logIOActivities":false,"showErrors":false,"unitid":"","dataType":"InputRegister","adr":"0000","quantity":"1","rate":"10","rateUnit":"s","delayOnStart":false,"startDelayTime":"","server":"724fa2d9.5914bc","useIOFile":false,"ioFile":"","useIOForPayload":false,"emptyMsgOnFail":false,"x":90,"y":360,"wires":[["f7649c87.95c0f"],["bf2a86d9.cb3bb8"]]},{"id":"bf2a86d9.cb3bb8","type":"function","z":"a04d7baf.796ac8","name":"conversion ","func":"msg.payload=new Array(8);\nmsg.payload[0]=Math.round(Math.random()*(40-30)+30);\nmsg.payload[1]=Math.round(Math.random()*(40-30)+30);\nmsg.payload[2]=Math.round(Math.random()*(40-30)+30);\nmsg.payload[3]=Math.round(Math.random()*(40-30)+30);\nmsg.payload[4]=Math.round(Math.random()*(40-30)+30);\nmsg.payload[5]=Math.round(Math.random()*(40-30)+30);\nmsg.payload[6]=Math.round(Math.random()*(40-30)+30);\nmsg.payload[7]=Math.round(Math.random()*(40-30)+30);\nmsg.fecha=new Date();\nmsg.hora=msg.fecha.getHours();\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":210,"y":440,"wires":[["9604e030.cc771"]]},{"id":"f7649c87.95c0f","type":"debug","z":"a04d7baf.796ac8","name":"Debug 2","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":240,"y":300,"wires":[]},{"id":"9604e030.cc771","type":"split","z":"a04d7baf.796ac8","name":"Split","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":370,"y":360,"wires":[["6767d632.b27598","8b46e5a.93d3818"]]},{"id":"6767d632.b27598","type":"debug","z":"a04d7baf.796ac8","name":"Debug 3","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":500,"y":440,"wires":[]},{"id":"8b46e5a.93d3818","type":"function","z":"a04d7baf.796ac8","name":"Insert in SQL","func":"var Current = msg.payload.Current\nvar Voltage = msg.payload.Voltage\nmsg.topic = \"INSERT INTO Data(`Current`, `Voltage`) VALUES ('\"+Current+\"', '\"+Voltage+\"')\";\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":530,"y":300,"wires":[["a5a9c118.a7cf4","b0c1ce72.a3a62"]]},{"id":"3f07f41d.dbab3c","type":"MySQLdatabase","name":"","host":"127.0.0.1","port":"3306","db":"Data","tz":"","charset":"UTF8"},{"id":"724fa2d9.5914bc","type":"modbus-client","name":"iologik","clienttype":"tcp","bufferCommands":true,"stateLogEnabled":false,"queueLogEnabled":false,"tcpHost":"192.168.127.250","tcpPort":"502","tcpType":"DEFAULT","serialPort":"/dev/ttyUSB","serialType":"RTU-BUFFERD","serialBaudrate":"9600","serialDatabits":"8","serialStopbits":"1","serialParity":"none","serialConnectionDelay":"100","unit_id":"1","commandDelay":"1","clientTimeout":"1000","reconnectOnTimeout":true,"reconnectTimeout":"2000","parallelUnitIdsAllowed":true}]
Screen shot is not what I need.
For the third and last time...
I need you to capture the debug output produced by the ModBus node.
Look in the debug side bar where debug messages are sent, find the output of "debug 2", hover over the debug message & a button "copy value" will appear under your mouse. Click that and paste your value into a reply.
Like this....
After looking at your flow for 2 minutes, it looks like you are trying to write voltage
and current
that you read from Modbus to a database.
Is that correct?
This is easy and I can show you how but first, please answer every question...
Q1. Which modbus address does voltage
come from?
Q2. What is the data type and scaling of the voltage
value (UINT? Float?)
Q3. Which modbus address does current
come from?
Q4. What is the data type and scaling of the current
value (UINT? Float?)
Q5. do you have a manual that explains what the modbus registers are?
Thank you very much for your interest, I will respond. First debug 2 output.
{"topic":"polling","payload":[12348],"responseBuffer":{"data":[12348],"buffer":[48,60]},"input":{"topic":"polling","from":"Modbus","payload":{"unitid":"","fc":4,"address":"0000","quantity":"1","messageId":"60519a31c5c24d8357604ea6"},"queueLengthByUnitId":{"unitId":1,"queueLength":1},"queueUnitId":1,"unitId":1},"sendingNodeId":"b88d2ed.80bead","_msgid":"85302155.39e77"}
I'm doing some tests with this flow, to read variables and store them in SQL. I called voltage and current. But I don't know how to pass it on modbus.
The registers I am going to work with are sensor readings with the 4-20 mA standard. For now what I have is that, the modbus node does seem to be working fine, but there is something precisely in the conversion that I still do not know well.
This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.