NodeRed, Arduino and NeoPixels

818 views
Skip to first unread message

Neil Ford

unread,
Feb 21, 2015, 7:21:10 AM2/21/15
to node...@googlegroups.com
I'd like to be able to drive some NeoPixels from NodeRed using an Arduino.

I've found the following modified Firmata library that is designed to work with Node/Johnny-Five: https://github.com/ajfisher/node-pixel

Now, I can get the modified library loaded on to an Arduino, but I'm wondering how I go about sending the appropriate commands to it from NodeRed. Any pointers would be gratefully received.

Neil.

ryan...@gmail.com

unread,
Feb 21, 2015, 8:25:49 AM2/21/15
to node...@googlegroups.com
Hi Neil,

Can't help with your specific scenario but just to give you an alternative approach: I use this Arduino lib for controlling the WS2812B strip: https://github.com/pololu/pololu-led-strip-arduino

The arduino has an ethernet shield and also runs MQTT/JSON parsing libs, giving a nice easy interface from Node Red or other sources.

Ryan. 

Julian Knight

unread,
Feb 22, 2015, 3:25:05 PM2/22/15
to node...@googlegroups.com
As I understand it, you simply send the commands over the serial port so you need a master device connected to the Arduino via serial. This can be via USB, software serial or via one of the radio modules that use serial such as the excellent (if somewhat confusing) Ciesco SRF modules that I'm trying to use - if they will ever stop getting distracted and actually verify my forum request.

Andrew Jawitz

unread,
Mar 1, 2015, 10:32:58 AM3/1/15
to node...@googlegroups.com
I have been looking for the exact same capability as I'll be using a Neopixel ring as one component in a larger NodeRED-based automation project outlined in this thread- https://groups.google.com/forum/#!topic/node-red/OM12VwAAFAI
 Thus far I have been using a sketch based on the following code-https://github.com/sourceperl/arduino.yun.ikea-fado to trigger an Arduino Yun via MQTT.  The problem is the sketch only really allows for basic, solid color changes and falls far short of what could be accomplished with individually addressable RGB-LEDs...

Nathanaël Lécaudé

unread,
Mar 1, 2015, 11:30:52 AM3/1/15
to node...@googlegroups.com
I think the most efficient way to do it would be to use the Serial node and send data as binary (using the Buffer object in a function)

That way you could setup the Arduino code to either read a full frame of data at once or set it to send a LED ID and the corresponding color.

Let's pretend you have 3 LEDs.  Sending a full frame from Node-Red would imply creating a buffer:

new Buffer([255, 255, 255, 255, 0, 0, 0, 0, 255]);

In the above example the first led would be white, the second red and the last blue.

For the second option you would send an ID and the led coordinates:

new Buffer([33, 255, 255, 255]);

Led 33 would light up white.

On the arduino side you would need to look at the Serial.readBytes method.

Dave C-J

unread,
Mar 1, 2015, 1:16:11 PM3/1/15
to node...@googlegroups.com
I agree with Nat :-)
I implemented the second of his suggestions a while back for a simple project. Just using a function block to create thre binary buffer and feed it to the serial port.
The advantage of that way is that you only ever send 4 bytes so easy to buffer and parse at the arduino end. If you have a low number of pixels then it is easy enough to create a large enough buffer - but once it gets large it can get fun to manage. 

Nathanaël Lécaudé

unread,
Mar 1, 2015, 1:25:57 PM3/1/15
to node...@googlegroups.com
Here's some code that demonstrates solution #1:

It uses the OctoWS2811 library for Teensy but should be easily portable to NeoPixel as it's almost the same function calls.

Dave C-J

unread,
Mar 1, 2015, 1:39:02 PM3/1/15
to node...@googlegroups.com
Likewise... here is mine fro the Arduino
expects serial at 57600.
Pixels attached to pin 4
flashes led on pin 13 when data arrives.
as per suggestion - expects   "N",{pixel id},{red},{green},{blue}
so 5 bytes starting with N


Andrew Jawitz

unread,
Mar 9, 2015, 6:53:29 PM3/9/15
to node...@googlegroups.com
I just discovered the fantastic FastLED library (formerly FastSPI) which significantly simplifies control for a wide variety of LED Strips, including Neopixel.  I'm currently trying to reconcile it with the MQTT/YUN code I've been working from at https://github.com/sourceperl/arduino.yun.ikea-fado as I have yet to find any good examples of using FastLED with MQTT.  However, there have been a few posts about using the library with MQTT for the ESP8266 (which I might have to try once it catches on more) on the FastLED users group on Google+  https://plus.google.com/communities/109127054924227823508


On Saturday, 21 February 2015 07:21:10 UTC-5, Neil Ford wrote:

Marko S

unread,
Mar 15, 2016, 4:31:08 AM3/15/16
to Node-RED
Andrew now that FastLED work on ESP8266 would your code work there too or is there something specific to the  Yun coded there?

Dne ponedeljek, 09. marec 2015 23.53.29 UTC+1 je oseba Andrew Jawitz napisala:
Reply all
Reply to author
Forward
0 new messages