Christmas star with Wi-Fi based on ESP8266

For many years I tried to make an unusual star on a New Year tree. The first option was a star with UV LEDs. They just shone without any chips. The second version of the star was with LED strip. Again, nothing interesting - just a static glow. There were ideas to finish the modes, but there was no time.

I decided to prepare for the celebration of 2015 in advance, starting the development of a new star a month before the new year. I just received the first batch of new penny ($ 3) SoC ESP8266. If you are interested in what came of it, I ask for a cat.

ESP8266 is a fairly new platform, but there are already several articles on this topic on Habré and Giktimes, for example: “ESP8266: Revolution in the World of the Internet of Things” and “Working with ESP8266: Build the Compiler and Write the First Firmware”.

The last link is a small how-to on setting up the environment for creating firmware for ESP8266.

First, I decided what I want to get from the device.
The main requirements were:
1. The ability to turn on / off the whole tree through the HTTP protocol;
2. Ability to set the color of each ray of the star via the HTTP protocol;
3. The presence of various "ready" modes for the star.

To highlight the rays of the star, I decided to use a pixel garland on the LPD6803 chip (I just already had it).

I had two options for creating the device.

The first option is to use the ESP8266 bundle with AT firmware and Arduino Pro Mini. In this case, I would only need to register the logic of work: all libraries under Arduino already exist. And voltage regulators on board the Arduino Pro Mini are already available. But this is uninteresting ...

So I went the second way - using only ESP8266 without Arduino.
I had available ESP8266 modification 01 (the most popular). Here is one:

This modification has two output GPIO ports, plus the ports UART_RX and UART_TX can be put into GPIO mode. For my craft, three GPIO ports are required: DATA and CLK for LPD6803 and a port for controlling the on / off relay of the whole tree.

For programming the ESP8266, I decided to use a USB-UART converter based on the PL2303 chip (which is easy to buy on ebay or aliexpress for a couple of dollars). This converter has four pins: + 5V, GND, RX, TX. The problem is that the ESP8266 runs on 3.3V and is not tolerant of 5V. For this reason (and just for convenience) I decided to do something similar to the development board for ESP8266:

This board lowers the voltage to 3.3V using the LM317 regulator, has pins for outputting GPIO, UART, GND, 3.3V, 5V and DIP -switches to put the ESP8266 into firmware mode (GPIO0 to GND, GPIO2 to 3.3V).

Now a little about implementation. The main part of the entire project is the driver for the LPD6803. I ported it from the Arduino library AdaFruit. I will not talk about the principles of operation of the LPD6803 in this article, because material pulls another article.

For those interested I will give some useful links:

- Datasheet
- My code for ESP8266 is on

In my implementation, GPIO0 is used to connect to DATA LPD6803, and GPIO2 to CLK. For the relay, I needed to get another GPIO output. There was no desire to use dirty hacks , so I just reassigned UART_RX to GPIO (all the same, my firmware does not support any input from the user). This line of code translates UART_RX to GPIO3:


As a web server, I used code from a friend Sprite_tm. This web server, as far as I know, is used in almost all amateur projects on the ESP8266. The functionality of connecting the device to the home network is already included in this web server. By default, the device works as an access point. After connecting to this access point, the user can enter the browser at . On this page, he will be able to select the desired network to connect (if necessary, you can select a hidden network and specify a password). All web server responses can be received in JSON format, which is very convenient for integration into various systems and applications.

As for the software part, there is nothing more to tell me, the firmware code is available on .

Now a little about the iron implementation. Let's start with the body. For him, I chose an old star in which glow plugs once stood. The case looks like this:

I was lucky, because RGB LEDs with LPD6803 chips ideally fit into the clips for incandescent lamps:

I decided to place the ESP8266 module directly in the star, because The quality of the Wi-Fi signal at the top of the tree will be better than under it.

Under the Christmas tree, I installed a 12V power supply and a homemade board of this kind:

As you can see, there are two voltage regulators on it, which give out 5V and 3.3V. 5 volts is used by LPD6803, and 3.3 volts, as already mentioned above, eats ESP8266. In addition to the regulators, a 12V relay is located on the board. Twitches through a transistor. From the box under the tree to the star there is a 4-wire cable: 3.3V, 5V, GND and a relay control channel.

At the moment, there is a problem with this star related to a bug in the TCP \ IP wrapper of the ESP8266 stack.
To solve this problem, you need to switch to the direct use of lwip without a wrapper.

The project development plans have two things:
1. Implement work through the MQTT protocol;
2. Make a star friends with OpenHab .

And finally, the video work. An Android application is used for control (raw, so I don’t post the source code). Voiced by his wife:

Also popular now: