ESP8266 MQTT JSON Lights. Supports brightness, effects, speed and OTA uploads. Based on https://github.com/bruhautomation/ESP-MQTT-JSON-Digital-LEDs
- WS2812 5v LED Ring
- WS2811 5v LED String (Required
NEO_GRB
to be changed toNEO_RGB
on line 56 inmain.cpp
for my set of lights)
This is not a comprehensive list by any means. Just devices that I or others have tested are working. Feel free to try uploading to your own device and add a pull request if your device works also.
Hardware is your choice of course. My examples however only requires a 5v power supply (which could just be USB) with high enough amperage to drive the LEDs.
A 5V power supply may be required if your lights draw too much current. If this happens or you are planning to use more than 30 leds or so, use the below method.
The diode / zenner diode isn't required, but I added it to avoid any reverse current issues.
You can drive over 100 LEDs without issues on this method. You may however have to add a wire from the PSU +5v to sections of the wire if you experience dimming along the string/strip.
-
Using Atom or VS Code, install Platform IO
-
Once setup, install the
esp8266
embedded platform -
Rename
src/setup-template.h
tosrc/setup.h
and add your network, MQTT and lighting setup information. Take note of thedeviceName
you set. You will need this later to send MQTT messages. -
Build the project (Ctrl+Alt+B) and check for any errors
If the build produces an error referencing dependencies, You will need to manually install these libraries:
- Adafruit NeoPixel
- ArduinoJson
- PubSubClient
- WS2812FX
-
Upload to your board of choice (Ctrl+Alt+U). This project was created specifically for the
NodeMCU
but can be configured to work with another WiFi board with some tinkering.
light:
platform: mqtt_json
name: 'LED Lights'
state_topic: 'light/led'
command_topic: 'light/led/set'
availability_topic: 'light/led/LWT'
payload_available: 'Online'
payload_not_available: 'Offline'
effect: true
effect_list:
- static
- blink
- breath
- color wipe
- color wipe inverted
- color wipe reverse
- color wipe reverse inverted
- color wipe random
- random color
- single dynamic
- multi dynamic
- rainbow
- rainbow cycle
- scan
- dual scan
- fade
- theater chase
- theater chase rainbow
- running lights
- twinkle
- twinkle random
- twinkle fade
- twinkle fade random
- sparkle
- flash sparkle
- hyper sparkle
- strobe
- strobe rainbow
- multi strobe
- blink rainbow
- chase white
- chase color
- chase random
- chase rainbow
- chase flash
- chase random
- chase rainbow white
- chase blackout
- chase blackout rainbow
- color sweep random
- running color
- running red blue
- running random
- larson scanner
- comet
- fireworks
- fireworks random
- merry christmas
- fire flicker
- fire flicker soft
- fire flicker intense
- circus combustus
- halloween
- bicolor chase
- tricolor chase
- icu
brightness: true
rgb: true
optimistic: false
qos: 0
input_number:
led_effect_speed:
name: 'LED Effect Speed'
initial: 50 # This is the default speed
mode: slider
min: 10 # ######################################
max: 1000 # Feel Free to adjust these as you like
step: 10 # ######################################
automation:
- action:
- alias: Set LED Lights Effect Speed
service: mqtt.publish
data_template:
topic: light/led/set
payload: '{"speed":{{ trigger.to_state.state | int }}}'
alias: LED Light Effect Speed
trigger:
- platform: state
entity_id: input_number.led_effect_speed
The speed of the lights will be slower the higher the slider value and faster the lower the value. Treat this more as a delay slider than a speed slider.
{
"brightness": 120,
"color": {
"r": 255,
"g": 255,
"b": 255
},
"effect": "rainbow cycle",
"speed": 60,
"state": "ON"
}