Hi everyone. I looked almost all SQLite topic and didnt get solve my problem.
I created a flow and testing local. Connected DHT11 and 1 cable for test.
I can take sensor values and also GPIO port connected or not connected. But I didnt succeed it to save in DB at SQLİte. DB files is creating in my RPI local.
I installed SQLite but dont have experience about function code. Can some one help me about function code how should be it ?
I also adding some screen shot and my flow. Thanks for your helps.
My Function node is ;
new Date(2018, 11 , 12, 11, 04,0)
var _resultDate = d.toLocaleDateString('de-CH', options);
msg.payload = _resultDate + ' T:' + msg.payload + ' H:' + msg.humidity;
return msg;
Flow
[{"id":"b6f00e41.761ef","type":"rpi-gpio in","z":"f833ce19.4b7f2","name":"","pin":"40","intype":"tri","debounce":"25","read":false,"x":150,"y":120,"wires":[["6cf8d1c6.c57b1"]]},{"id":"6cf8d1c6.c57b1","type":"dsm","z":"f833ce19.4b7f2","name":"state right","sm_config":"{\n \"triggerInput\": \"payload\",\n \"currentState\": \"running\",\n \"states\": {\n \"stopped\": {\n \"0\": \"running\"\n },\n \"running\": {\n \"1\": \"stopped\"\n }\n },\n \"methods\": {\n \"onBeforeTransition\": \"msg.pyload = msg.payload.toString();\",\n \"0\": \"sta.fill='green';msg.background='green';msg.label='Laser 1 Working';\",\n \"1\": \"sta.fill='red';msg.background='red';msg.label='Laser 1 Error!!!';\"\n }\n}","x":336,"y":118,"wires":[["ce065d9c.2bf7d","698821cf.9c9ad"]]},{"id":"ce065d9c.2bf7d","type":"ui_button","z":"f833ce19.4b7f2","name":"Laser 1","group":"7fe16ebd.2f6bb","order":0,"width":0,"height":0,"passthru":false,"label":"{{msg.label}}","color":"","bgcolor":"{{msg.background}}","icon":"","payload":"","payloadType":"str","topic":"","x":500,"y":120,"wires":[[]]},{"id":"206a0f23.962e3","type":"sqlite","z":"f833ce19.4b7f2","mydb":"3a0f3358.0ee28c","sqlquery":"msg.topic","sql":"","name":"Sqlite","x":670,"y":80,"wires":[[]]},{"id":"698821cf.9c9ad","type":"function","z":"f833ce19.4b7f2","name":"Record","func":"","outputs":1,"noerr":0,"x":500,"y":80,"wires":[["206a0f23.962e3"]]},{"id":"1eedbd33.6bf773","type":"ui_gauge","z":"f833ce19.4b7f2","name":"Temp Gauge","group":"51d39551.b1d77c","order":0,"width":0,"height":0,"gtype":"gage","title":"Temp Gauge","label":"°C","format":"{{value}}","min":0,"max":"35","colors":["#00b500","#fb9b44","#ca3838"],"seg1":"","seg2":"","x":710,"y":260,"wires":[]},{"id":"30d30a4b.5b8a76","type":"ui_gauge","z":"f833ce19.4b7f2","name":"Humid Gauge","group":"ca64eeb9.03b0c","order":0,"width":0,"height":0,"gtype":"gage","title":"Humid Gauge","label":"%","format":"{{value}}","min":0,"max":"50","colors":["#00b500","#e6e600","#ca3838"],"seg1":"","seg2":"","x":700,"y":400,"wires":[]},{"id":"487c05d4.5fafcc","type":"ui_chart","z":"f833ce19.4b7f2","name":"Humid Graph","group":"ca64eeb9.03b0c","order":0,"width":0,"height":0,"label":"Humid Graph","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":false,"ymin":"0","ymax":"100","removeOlder":"1","removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"x":690,"y":360,"wires":[[],[]]},{"id":"3d877289.a4cd3e","type":"ui_chart","z":"f833ce19.4b7f2","name":"Temp Graph","group":"51d39551.b1d77c","order":0,"width":0,"height":0,"label":"Temp Graph","chartType":"line","legend":"false","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":false,"ymin":"0","ymax":"50","removeOlder":"1","removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"x":705.0000267028809,"y":226.00000381469727,"wires":[[],[]]},{"id":"92a455b6.ad22e8","type":"function","z":"f833ce19.4b7f2","name":"Humidity","func":"msg.payload = msg.humidity;\nreturn msg;","outputs":1,"noerr":0,"x":500,"y":340,"wires":[["30d30a4b.5b8a76","487c05d4.5fafcc","7763bb14.c0cfe4"]]},{"id":"1bbe8187.919a2e","type":"function","z":"f833ce19.4b7f2","name":"Temperature","func":"msg.payload = msg.payload;\nreturn msg;","outputs":1,"noerr":0,"x":509.9999656677246,"y":298.9999933242798,"wires":[["1eedbd33.6bf773","3d877289.a4cd3e","7763bb14.c0cfe4"]]},{"id":"f20a0124.8beab","type":"rpi-dht22","z":"f833ce19.4b7f2","name":"","topic":"Isi/Nem","dht":"11","pintype":"0","pin":4,"x":300,"y":320,"wires":[["92a455b6.ad22e8","1bbe8187.919a2e"]]},{"id":"a7f66a47.d2f538","type":"rpi-gpio in","z":"f833ce19.4b7f2","name":"","pin":"7","intype":"tri","debounce":"25","read":false,"x":110,"y":340,"wires":[["f20a0124.8beab"]]},{"id":"8e763e28.d77a5","type":"inject","z":"f833ce19.4b7f2","name":"","topic":"","payload":"","payloadType":"date","repeat":"30","crontab":"","once":false,"onceDelay":0.1,"x":135.52993392944336,"y":306.3500499725342,"wires":[["f20a0124.8beab"]]},{"id":"7763bb14.c0cfe4","type":"function","z":"f833ce19.4b7f2","name":"Rec Function","func":"new Date(2018, 11 , 12, 11, 04,0)\nvar _resultDate = d.toLocaleDateString('de-CH', options);\n\n//var d = new Date(2018, 11, 24, 10, 33, 30, 0);\nmsg.payload = _resultDate + ' T:' + msg.payload + ' H:' + msg.humidity;\nreturn msg;","outputs":1,"noerr":0,"x":769.5299110412598,"y":301.350022315979,"wires":[["ac9435a0.fbc6b8","4f988ac8.e745f4"]]},{"id":"4f988ac8.e745f4","type":"e-mail","z":"f833ce19.4b7f2","server":"53.151.100.102","port":"25","secure":false,"name":"//tarik.bellikli@daimler.com","dname":"Mail","x":970,"y":340,"wires":[]},{"id":"ac9435a0.fbc6b8","type":"sqlite","z":"f833ce19.4b7f2","mydb":"3a0f3358.0ee28c","sqlquery":"msg.topic","sql":"","name":"Sql","x":970,"y":260,"wires":[[]]},{"id":"7fe16ebd.2f6bb","type":"ui_group","z":"","name":"Assembly Lines","tab":"6809cbe4.c8aa24","disp":true,"width":"6","collapse":false},{"id":"3a0f3358.0ee28c","type":"sqlitedb","z":"","db":"/var/www/html/database/LaserDB","mode":"RWC"},{"id":"51d39551.b1d77c","type":"ui_group","z":"","name":"Assembly Lines ","tab":"6809cbe4.c8aa24","disp":true,"width":"6","collapse":false},{"id":"ca64eeb9.03b0c","type":"ui_group","z":"","name":"Assembly Lines ","tab":"6809cbe4.c8aa24","disp":true,"width":"6","collapse":false},{"id":"6809cbe4.c8aa24","type":"ui_tab","z":"","name":"Chasis Lines","icon":"dashboard"}]
Screenshot