Hi,
Been struggling for a while to get this to work (saving multiple sensor readers to MySQL) and finally succeeded but now it saves 2 identical lines each time to the database and I get a sporadic error message from the debug node of the Mysql node;
5/14/2020, 9:37:05 AMnode: monitor DBmsg : error
"Error: ER_BAD_FIELD_ERROR: Unknown column 'NaN' in 'field list'"
Any help or guidance would be appreciated...
[{"id":"992108be.ca8be8","type":"tab","label":"Flow 2","disabled":false,"info":""},{"id":"24eff4.946ed00c","type":"mqtt in","z":"992108be.ca8be8","name":"pool","topic":"esp8266/temppool","qos":"0","datatype":"auto","broker":"a414d62.a841f28","x":90,"y":240,"wires":[["be869ffb.c85e8"]]},{"id":"9125ef0d.73a4e","type":"function","z":"992108be.ca8be8","name":"insert data","func":"var Sensor_Val= parseFloat(msg.pool);\nvar Temp_Val= parseFloat(msg.ldr2);\n\nmsg.topic = \"INSERT INTO nodered (data1, data2) VALUES (?,?)\";\nmsg.payload = [Sensor_Val, Temp_Val];\nreturn msg;\n\n//// replace myTable with your db table name \n//msg.topic = \"INSERT INTO Sensor_data (Sensor_Val, Time, Sensor_Name) VALUES (?,?,?)\";\n//msg.payload = [sensorVal, timeStamp, sensorName];\n//return msg;","outputs":1,"noerr":0,"x":610,"y":300,"wires":[["4321defc.dae73"]]},{"id":"ac0b2bc1.0ea6a8","type":"debug","z":"992108be.ca8be8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":970,"y":300,"wires":[]},{"id":"4321defc.dae73","type":"mysql","z":"992108be.ca8be8","mydb":"a7f567b9.54f4b8","name":"monitor DB","x":790,"y":300,"wires":[["ac0b2bc1.0ea6a8"]]},{"id":"4993bafa.cc5ab4","type":"mqtt in","z":"992108be.ca8be8","name":"ldr2","topic":"esp8266/ldr2","qos":"0","datatype":"auto","broker":"a414d62.a841f28","x":90,"y":360,"wires":[["2b6551ab.1a330e"]]},{"id":"2874b5d1.e599da","type":"delay","z":"992108be.ca8be8","name":"","pauseType":"timed","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"minute","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":true,"x":270,"y":300,"wires":[["bcfed16e.72836"]]},{"id":"be869ffb.c85e8","type":"change","z":"992108be.ca8be8","name":"","rules":[{"t":"move","p":"payload","pt":"msg","to":"pool","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":290,"y":240,"wires":[["2874b5d1.e599da"]]},{"id":"2b6551ab.1a330e","type":"change","z":"992108be.ca8be8","name":"","rules":[{"t":"move","p":"payload","pt":"msg","to":"ldr2","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":290,"y":360,"wires":[["2874b5d1.e599da"]]},{"id":"bcfed16e.72836","type":"join","z":"992108be.ca8be8","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":", ","joinerType":"str","accumulate":true,"timeout":"","count":"1","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":450,"y":300,"wires":[["9125ef0d.73a4e"]]},{"id":"a414d62.a841f28","type":"mqtt-broker","z":"","name":"192.168.0.75","broker":"192.168.0.75","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"a7f567b9.54f4b8","type":"MySQLdatabase","z":"","name":"monitor db","host":"192.168.0.77","port":"3306","db":"monitor","tz":""}]