Node-RED
Node-RED

Using Node-Red to send commands to Wifi LED Controllers


After buying a new Raspberry Pi 3, I noticed it came with an interesting app called Node-Red. Already familiar with Node.JS, I thought it was going to be some cheesy simplification that was going to severely limit what it could do for beginners. To my amazement, it wasn’t.

Node-Red is a tool designed for IoT to get you past configuring serial ports and oAuth and into actually using the data your sensors produces. It is a web app that runs on the device through node and from any web browser gives you a quick interface to design the automations you want.Node-Red controlling Wifi LED controller

 

WIFI LED Controllers

I bought my Wifi LED Controller from Amazon for $18 with prime shipping. To be fair, most of the LED controllers out there are really made by a single factory in China (http://zengge.com/), so there isn’t much difference between them. That being said, I ran into issues with older protocols not working on the newer ones. One way you can tell is by the number of channels it supports, if it is RGB only, then it is probably the “2014 protocol”. If it is RGB + WW + CW then it is probably the protocol shown on this blog.

XCSOURCE DC 12-24V iOS Android WIFI Remote 5 Channels Controller for RGB LED Strip LD686 – $18 (PRIME)

Magic House App – http://www.ledmagical.com/Apps/MgcHome/AppDown.aspx

Code

In Node-Red, you can go to the top right settings menu and click Import and then Clipboard. Paste in the following:

[{"id":"d9ffe9ba.e5dea8","type":"inject","z":"e602a429.19fd58","name":"Turn On","topic":"","payload":"true","payloadType":"bool","repeat":"","crontab":"","once":false,"x":299,"y":97,"wires":[["92d823b8.e9969"]]},{"id":"c678b7b7.ddaa08","type":"tcp out","z":"e602a429.19fd58","host":"192.168.0.102","port":"5577","beserver":"client","base64":false,"end":true,"name":"","x":939,"y":208,"wires":[]},{"id":"92d823b8.e9969","type":"function","z":"e602a429.19fd58","name":"on","func":"msg.payload = new Buffer([0x71,0x23,0x0F,0xA3]);\nreturn msg;","outputs":1,"noerr":0,"x":530,"y":99,"wires":[["c678b7b7.ddaa08"]]},{"id":"64d0bd5a.368424","type":"inject","z":"e602a429.19fd58","name":"Turn Off","topic":"","payload":"false","payloadType":"bool","repeat":"","crontab":"","once":false,"x":299,"y":146,"wires":[["c6e3a3e0.b412a"]]},{"id":"c6e3a3e0.b412a","type":"function","z":"e602a429.19fd58","name":"off","func":"msg.payload = new Buffer([0x71,0x24,0x0F,0xA4]);\nreturn msg;","outputs":1,"noerr":0,"x":531.5,"y":146,"wires":[["c678b7b7.ddaa08"]]},{"id":"6a8ff1ba.c3d23","type":"function","z":"e602a429.19fd58","name":"RGB(0, 0, 7)","func":"msg.payload = new Buffer([0x31,0x00,0x00,0x07,0x00,0x00,0xF0,0x0F,0x37]);\nreturn msg;","outputs":1,"noerr":0,"x":522,"y":240,"wires":[["c678b7b7.ddaa08"]]},{"id":"fe8375b6.b7a498","type":"inject","z":"e602a429.19fd58","name":"Everyday 7AM","topic":"","payload":"false","payloadType":"bool","repeat":"","crontab":"00 12 * * *","once":false,"x":302.5,"y":329,"wires":[["cf8bb876.357ba8"]]},{"id":"cf8bb876.357ba8","type":"function","z":"e602a429.19fd58","name":"RGB(100, 100, 100)","func":"msg.payload = new Buffer([0x31,0xFF,0xFF,0xFF,0x00,0x00,0xF0,0x0F,0x2D]);\nreturn msg;","outputs":1,"noerr":0,"x":541,"y":344,"wires":[["c678b7b7.ddaa08"]]},{"id":"b3fedaec.342ab8","type":"inject","z":"e602a429.19fd58","name":"Everyday 8PM","topic":"","payload":"true","payloadType":"bool","repeat":"","crontab":"00 1 * * *","once":false,"x":307.5,"y":227,"wires":[["6a8ff1ba.c3d23"]]},{"id":"cc5e9938.d64978","type":"inject","z":"e602a429.19fd58","name":"Everyday 9AM","topic":"","payload":"true","payloadType":"bool","repeat":"","crontab":"00 14 * * *","once":false,"x":307,"y":266,"wires":[["6a8ff1ba.c3d23"]]},{"id":"7f9300a3.50f15","type":"inject","z":"e602a429.19fd58","name":"Everyday 5PM","topic":"","payload":"false","payloadType":"bool","repeat":"","crontab":"00 22 * * *","once":false,"x":305,"y":373,"wires":[["cf8bb876.357ba8"]]}]

You will need to update the IP address of the unit to match your wifi controller but beyond that, you should be able to start clicking on inject buttons and seeing the lights react.

(I’m running my app on a Raspberry Pi that is in UTC timezone, so all the hours are slightly shifted +5, incase you are wondering why 7AM is entered as 12:00)

Commands

All commands are sent at a TCP packet to port 5577, you need no handshake or authorization to do this.

<command group> …modifiers… <checksum>

Power On = 0x71 0x23 0x0F 0xA4
Power Off = 0x71 0x24 0x0F 0xA3
Set Color = 0x31 RED GREEN BLUE WW CW TRUE FALSE CHECKSUM
Set Blue 7% = 0x31 0x00 0x00 0x07 0x0 0x0 0xFO 0xOF 0x37

Checksum is calculated by adding up all the bits then AND masking it with 0xFF

Command Groups

SetColor = 0x31
SetMode = 0x61
SetPower  = 0x71

Constants

TRUE = 0xF0
FALSE = 0x0F
ON = 0x23
OFF = 0x24

 


I'm a 29 year old UIUC Computer Engineer building mobile apps, websites and hardware integrations with an interest in 3D printing, biotechnology and Arduinos.

View Comments