MessageTorch - torch fire animation with WS2812 leds + message display


#1

MessageTorch

A small fun project using a WS2812 color LED strip and a spark.io core WiFi+Cloud enabled prototyping board.

[Update: now also works as a cheerlights client, thanks to code shared by ls6 on github. The background lights up in the cheerlights color when it is changed, and fades back to black over time. Set “cheer_brightness” param to zero to disable."]

(tldr; source is on github.com/plan44/messagetorch)

End of last year, at the incredibly great 30C3 chaos communication congress in Hamburg, I learnt of the existence of WS2812 LED chips. Shame on me I wasn’t aware of them before. These are RGB LEDs with a built-in controller which allows chaining hundreds of them and controlling each LED individually via a single output pin of a microcontroller, at a speed suitable for complex animations.

At 30C3, there were many many WS2812 based and very colorful light installations, but the one that fascinated me most was a rather small and nearly monochrome one. It was a LED strip with some 200 WS2812, wound onto a tube of approximately 7cm diameter and maybe 70cm height. The tube stood vertically on a desk and showed an animation that made the tube look like a torch on fire. The fascinating thing was that it really created a feeling of fire, despite the very limited resolution (after all, it had only 200 “pixels” around the tube, so what you could see at once were probably less 100 LEDs). But the effect was really stunning.

Luckily, the creator of the torch was explaining how the did the calculations for the animation just the moment I passed by. Not in great detail, but I got the basic idea which later, back at home, transformed to my version - the “MessageTorch”.

I would very much like to give him credit for this awesome idea - if I only knew his name. I tried to find out afterwards but without success so far (hints welcome, if anyone saw it too and knows who is the creator, please let me know).

Anyway, back at home I ordered some WS2812 led strips (4m ones with 240 chips each). And nearly the same day the strips were delivered, the Kickstarter reward from the awesome spark.io “spark core” project also arrived.

So the formula was: Idea from Blinkenlights@30c3 + spark.core + WS2812 strip -> do something with that!

Driving WS2812 chains

First step was to get the WS2812 serial protocol generated by the spark core. The timing must be quite accurate (only 150nS tolerance). By now there are several libraries for that on github, but before I found those I had written my own, partly out of the challenge to figure it out myself, using SPI for generating the timing.

Wiring + Power

Wiring the WS2812 LED strips to the spark.core is super simple: the strip has three wires, ground, 5V and data. Ground goes to GND of spark.core, 5V to VIN and data to A5 (SPI MOSI):

This works fine with a ordinary 5V/1A USB power supply with one big caveat: don’t try to switch on all LEDs at full brightness. A 240 LED WS2812 chain, all LEDs set to bright white, would consume around 14Amps (70 Watts!). A small USB power supply will simply collapse when connected to such a load, usually by overload protection switching it off, but really cheap ones might simply die. Having said that - for the MessageTorch that simple 5V/1A is sufficient, as only few LEDs are actually on together at a given time.

Torch simulation

I tried to code what the original creator of the torch explained. Each pixel has an amount of “energy”. Pixels dissipate their energy up and sidewards to neighbour pixels. A very “hot” pixel will show in white/blue, cooler ones in yellow down to dim red. In the bottom row, pixels receive a random amount of “energy” in every cycle. In addition, some special spark pixels (which keep their energy while moving up) are randomly generated in the second row. There’s lot of room for improvement, of course…

Via the Cloud - Message display

Now once this worked, there was the cloud API of the spark to do something with. So I added the message display part. Any text message sent to the torch via the spark API is rendered in a good old 5x7 pixel font I found hex code for somewhere in the depths of my old projects. The message first shows bright blue, and then fades with every repetition.

The MessageTorch is standing near our coffee table in the office, so I hacked a website so everyone can send us a message. Around 10AM CET chances are good messages are seen…

For your own spark cores, of which you have the device ID and access token, the message can be sent directly:

curl https://api.spark.io/v1/devices/xxxxxxx/message -d access_token=tttt -d “args=Hello Spark”

Parameters

The development cycle on the spark core via the web IDE is rather slow, as every update apparently re-flashes not only the user code, but the entire firmware. So to play with the animations, colors etc. I added a lot of parameters that can be set via the cloud API:

curl https://api.spark.io/v1/devices/xxxxxxx/params -d access_token=tttt -d “args=mode=2,brightness=255”

To see what parameters are supported, check out the handleParams() function around line 465 of the code.

Finally - integration into digitalSTROM home automation

As my current work is an open source project for integrating third-party devices into the digitalSTROM home automation system, our office lighting is fully automated. Coffee table lights (colored LEDs, of course) go on when the coffee machine is switched on etc.

So of course I also wanted the MessageTorch to be part of that, and that’s what the third cloud API called “vdsd” is about. That means “virtual digitalstrom device” and it interfaces to the “vdcd” software component which then includes the MessageTorch as a dimmable lamp into the system.

Adapting to your LED chain and tube diameter

There are two constants in the source at the top, “ledsPerLevel” and “levels”. “ledsPerLevel” must be set to the number of LEDs in one winding of the LED chain around (or in my case, inside the plexiglass) tube. “levels” must be the number of windings. Of course “ledsPerLevel” times “levels” must not exceed the total number of LEDs in the chain.

Source

is on github.com/plan44/messagetorch


Can you change how many web functions / variables you can register?
Twitter Torch - Twitter messages in a glass tube
Everything in the Particle booth at Maker Faire 2015!
Adafruit Neopixel Library [PORTED]
Halloween Blinky Eyes
#2

@luz Dude this is EPIC!!! Rad project man… I :blue_heart: it!


#3

Agreed, this is awesome!


#4

@luz are you kidding me!!! This is awesome.!!!


#5

Hi Luz - very cool. What diameter of acrylic tube did you use? Looks about 100mm.

Txs


#6

Thanks :slight_smile:

The inner diameter is 73mm, outer is 80mm.

The mechanical side of the project is still very rough, just that piece of tube I had lying around. I’d like to put the tube on a nice wooden base, and maybe add a acrylic cap on to of the tube. Another idea is to include a small bell/ringer, which would go “ping” whenever a new message arrives…


#7

Thanks for the message today around 10 o whoever sent it - we’ve seen it while drinking coffee :slight_smile:


#8

Thanks @luz for the library!

Did a simple hook up for 1 x 8 WS2812 Strip i bought from rgb123.com :smile:

https://vine.co/v/MZF3FFJiPBj


#9

Thats a great project, I like it very much, thanks for sharing :slight_smile:


#10

Cool to see it working on someone else’s desk :slight_smile: Thanks for sharing the video!


#11

Current spark.core firmware does not allow to run the app with more than about 130 LEDs, so I reduced the number of rows (with one row having 13 LEDs as before) to 10 from 18 as a hotfix.

I hope I’ll be able to figure out why messageTorch, requiring only about 1k of RAM, exhausts the 20KB RAM on the core. They increased some UDP buffers in the firmware, but still 19k of RAM just for the firmware seems like a lot to me.


#12

@luz You could use a Teensy board to control the ledstrip, and the Spark Core for internet accessibility. http://www.pjrc.com/teensy/td_libs_OctoWS2811.html

(i have no affiliation to the above site)

Also there’s a library for the WS2811 and source code for the project on the page that might be useful.

I’m waiting to get my cores to start playing with this kind of project.
By the way, awesome project, i’m loving it.


#13

the OctoWS2811 lib is an ultra clever design, but does not help for a single LED strip as I use in MessageTorch. OctoWS is efficient only when one needs to drive 8 strips in parallel. For a single strip, it would need 8 times the RAM than my WS2811 lib does.


#14

Firstly, thank you very much @luz for sharing your project. It’s so pretty and inspiring that I believe many of us didn’t mind spending a little bit more on LEDs for the sake of this project.

Apart from the issue of not able to make use of all the LEDs due to memory limitation with the current version of spark core, am I the only person struggling to curl the LED strip into the cylinder…? Is there a trick to it? I think I have already spent about 2 to 3 hours trying to secure it properly! :stuck_out_tongue:


#15

It probably depends on the type of LED strip you have.

Mine (the product I linked to in the original post) was enclosed in a transparent silicone rectangular “tube” for water protection, which gives it a slightly rubbery surface. Putting that kind LED strip into the acrylic tube was easy. I just wound it onto a support paper tube (a rolled up A3 sheet) with the diameter such that I could just slide it into the acrylic tube. Then, I taped one end of the strip to the acrylic tube, and by turning the paper tube, the LED strip winding got a bit wider and laid itself nicely to the inner wall of the acrylic tube. I pulled out the paper and taped the other end of the strip.

I can imagine that this would not work with bare WS2812 strips.


#16

That make sense @luz! My strip do not have a rubbery surface. So I have to resort to the less attractive option of using sticky tape. :stuck_out_tongue: I managed to get all the LED to lit up by removing the cheerlight section of the code. Thank you again for sharing this aesthetic demonstration of LEDs! :slight_smile:


#17

First of all, very awesome build!

I gave your code a try, and had it working with a 1m (60 LED) strip, 10 led diameter, 6 rows. (unfortunately, all I have at the moment).

The “torch” mode looks great, though it’s too short to really display text messages properly.

My only problem is that when I try to send a text message to it, my :spark: crashes and resets itself. I didn’t have time to dig deeper to see why (memory limitation as @timolol mentioned?), and at the moment, I’ve got my spark and LED strip reconfigured back as a motion sensor. But I kept the cylindrical setup, using a clear plastic water bottle.

Since my motion sensor doesn’t really need all the power of a :spark:, I might replace it with a DigiSpark at some point.


#18

@luz, you explained that you use a roll of paper to get the strip inside the tube:

I got the strip wound on a piece of rolled paper, stuck it in but when I try and roll the paper to “unfurl” the strip I find the strip won’t properly lay itself out because it is too sticky and I loose the vertical alignment of pixels which I believe is necessary for a good looking effect. Any suggestions?


#19

@peekay123 Actually, my pixels don’t align exactly as well. But I found that this it even looks more natural than if the columns were completely vertical - the “sparks” get a slightly diagonal movement, as you can see in the animated gif. Same for the text, it gets a slightly “italic” look which is quite nice. You might need to adjust the ledsPerLevel constant in line 365 to make it look right.

As for the mechanical challenge to get the strip inside a tube, I guess I was just lucky with the combination of strip and tube I had, which made it really easy, without giving it a second thought. With a more difficult strip/tube, I’d probably try to use bits of double-sided, transparent sticky tape on some of the LEDs to fix the strip at more points than just the beginning and end. But I have no idea how doable this actually is.


#20

@luz, I agree with a little horizontal shift between rows it looks great and I get this when I wrap the strip OUTSIDE the tube. But wrapping it inside the tube seems to be eluding me. I may try spraying some water on the strip to see if it makes it more slippery and easy to unfurl inside the tube. If I can’t get it done, I will just wrap the strip outside the tube - not as pretty but it will work!

I forgot to mention that this is a fantastic project and I will be taking it to the Maker Faire for display! We are working on being able to control aspects of the torch with a pebble watch (like setting mode, colors, send message). I also have the twitter magnet sending tweets as text to the torch so hopefully it will attract a lot of attention. :smiley: