Seeedstudio Relay board 1.0 for Raspberry Pi

Control a single instance of Seeedstudio's four-relay board using the i2c port.

[{"id":"592dfe9c.b58ce","type":"tab","label":"Seeed Relay board","disabled":false,"info":""},{"id":"a2e54be3.05fe08","type":"i2c scan","z":"592dfe9c.b58ce","x":465,"y":77,"wires":[["11321803.7ce6"],[]]},{"id":"1209fd37.467f0b","type":"i2c out","z":"592dfe9c.b58ce","name":"","address":"32","command":"6","payload":"payload","payloadType":"msg","count":"1","x":744,"y":176,"wires":[]},{"id":"11321803.7ce6","type":"debug","z":"592dfe9c.b58ce","name":"","active":true,"console":"false","complete":"true","x":725,"y":60,"wires":[]},{"id":"3932896a.d2c79e","type":"function","z":"592dfe9c.b58ce","name":"Seeedstudio Relay 1.0","func":"var seeed = global.get(\"SEEED1\") || 0xFF;\nswitch(msg.topic) {\n    case 'on': \n        seeed &= ~(0x1 << (parseInt(msg.payload)-1)); break;\n    case 'off':\n        seeed |= (0x1 << (parseInt(msg.payload)-1)); break;\n    case 'all on':\n        seeed &= ~(0xf << 0); break;\n    case 'all off':\n        seeed = 0xff; break;\n}\nnode.log('Seeed state: '+seeed.toString(16));\nglobal.set(\"SEEED1\", seeed);\nreturn {\"payload\": seeed};","outputs":1,"noerr":0,"x":500,"y":184,"wires":[["1209fd37.467f0b"]]},{"id":"25f16d93.b83662","type":"inject","z":"592dfe9c.b58ce","name":"turn on 1","topic":"on","payload":"1","payloadType":"num","repeat":"","crontab":"","once":false,"x":122,"y":97,"wires":[["3932896a.d2c79e"]]},{"id":"fc7f993.9ffea68","type":"inject","z":"592dfe9c.b58ce","name":"turn off 1","topic":"off","payload":"1","payloadType":"num","repeat":"","crontab":"","once":false,"x":121,"y":126,"wires":[["3932896a.d2c79e"]]},{"id":"76b40e9c.eac65","type":"inject","z":"592dfe9c.b58ce","name":"turn on 2","topic":"on","payload":"2","payloadType":"num","repeat":"","crontab":"","once":false,"x":169,"y":169,"wires":[["3932896a.d2c79e"]]},{"id":"975011bb.5fc71","type":"inject","z":"592dfe9c.b58ce","name":"turn off 2","topic":"off","payload":"2","payloadType":"json","repeat":"","crontab":"","once":false,"x":168,"y":199,"wires":[["3932896a.d2c79e"]]},{"id":"4a43acef.a450f4","type":"inject","z":"592dfe9c.b58ce","name":"turn on 3","topic":"on","payload":"3","payloadType":"num","repeat":"","crontab":"","once":false,"x":211,"y":238,"wires":[["3932896a.d2c79e"]]},{"id":"cda5c0ec.5c4e88","type":"inject","z":"592dfe9c.b58ce","name":"turn off 3","topic":"off","payload":"3","payloadType":"json","repeat":"","crontab":"","once":false,"x":210,"y":268,"wires":[["3932896a.d2c79e"]]},{"id":"29e18fdf.9b4d9","type":"inject","z":"592dfe9c.b58ce","name":"turn off 4","topic":"off","payload":"4","payloadType":"json","repeat":"","crontab":"","once":false,"x":225,"y":343,"wires":[["3932896a.d2c79e"]]},{"id":"2f7a52b.3711fae","type":"inject","z":"592dfe9c.b58ce","name":"turn on 4","topic":"on","payload":"4","payloadType":"num","repeat":"","crontab":"","once":false,"x":226,"y":313,"wires":[["3932896a.d2c79e"]]},{"id":"207f33a3.0979d4","type":"inject","z":"592dfe9c.b58ce","name":"turn on ALL","topic":"all on","payload":"","payloadType":"num","repeat":"","crontab":"","once":false,"x":270,"y":403,"wires":[["3932896a.d2c79e"]]},{"id":"bde188c1.c1685","type":"inject","z":"592dfe9c.b58ce","name":"turn off ALL","topic":"all off","payload":"","payloadType":"num","repeat":"","crontab":"","once":false,"x":283,"y":436,"wires":[["3932896a.d2c79e"]]}]

Flow Info

Created 6 years, 11 months ago
Updated 4 years, 4 months ago
Rating: 5 1

Owner

Actions

Rate:

Node Types

Core
  • debug (x1)
  • function (x1)
  • inject (x10)
Other

Tags

  • i2c
  • relay
  • raspberry
Copy this flow JSON to your clipboard and then import into Node-RED using the Import From > Clipboard (Ctrl-I) menu option