ESP8266 web server for Neopixel LED strips [160487]
Control your WS2812 RGB LED strip via an ESP8266 WiFi access point.
This project controls an LED strip with WS2812 RGB Neopixels via WiFi. An ESP-01 (containing the well-known ESP8266) sets up a WiFi access point, log in with your smartphone or other mobile device and select up to 44 light effects and five levels of intensity of the LEDs on the ESP’s webpage.
Hardware
The schematic shows that the hardware isn’t too complicated. The ESP8266-based ESP-01 module (MOD1) does all the work, but of course it needs some additional stuff to do the trick.
First of all the power supply: a 5V, 2A power supply can be connected to K1. D1 serves as crowbar, protecting the circuit by blowing fuse F1 if the polarity of the supply voltage is wrong. WS2812B Neopixel LEDs will consume about 60mA each at full intensity, so a 2A power supply will suffice for about 33 of these LEDs. If you need more power (i.e. more LEDs), a heavier power supply can be connected to K3 instead of K2. In that case, don’t forget to change F1 to a suitable higher current rating (i.e. just below the maximum current of the power supply).
Alternatively, instead of using K1 or K3, when you only need power for programming and/or debugging the ESP8266, power can be supplied via a 3.3V FTDI cable connected to K4 with jumper JP2 closed. Please note that this 5V connection at pin 3 can not source more than 50mA, so disconnect K2 (i.e. the LEDs) when you use K4 to power the circuit! And equally important: remove the FTDI-cable or JP2 before you connect a power supply to K1 or K3!
Jumper JP1 must be closed on power up when you are going to program the ESP-module, don’t forget to remove it after programming. If JP1 is closed on power up, the ESP8266 will start in programming mode and your application will not run.
Low-drop voltage regulator IC1 is used for the 3.3V supply voltage of the ESP8266, LED1 will light when this voltage is present.
T1 serves as voltage level shifter, translating the 3.3V output signal of the ESP to 5V input voltage level for data of the WS2812 Neopixel LED strip connected to K2. Although this level shifter is bi-directional, the signal in this case is output only (i.e. 3.3V -> 5V).
Level shifter issues
In the original design a 2N7002 was used, with 10k pull-up resistors at the 5V and 3V3 side. This proved to be a poor solution, with the 800kHz square wave of the Neopixel data signal the voltage level at the drain of the FET hardly reaching the 3.5V level needed for the Neopixel LEDs to detect a logic high level, let alone the 5V we would (like to) expect there. Apparently the cut-off voltage of these FETs (2.5V max.) is too high for this application, a BSS138 with a 1.5V threshold does a much better (although still not perfect!) job.
Software
Our software download package contains the Arduino 'portable' folder for this project (see https://www.arduino.cc/en/Guide/PortableIDE for more infromation on the Arduino portable IDE). To cut the size of this download, we did NOT include the Arduino ESP8266 boards addon, please refer to https://github.com/esp8266/Arduino if you need help with the installation of this addon.
The Arduino sketch for this project uses (amongst others) the WS2812 library, which also contains the 44 light effects that can be selected for the LED strip.
The length of the strip (i.e. the number of LEDs) can be entered in line 44 of the sketch:
#define LED_COUNT 180
The sketch will still work if this constant doesn’t match the LED strip you have, but if it contains more LEDs than LED_COUNT, the remaining LEDs will not light. Or if the LED strip is shorter than LED_COUNT, the light effect may be spoiled because part of the animation is lost.
The name access point of the ESP and its password can be changed in lines 27 and 28 of the sketch:
const char *ssid = “Neopixel Elektor”
const char *password = “Tours2017”
For French-speaking readers: there is also a French version of the ESP’s webpage available. To select this, just change the constant LANGUAGE in line 25 from ‘1’ to ‘0’ before you compile and upload the sketch.
Compiler errors
We had some issues compiling the source code of this project after a fresh install of the Arduino IDE and its ESP8266 Arduino Addon, errors on the use of ‘min’ and ‘max’ functions to be more precise. This was caused by the (default!) installation of a version of the ESP8266 add-on in the Boards Manager that was incompatible with the WS2812FX library. Changing it to version 2.4.0-rc2 solved the issues, other versions may work too.
Using the RGB LED Server
First connect to the WiFi network of the ESP8266’s access point, the default SSID is “Neopixel Elektor” with password “Tours2017”. Open your browser and enter the IP Address 192.168.4.1 in the address bar. Select the LED intensity and light effect end press the ‘send’ button to transfer these parameters to the server. Effect ‘100’ will cycle through all available light effects.
BOM
Resistor
R1,R4 = 220 Ω, thick film, 5%, 0.1W, 150V
R2,R3,R6,R7,R8 = 10 kΩ, thick film, 5%, 0.1W, 150V
R5 = 100 kΩ, thick film, 5%, 0.1W, 150V
Inductor
Capacitor
C1,C4,C6 = 100 nF, 50 V, X7R, 0805
C2 = 10μF, 16V radial can SMD, Panasonic FK series
C3,C5,C7 = 100μF, 16V radial can SMD, Panasonic FK series
Semiconductor
D1 = LL4001 diode 50V, 1A
LED1 = LED, green, 3 mm
T1 = BSS138LT1G N-channel MOSFET, 50V, 200mA
IC1 = LM3940IMP-3.3 LDO 3.3V, 1A
MOD1 = ESP-01, ESP8266-based WiFi module
Other
F1 = Holder for 5 x 20mm fuse, PSB mount, pitch 22.6mm
F1 = fuse 5 x 20mm (see text)
S1 = Slide switch SPDT, Through hole, angled (C&K 1101M2S4AQE2)
K1 = Power jack 2.35mm, 4A (Multicomp MJ-180PH)
K2 = Wire-To-Board connector SL 5.08, 3 ways
K2' = Pluggable terminal block BL5.08, 3 ways
K3 = Wire-To-Board connector SL 5.08, 2 ways
K2' = Pluggable terminal block BL5.08, 3 ways
K4 = header male 6 pin, 0.1" pitch vertical
JP1,JP2 = header male 2 pin, 0.1" pitch vertical
JP1',JP2 = Jumper
Enclosure Hammond 1591 112x62x31
Hardware
The schematic shows that the hardware isn’t too complicated. The ESP8266-based ESP-01 module (MOD1) does all the work, but of course it needs some additional stuff to do the trick.
First of all the power supply: a 5V, 2A power supply can be connected to K1. D1 serves as crowbar, protecting the circuit by blowing fuse F1 if the polarity of the supply voltage is wrong. WS2812B Neopixel LEDs will consume about 60mA each at full intensity, so a 2A power supply will suffice for about 33 of these LEDs. If you need more power (i.e. more LEDs), a heavier power supply can be connected to K3 instead of K2. In that case, don’t forget to change F1 to a suitable higher current rating (i.e. just below the maximum current of the power supply).
Alternatively, instead of using K1 or K3, when you only need power for programming and/or debugging the ESP8266, power can be supplied via a 3.3V FTDI cable connected to K4 with jumper JP2 closed. Please note that this 5V connection at pin 3 can not source more than 50mA, so disconnect K2 (i.e. the LEDs) when you use K4 to power the circuit! And equally important: remove the FTDI-cable or JP2 before you connect a power supply to K1 or K3!
Jumper JP1 must be closed on power up when you are going to program the ESP-module, don’t forget to remove it after programming. If JP1 is closed on power up, the ESP8266 will start in programming mode and your application will not run.
Low-drop voltage regulator IC1 is used for the 3.3V supply voltage of the ESP8266, LED1 will light when this voltage is present.
T1 serves as voltage level shifter, translating the 3.3V output signal of the ESP to 5V input voltage level for data of the WS2812 Neopixel LED strip connected to K2. Although this level shifter is bi-directional, the signal in this case is output only (i.e. 3.3V -> 5V).
Level shifter issues
In the original design a 2N7002 was used, with 10k pull-up resistors at the 5V and 3V3 side. This proved to be a poor solution, with the 800kHz square wave of the Neopixel data signal the voltage level at the drain of the FET hardly reaching the 3.5V level needed for the Neopixel LEDs to detect a logic high level, let alone the 5V we would (like to) expect there. Apparently the cut-off voltage of these FETs (2.5V max.) is too high for this application, a BSS138 with a 1.5V threshold does a much better (although still not perfect!) job.
Software
Our software download package contains the Arduino 'portable' folder for this project (see https://www.arduino.cc/en/Guide/PortableIDE for more infromation on the Arduino portable IDE). To cut the size of this download, we did NOT include the Arduino ESP8266 boards addon, please refer to https://github.com/esp8266/Arduino if you need help with the installation of this addon.
The Arduino sketch for this project uses (amongst others) the WS2812 library, which also contains the 44 light effects that can be selected for the LED strip.
The length of the strip (i.e. the number of LEDs) can be entered in line 44 of the sketch:
#define LED_COUNT 180
The sketch will still work if this constant doesn’t match the LED strip you have, but if it contains more LEDs than LED_COUNT, the remaining LEDs will not light. Or if the LED strip is shorter than LED_COUNT, the light effect may be spoiled because part of the animation is lost.
The name access point of the ESP and its password can be changed in lines 27 and 28 of the sketch:
const char *ssid = “Neopixel Elektor”
const char *password = “Tours2017”
For French-speaking readers: there is also a French version of the ESP’s webpage available. To select this, just change the constant LANGUAGE in line 25 from ‘1’ to ‘0’ before you compile and upload the sketch.
Compiler errors
We had some issues compiling the source code of this project after a fresh install of the Arduino IDE and its ESP8266 Arduino Addon, errors on the use of ‘min’ and ‘max’ functions to be more precise. This was caused by the (default!) installation of a version of the ESP8266 add-on in the Boards Manager that was incompatible with the WS2812FX library. Changing it to version 2.4.0-rc2 solved the issues, other versions may work too.
Using the RGB LED Server
First connect to the WiFi network of the ESP8266’s access point, the default SSID is “Neopixel Elektor” with password “Tours2017”. Open your browser and enter the IP Address 192.168.4.1 in the address bar. Select the LED intensity and light effect end press the ‘send’ button to transfer these parameters to the server. Effect ‘100’ will cycle through all available light effects.
BOM
Resistor
R1,R4 = 220 Ω, thick film, 5%, 0.1W, 150V
R2,R3,R6,R7,R8 = 10 kΩ, thick film, 5%, 0.1W, 150V
R5 = 100 kΩ, thick film, 5%, 0.1W, 150V
Inductor
Capacitor
C1,C4,C6 = 100 nF, 50 V, X7R, 0805
C2 = 10μF, 16V radial can SMD, Panasonic FK series
C3,C5,C7 = 100μF, 16V radial can SMD, Panasonic FK series
Semiconductor
D1 = LL4001 diode 50V, 1A
LED1 = LED, green, 3 mm
T1 = BSS138LT1G N-channel MOSFET, 50V, 200mA
IC1 = LM3940IMP-3.3 LDO 3.3V, 1A
MOD1 = ESP-01, ESP8266-based WiFi module
Other
F1 = Holder for 5 x 20mm fuse, PSB mount, pitch 22.6mm
F1 = fuse 5 x 20mm (see text)
S1 = Slide switch SPDT, Through hole, angled (C&K 1101M2S4AQE2)
K1 = Power jack 2.35mm, 4A (Multicomp MJ-180PH)
K2 = Wire-To-Board connector SL 5.08, 3 ways
K2' = Pluggable terminal block BL5.08, 3 ways
K3 = Wire-To-Board connector SL 5.08, 2 ways
K2' = Pluggable terminal block BL5.08, 3 ways
K4 = header male 6 pin, 0.1" pitch vertical
JP1,JP2 = header male 2 pin, 0.1" pitch vertical
JP1',JP2 = Jumper
Enclosure Hammond 1591 112x62x31
Discussion (9 commentaire(s))