Crystal Light Page


Home                               Craigs Pages                               Heathers Pages

July 2023

Heather and I spent a week in Buena Vista recently and visited a rock shop in Nathrop, Colorado, called The Rock Doc. This is a very nice store with lots of things to see and buy. While there, I saw a crystal display stand that changed colors that I thought was cool but the $100 price tag (which, to be fair, included a beautiful large extremely clear quartz crystal) was a bit much. In thinking about this during the remainder of our vacation I decided that I would make one when I get home instead of buying the one at the shop. I thought to myself, how hard can it be?

The Electronic Hardware
At home I went into my parts stash and pulled out a single NeoPixel and an ESP8266 micro-controller. Overkill you think? That was OK because with the power of the ESP8266 and its WiFi capabilities I could make a crystal stand with greater functionality. I also decided I would power the light with USB power instead of using batteries since it would be easier.

The Case Design
With the hardware sorted the next step was the physical base itself. So I opened up OpenSCAD and designed a base for 3D printing. I printed the base with black PETG and it turned out great.
Since I wasn't sure where the USB connector on the ESP8266 would line up with the base I didn't put a cutout for it in my design. Instead, when I figured out where the hole should be, I used a drill and a file to make the cutout for the USB cable to attach to the ESP8266.

The crystal display stand I saw in the shop had a mirror for the top and I wanted that as well but couldn't find any 3" circular mirrors with a half inch whole in the center. I thought I was being clever when I purchased some thin acrylic mirror material that I would cut to shape using my diode laser cutter. This was an absolute failure; so much for my clever idea. I could not seem to cut the thin acrylic no matter how much power or how many passes I used. The mirror material would melt and then just harden again. Maybe if I had painted the mirror back black it might have worked but I quickly gave up on that idea and decided instead to cut the top out of thin 1/8" wood that I had on hand. I knew my laser cutter could cut this stuff. With the two pieces of the base finished, I hot glued them together.

Assembly
Inside the base, I hot glued the ESP8266 and the single NeoPixel in and then wired them together. The wiring could not be simpler. I connected the +5v pin of the ESP8266 to the Vcc pin on the NeoPixel. The Gnd pin to the Gnd pin on the NeoPixel and the D4 pin on the ESP8266 to DIn pin of the NeoPixel. Done. Next up, software.

Software
Not satisfied with just a static pattern of changing colors (like the light I saw in the shop), I decided to up the game a bit by making the crystal light controllable over the net. I had bits and piece of code from other "blinky" projects I have done that I brought together for this project. I decided the crystal light should provide a web page for its control. So initially I integrated a web server with a web socket interface to the FastLED library for controlling the NeoPixel. The code was developed using the Arduino IDE version 2.1.0. The web page is shown in the final image below.

I was really proud of myself as the software came together quickly in an afternoon. As you can see on the web page it is possible to turn the  light off and on, to select either a swepted mode where the colors change gradually or a stepped mode where the colors jump from one solid color to the next, to change the direction that the color hues change with up being where the hues go from red across the spectrum to pink and then repeat or up and down where the hue go from red to pink and then back down from pink to red, and finally the ability to change the speed of the color changes.

The Problem
During my testing I came upon a strange issue that I couldn't and still don't understand. The swepted mode worked perfectly sweeping the colors back and forth across the visible spectrum with every color represented, every time. The stepped mode, however, would only step through the colors once and on every subsequent iteration of the pattern the blue portion of the NeoPixel would never come on. This, of course, messed up any of the colors that had a blue component. I struggled with problem for a couple of days placing debugging statements where I could to try and find my error but I eventually came to the conclusion that my code was correct and what I was seeing was some kind of interaction between FastLED and the async web server code. I even filed a issue the FastLED on this but have yet to hear back.

With my frustration mounting I decided to pull out the FastLED library and integrate the Adafruit NeoPixel library instead. After an hour or so, the crystal light was working perfectly. I will say, however, I would rather use the FastLED library in the crystal light because of how they implemented the HSV color space. The FastLED library stretches the color spectrum to make yellow more prominent and they also scale the colors for equal brightness across the spectrum which I believe is more pleasing to the eye. If I ever get the FastLED library issue fixed I will probably integrate it back into the crystal light.


Picture
Description

Here is the finished base with a quartz crystal. The USB cable plugged into the side powers the light.

After laser cutting the top wooden piece and gluing it onto the 3D printed base, I oiled it which brought out the grain nicely.

Here you can see how the single NeoPixel can really light up the crystal.

Since the colors sweep across the visible spectrum you get lots of gorgeous colors which interact with the crystal's geometry in pleasing ways.

The red really pops!


This is the web page interface for the crystal light. This is accessed by entering the IP address of the crystal light into your browser. You may need to consult your WiFi router to determine the IP address of the light. In my case the IP address was:
192.168.0.28
Yours will probably be different.

The Arduino software and design files for the crystal light are available here.

 
Questions and comments to me Craig at: calhjh@gmail.com


Home                               Craigs Pages                               Heathers Pages