Tweet to turn on LED in Arduino via MQTT

Example flow where you can tweet a primary, secondary, or white color and the Arduino will turn on the color using a RGB led. The Arduino can also tweet via button press.

[{"id":"a36eecac.af905","type":"twitter in","z":"3d42f9b2.cb8456","twitter":"","tags":"electronhacks,Electronhacks","user":"false","name":"Direct","topic":"tweets","inputs":0,"x":186.7840347290039,"y":102.80112361907959,"wires":[["bacc6879.8f34b8","1912a8f2.5c4c67"]]},{"id":"bacc6879.8f34b8","type":"debug","z":"3d42f9b2.cb8456","name":"","active":true,"console":"false","complete":"false","x":699.7812271118164,"y":108.87783718109131,"wires":[]},{"id":"1912a8f2.5c4c67","type":"function","z":"3d42f9b2.cb8456","name":"Check for Keywords","func":"message = msg.payload\nif (message.toLocaleLowerCase().includes(\"red\"))  \n{\n    return {topic:'Arduino',payload:'Red'}; \n}\nif (message.toLocaleLowerCase().includes(\"green\"))  \n{\n    return {topic:'Arduino',payload:'Green'}; \n}\nif (message.toLocaleLowerCase().includes(\"blue\"))  \n{\n    return {topic:'Arduino',payload:'Blue'}; \n}\nif (message.toLocaleLowerCase().includes(\"white\"))  \n{\n    return {topic:'Arduino',payload:'White'}; \n}\nif (message.toLocaleLowerCase().includes(\"yellow\"))  \n{\n    return {topic:'Arduino',payload:'Yellow'}; \n}\nif (message.toLocaleLowerCase().includes(\"cyan\"))  \n{\n    return {topic:'Arduino',payload:'Cyan'}; \n}\nif (message.toLocaleLowerCase().includes(\"magenta\"))  \n{\n    return {topic:'Arduino',payload:'Magenta'}; \n}\n","outputs":1,"noerr":0,"x":471.78688049316406,"y":183.73862552642822,"wires":[["bacc6879.8f34b8","4d1f9ea2.cdd55"]]},{"id":"4d1f9ea2.cdd55","type":"mqtt out","z":"3d42f9b2.cb8456","name":"","topic":"","qos":"0","retain":"false","broker":"c3f1643d.d91608","x":758.7840194702148,"y":189.1221466064453,"wires":[]},{"id":"79211b62.a0c484","type":"twitter out","z":"3d42f9b2.cb8456","twitter":"","name":"Tweet","x":733.7840538024902,"y":280.14198303222656,"wires":[]},{"id":"50d22dce.038c54","type":"mqtt in","z":"3d42f9b2.cb8456","name":"","topic":"Arduino/Out","qos":"0","broker":"c3f1643d.d91608","x":246.78125,"y":277.9175796508789,"wires":[["79211b62.a0c484"]]},{"id":"c3f1643d.d91608","type":"mqtt-broker","z":"","broker":"localhost","port":"1883","clientid":"NodeRedPing","usetls":false,"compatmode":true,"keepalive":"15","cleansession":true,"willTopic":"","willQos":"0","willPayload":"","birthTopic":"","birthQos":"0","birthPayload":""}]
ElectronHacks

Flow Info

created 4 months, 3 weeks ago

Node Types

Core
  • debug (x1)
  • function (x1)
  • mqtt in (x1)
  • mqtt out (x1)
  • mqtt-broker (x1)
  • twitter in (x1)
  • twitter out (x1)

Tags

  • Arduino
  • twitter
  • tweet
  • LED
Copy this flow JSON to your clipboard and then import into Node-RED using the Import From > Clipboard (Ctrl-I) menu option