Skip to content

Instantly share code, notes, and snippets.

@jpwsutton
Last active May 30, 2018 07:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jpwsutton/7ff76acfd165059b3977d3ae3a00607c to your computer and use it in GitHub Desktop.
Save jpwsutton/7ff76acfd165059b3977d3ae3a00607c to your computer and use it in GitHub Desktop.
Node-Red flow for controlling and connecting to a Fujifilm INSTAX Printer
[
{
"id": "5e4a70ef.bac7a",
"type": "tab",
"label": "Flow 1",
"disabled": false,
"info": ""
},
{
"id": "17f15d16.6e3143",
"type": "subflow",
"name": "Toggle Instax Power",
"info": "",
"in": [
{
"x": 60,
"y": 80,
"wires": [
{
"id": "cde60f00.626b8"
}
]
}
],
"out": []
},
{
"id": "2baee422.fab20c",
"type": "subflow",
"name": "INSTAX online?",
"info": "Checks for a WiFi network that begins with instax.\nIf available, the SSID will be returned.",
"in": [
{
"x": 320,
"y": 160,
"wires": [
{
"id": "22e7b1cb.a1408e"
}
]
}
],
"out": [
{
"x": 660,
"y": 160,
"wires": [
{
"id": "22e7b1cb.a1408e",
"port": 0
}
]
}
]
},
{
"id": "fd8a21ec.d31a3",
"type": "inject",
"z": "5e4a70ef.bac7a",
"name": "",
"topic": "",
"payload": "0",
"payloadType": "num",
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"x": 110,
"y": 60,
"wires": [
[
"88c52421.53f3c8"
]
]
},
{
"id": "992699da.82c778",
"type": "inject",
"z": "5e4a70ef.bac7a",
"name": "",
"topic": "",
"payload": "100",
"payloadType": "num",
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"x": 110,
"y": 140,
"wires": [
[
"88c52421.53f3c8"
]
]
},
{
"id": "88c52421.53f3c8",
"type": "pi-gpiod out",
"z": "5e4a70ef.bac7a",
"name": "",
"host": "localhost",
"port": 8888,
"pin": "2",
"set": "",
"level": "0",
"out": "ser",
"sermin": "600",
"sermax": "2400",
"x": 260,
"y": 100,
"wires": []
},
{
"id": "dac09d7.b3b086",
"type": "inject",
"z": "5e4a70ef.bac7a",
"name": "",
"topic": "",
"payload": "50",
"payloadType": "num",
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"x": 110,
"y": 100,
"wires": [
[
"88c52421.53f3c8"
]
]
},
{
"id": "c4503177.2a743",
"type": "inject",
"z": "5e4a70ef.bac7a",
"name": "Toggle Power",
"topic": "",
"payload": "true",
"payloadType": "bool",
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"x": 650,
"y": 140,
"wires": [
[
"c0137ced.a10bf"
]
]
},
{
"id": "49559a6b.ce6964",
"type": "inject",
"z": "5e4a70ef.bac7a",
"name": "Connect to Instax network if available.",
"topic": "",
"payload": "",
"payloadType": "date",
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"x": 250,
"y": 320,
"wires": [
[
"b80130a1.6e6f2"
]
]
},
{
"id": "b6fd59b6.63c738",
"type": "debug",
"z": "5e4a70ef.bac7a",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"x": 550,
"y": 320,
"wires": []
},
{
"id": "e4e8a53b.31d7c8",
"type": "pi-gpiod out",
"z": "17f15d16.6e3143",
"name": "",
"host": "localhost",
"port": 8888,
"pin": "4",
"set": true,
"level": "0",
"out": "out",
"sermin": "1000",
"sermax": "2000",
"x": 600,
"y": 120,
"wires": []
},
{
"id": "cde60f00.626b8",
"type": "function",
"z": "17f15d16.6e3143",
"name": "Set High",
"func": "msg.payload = 1;\nreturn msg;",
"outputs": 1,
"noerr": 0,
"x": 240,
"y": 80,
"wires": [
[
"e4e8a53b.31d7c8",
"738a1928.774e28"
]
]
},
{
"id": "738a1928.774e28",
"type": "delay",
"z": "17f15d16.6e3143",
"name": "",
"pauseType": "delay",
"timeout": "1",
"timeoutUnits": "seconds",
"rate": "1",
"nbRateUnits": "1",
"rateUnits": "second",
"randomFirst": "1",
"randomLast": "5",
"randomUnits": "seconds",
"drop": false,
"x": 420,
"y": 60,
"wires": [
[
"28622509.0e84aa"
]
]
},
{
"id": "28622509.0e84aa",
"type": "function",
"z": "17f15d16.6e3143",
"name": "Set Low",
"func": "msg.payload = 0;\nreturn msg;",
"outputs": 1,
"noerr": 0,
"x": 560,
"y": 60,
"wires": [
[
"e4e8a53b.31d7c8"
]
]
},
{
"id": "c0137ced.a10bf",
"type": "subflow:17f15d16.6e3143",
"z": "5e4a70ef.bac7a",
"name": "",
"x": 910,
"y": 140,
"wires": []
},
{
"id": "22e7b1cb.a1408e",
"type": "function",
"z": "2baee422.fab20c",
"name": "Is INSTAX SSID present",
"func": "var piWifi = global.get('piwifi');\n\n\n\npiWifi.scan(function(err, networks) {\n if (err) {\n return console.error(err.message);\n }\n for (var x = 0; x < networks.length; x++){\n\n if( 'ssid' in networks[x] && networks[x].ssid.startsWith(\"INSTAX-\")){\n node.send({payload:networks[x].ssid});\n }\n}\n \n});\n\n\n\n\n",
"outputs": 1,
"noerr": 0,
"x": 470,
"y": 160,
"wires": [
[]
]
},
{
"id": "b80130a1.6e6f2",
"type": "subflow:2baee422.fab20c",
"z": "5e4a70ef.bac7a",
"name": "",
"x": 400,
"y": 380,
"wires": [
[
"b6fd59b6.63c738",
"d85201ae.a11be"
]
]
},
{
"id": "d85201ae.a11be",
"type": "function",
"z": "5e4a70ef.bac7a",
"name": "Connect to network",
"func": "var piWifi = global.get('piwifi');\n\nvar ssid = msg.payload;\n\npiWifi.connectTo({ssid: ssid}, function(err) {\n if (!err) { //Network created correctly\n setTimeout(function () {\n piWifi.check(ssid, function (err, status) {\n if (!err && status.connected) {\n node.send({payload:{state: \"connected\", ssid: ssid}});\n } else {\n node.send({payload:{state: \"failed to connect\", ssid: ssid}});\n }\n });\n }, 2000);\n } else {\n node.send({payload:{state: \"failed to create network\", ssid: ssid}});\n }\n})",
"outputs": 1,
"noerr": 0,
"x": 590,
"y": 380,
"wires": [
[
"f4be7644.1f11e8"
]
]
},
{
"id": "f4be7644.1f11e8",
"type": "debug",
"z": "5e4a70ef.bac7a",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"x": 750,
"y": 320,
"wires": []
}
]
@jpwsutton
Copy link
Author

Dependencies:

  • pi-wifi (Node.js)
  • node-red-node-pi-gpiod

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment