[ { "id": "c1906536.fad568", "type": "tab", "order": 0, "label": "I2C", "disabled": false }, { "id": "d283bcbc.b69d5", "type": "tab", "order": 1, "label": "AutoI2C", "disabled": false }, { "id": "1eb3b21c.22109e", "type": "tab", "order": 2, "label": "Websockets_signal" }, { "id": "cf05a7c3.35f5e8", "type": "tab", "order": 3, "label": "ConfigPage", "disabled": false }, { "id": "efc17199.b2e58", "type": "i2c bus", "__package": "luvitred/core-io", "__version": "0.1.0", "bus": "/dev/i2c-1", "__users": [ "ecb40883.ed0578" ] }, { "id": "5334b2fb.07a66c", "type": "http server", "__package": "luvitred/core-io", "__version": "0.1.0", "mode": "http", "port": "8888", "firewall": false, "host": "0.0.0.0", "tlsserverconfig": "_ADD_", "authpasswd": false, "cors": false, "realm": "", "__users": [ "d157ab6.f456258", "66820228.34675c", "e8107983.6f4bb8" ] }, { "id": "f7a8ec5.e874f1", "type": "ui config", "__package": "luvitred/ui", "__version": "0.1.0", "menuname": "i2c Sensor Configuration", "__users": [ "8fd838a7.127028" ] }, { "id": "92470fea.7bc22", "type": "ui section", "__package": "luvitred/ui", "__version": "0.1.0", "name": "Fahrenheit/Celsius selection", "order": 1, "__users": [ "8fd838a7.127028" ] }, { "id": "b3eb30d9.dd259", "type": "debug", "__package": "luvitred/core-core", "__version": "0.1.0", "name": "", "active": true, "highlight": "gold", "console": "true", "complete": "payload", "completetype": "msg", "x": 575, "y": 425, "z": "c1906536.fad568", "wires": [] }, { "id": "ecb40883.ed0578", "type": "i2c dev", "__package": "luvitred/core-io", "__version": "0.1.0", "bus": "efc17199.b2e58", "name": "I2C", "addr": "112", "addrtype": "num", "cmd": "cmd", "cmdtype": "msg", "args": "payload", "argstype": "msg", "x": 600, "y": 250, "z": "c1906536.fad568", "wires": [ [ "3331768e.e2145a", "f178bdbd.e39a9", "38f4b98e.933626" ] ] }, { "id": "bc1ef1c6.c7ad2", "type": "inject", "__package": "luvitred/core-core", "__version": "0.1.0", "name": "WakeUP", "key": "payload", "topic": "wakeup", "payload": "wakeup", "payloadType": "date", "fromval": 0, "toval": 10, "repeat": "", "crontab": "", "once": false, "x": 212.5, "y": 175, "z": "c1906536.fad568", "wires": [ [ "6898bb27.4787b4" ] ] }, { "id": "51083a03.f4ce34", "type": "inject", "__package": "luvitred/core-core", "__version": "0.1.0", "name": "MeasureRH", "key": "payload", "topic": "measurerh", "payload": "measurerh", "payloadType": "date", "fromval": 0, "toval": 10, "repeat": "", "crontab": "", "once": false, "x": 212.5, "y": 250, "z": "c1906536.fad568", "wires": [ [ "6898bb27.4787b4" ] ] }, { "id": "21162198.e0235e", "type": "inject", "__package": "luvitred/core-core", "__version": "0.1.0", "name": "Read", "key": "payload", "topic": "read", "payload": "read", "payloadType": "date", "fromval": 0, "toval": 10, "repeat": "", "crontab": "", "once": false, "x": 220, "y": 299, "z": "c1906536.fad568", "wires": [ [ "6898bb27.4787b4" ] ] }, { "id": "dad6f755.b6d298", "type": "inject", "__package": "luvitred/core-core", "__version": "0.1.0", "name": "Sleep", "key": "payload", "topic": "sleep", "payload": "sleep", "payloadType": "date", "fromval": 0, "toval": 10, "repeat": "", "crontab": "", "once": false, "x": 220, "y": 374, "z": "c1906536.fad568", "wires": [ [ "6898bb27.4787b4" ] ] }, { "id": "6898bb27.4787b4", "type": "function", "__package": "luvitred/core-core", "__version": "0.1.0", "name": "SetCommands", "func": "topic=msg.topic\n\np(topic)\nif topic == \"read\" then\n msg.cmd = 'read'\n msg.payload = 6\nelseif topic == \"wakeup\" then\n msg.cmd = 'write'\n msg.payload = string.char(tonumber('0x35'),tonumber('0x17'))\nelseif topic == \"reset\" then\n msg.cmd = 'write'\n msg.payload = string.char(tonumber('0x80'),tonumber('0x5d'))\nelseif topic == \"sleep\" then\n msg.cmd = 'write'\n msg.payload = string.char(tonumber('0xb0'),tonumber('0x98'))\nelseif topic == \"measurerh\" then\n msg.cmd = 'write'\n msg.payload = string.char(tonumber('0x5c'),tonumber('0x24'))\nelse\n p(\"Unknown command: \"..topic)\n return\nend\n\nreturn msg", "startnil": false, "outputs": 1, "x": 425, "y": 250, "z": "c1906536.fad568", "wires": [ [ "ecb40883.ed0578", "90ecdb37.fb7188" ] ] }, { "id": "1ca3555e.bddccb", "type": "inject", "__package": "luvitred/core-core", "__version": "0.1.0", "name": "Reset", "key": "payload", "topic": "reset", "payload": "reset", "payloadType": "date", "fromval": 0, "toval": 10, "repeat": "", "crontab": "", "once": true, "x": 220, "y": 424, "z": "c1906536.fad568", "wires": [ [ "6898bb27.4787b4" ] ] }, { "id": "3331768e.e2145a", "type": "debug", "__package": "luvitred/core-core", "__version": "0.1.0", "name": "", "active": false, "highlight": "green", "console": "false", "complete": "payload", "completetype": "msg", "x": 550, "y": 325, "z": "c1906536.fad568", "wires": [] }, { "id": "f178bdbd.e39a9", "type": "function", "__package": "luvitred/core-core", "__version": "0.1.0", "name": "Calculations", "func": "local function crc_check(data,numbytes,checksum)\n local crc = 0xff\n local CRC_POLYNOMIAL=0X131\n \n for bytectr=1,numbytes,1 do\n crc=bit.bxor(crc,data[bytectr])\n for cbit=8,1,-1 do\n if(bit.band(crc,0x80)~=0)then\n crc=bit.bxor(bit.lshift(crc,1),CRC_POLYNOMIAL)\n else\n crc=bit.lshift(crc,1)\n end\n end\n end\n --p(crc)\n --p(checksum)\n if crc ~= checksum then\n p(\"CHECKSUM ERROR\")\n statusError(\"CHECKSUM ERROR\")\n else\n p(\"CHECKSUM OK\")\n end\nend\n\nif msg.topic == \"read\" then\nb1 = string.byte(msg.payload,1)\nb2 = string.byte(msg.payload,2)\nb3 = string.byte(msg.payload,3)\nb4 = string.byte(msg.payload,4)\nb5 = string.byte(msg.payload,5)\nb6 = string.byte(msg.payload,6)\n--res={b1,b2,b3,b4,b5,b6}\n--p(res)\nres1={b1,b2}\n--p(res1)\nres2={b4,b5}\n--p(res2)\n\nHum_raw = bit.bor(bit.lshift(b1,8),b2)\n--p(Hum_raw)\nHum_crc = b3\n--p(Hum_crc)\nTemp_raw = bit.bor(bit.lshift(b4,8),b5)\n--p(Temp_raw)\nTemp_crc = b6\n--p(Temp_crc)\n\nTempC = 175*Temp_raw/65536 -45\n--p(TempC)\nHum = 100*Hum_raw/65536\n--p(Hum)\n\np(\"Hum CRC check (\"..Hum_crc..\")\")\ncrc_check(res1,2,Hum_crc)\np(\"Temp CRC check (\"..Temp_crc..\")\")\ncrc_check(res2,2,Temp_crc)\n\nmsg.payload = {\n temp=TempC,\n hum=Hum\n}\nreturn msg\nend", "startnil": false, "outputs": 1, "x": 425, "y": 375, "z": "c1906536.fad568", "wires": [ [ "b3eb30d9.dd259", "716bb7e8.06d648" ] ] }, { "id": "c7641c0a.94082", "type": "inject", "__package": "luvitred/core-core", "__version": "0.1.0", "name": "Init", "key": "payload", "topic": "wakeup", "payload": "wakeup", "payloadType": "date", "fromval": 0, "toval": 10, "repeat": "10", "crontab": "", "once": false, "x": 100, "y": 75, "z": "d283bcbc.b69d5", "wires": [ [ "7695e481.9c262c", "353b4abe.5aade6" ] ] }, { "id": "7695e481.9c262c", "type": "link out", "__package": "luvitred/core-core", "__version": "0.1.0", "name": "", "links": [ "1d696f5a.1434f1" ], "x": 465, "y": 75, "z": "d283bcbc.b69d5", "wires": [] }, { "id": "1d696f5a.1434f1", "type": "link in", "__package": "luvitred/core-core", "__version": "0.1.0", "name": "SetCommands", "links": [ "7695e481.9c262c" ], "x": 340, "y": 150, "z": "c1906536.fad568", "wires": [ [ "6898bb27.4787b4" ] ] }, { "id": "353b4abe.5aade6", "type": "trigger", "__package": "luvitred/core-core", "__version": "0.1.0", "op1": "1", "op2": "0", "op1type": "nul", "op2type": "pay", "duration": "100", "extend": "false", "units": "ms", "trigger": "msg", "name": "100ms", "x": 250, "y": 100, "z": "d283bcbc.b69d5", "wires": [ [ "ab241307.41217" ] ] }, { "id": "ab241307.41217", "type": "change", "__package": "luvitred/core-logic", "__version": "0.1.0", "action": "replace", "property": "topic", "propertytype": "msg", "from": "", "to": "\"measurerh\"", "reg": false, "name": "MeasureRH", "x": 300, "y": 150, "z": "d283bcbc.b69d5", "wires": [ [ "7695e481.9c262c", "80b252d.205c3b" ] ] }, { "id": "80b252d.205c3b", "type": "trigger", "__package": "luvitred/core-core", "__version": "0.1.0", "op1": "1", "op2": "0", "op1type": "nul", "op2type": "pay", "duration": "100", "extend": "false", "units": "ms", "trigger": "msg", "name": "100ms", "x": 300, "y": 200, "z": "d283bcbc.b69d5", "wires": [ [ "7af73db4.35bcd4" ] ] }, { "id": "7af73db4.35bcd4", "type": "change", "__package": "luvitred/core-logic", "__version": "0.1.0", "action": "replace", "property": "topic", "propertytype": "msg", "from": "", "to": "\"read\"", "reg": false, "name": "Read", "x": 325, "y": 250, "z": "d283bcbc.b69d5", "wires": [ [ "7695e481.9c262c", "6f87903b.87dbf" ] ] }, { "id": "6f87903b.87dbf", "type": "trigger", "__package": "luvitred/core-core", "__version": "0.1.0", "op1": "1", "op2": "0", "op1type": "nul", "op2type": "pay", "duration": "100", "extend": "false", "units": "ms", "trigger": "msg", "name": "100ms", "x": 350, "y": 300, "z": "d283bcbc.b69d5", "wires": [ [ "3992745a.8c146c" ] ] }, { "id": "3992745a.8c146c", "type": "change", "__package": "luvitred/core-logic", "__version": "0.1.0", "action": "replace", "property": "topic", "propertytype": "msg", "from": "", "to": "\"sleep\"", "reg": false, "name": "Sleep", "x": 375, "y": 350, "z": "d283bcbc.b69d5", "wires": [ [ "7695e481.9c262c" ] ] }, { "id": "d157ab6.f456258", "type": "http in", "__package": "luvitred/core-io", "__version": "0.1.0", "name": "", "topic": "", "server": "5334b2fb.07a66c", "timeout": 0, "streamin": false, "url": "/i2c", "method": "get", "psize": 0, "x": 137.5, "y": 325, "z": "1eb3b21c.22109e", "wires": [ [ "8784435f.475fd" ] ] }, { "id": "785a369a.41ea28", "type": "http response", "__package": "luvitred/core-io", "__version": "0.1.0", "name": "", "x": 557, "y": 327, "z": "1eb3b21c.22109e", "wires": [] }, { "id": "66820228.34675c", "type": "websocket out", "__package": "luvitred/core-io", "__version": "0.1.0", "name": "", "wholemsg": "false", "server": "5334b2fb.07a66c", "x": 862.5, "y": 100, "z": "1eb3b21c.22109e", "wires": [] }, { "id": "e9489fef.37ffa", "type": "function", "__package": "luvitred/core-core", "__version": "0.1.0", "name": "Extract", "func": "if msg.payload.hum and msg.payload.temp then\n if type(msg.payload.hum) == \"number\" then\n msg.payload.hum=math.floor(msg.payload.hum*100)/100\n end\n if type(msg.payload.temp) == \"number\" then\n msg.payload.temp=math.floor(msg.payload.temp*100)/100\n end\n \n if global.tempselect == \"1\" then\n if type(msg.payload.temp) == \"number\" then\n global.i2c = {{hum=msg.payload.hum..\" %\", temp=((msg.payload.temp)*9/5 + 32)..\" °F\"}}\n else\n global.i2c = {{hum=msg.payload.hum, temp=msg.payload.temp}}\n end\n else\n if type(msg.payload.hum) == \"number\" and type(msg.payload.temp) == \"number\" then\n global.i2c = {{hum=msg.payload.hum..\" %\", temp=msg.payload.temp..\" °C\"}}\n else\n global.i2c = {{hum=msg.payload.hum, temp=msg.payload.temp}}\n end\n end\n \n msg.payload = global.i2c\n return msg\nend", "startnil": false, "outputs": 1, "x": 525.50003051758, "y": 98, "z": "1eb3b21c.22109e", "wires": [ [ "c0f35c9e.b219b" ] ] }, { "id": "c0f35c9e.b219b", "type": "json", "__package": "luvitred/core-parsers", "__version": "0.1.0", "name": "", "x": 691.5, "y": 99, "z": "1eb3b21c.22109e", "wires": [ [ "66820228.34675c", "687fa359.985b2c" ] ] }, { "id": "e8107983.6f4bb8", "type": "websocket in", "__package": "luvitred/core-io", "__version": "0.1.0", "name": "", "topic": "modbus", "wholemsg": "false", "url": "/ws", "server": "5334b2fb.07a66c", "x": 136.00003051758, "y": 243, "z": "1eb3b21c.22109e", "wires": [ [] ] }, { "id": "8784435f.475fd", "type": "template", "__package": "luvitred/core-core", "__version": "0.1.0", "name": "", "field": "", "template": "\n\n
\nI2C Sensor
\n \tHUM: ?
\n \tTEMP: ?
\n\t