GithubHelp home page GithubHelp logo

esp-mqtt-rgb-led's People

Contributors

chrom3 avatar citruz avatar corbanmailloux avatar mpagnoulle avatar r41d avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

esp-mqtt-rgb-led's Issues

How much power does the ESP8266 use?

I'm thinking about changing the voltage regulator to a buck for efficiency but if the ESP8266 only draws a small amount of current most of the time then maybe it's not worth it. About how much power do you expect the ESP8266 to draw most of the time?

MQTT packet size

Hello. I have implemented this to ESP32 with simple cp-paste from example sketches. Basically I changed:
#include <ESP8266WiFi.h> to #include <WiFi.h>
analog.Writes to corresponding ledc library.

JSON library is intact as it should be.

However for some reason callback() function isn't called if JSON message is too long. 6 lines/objects is fine, 7 or more isn't.

I did found that message goes nicely to thru MQTT broker and that it doesn't matter which objects are in the payload. Other than that I'm out of ideas.

Rename files to suggest using the unified sketch

As mentioned in my comment on PR #31, I should rename the files to push people to use the unified sketch instead of the other ones. This will make future improvements simpler, because only one file will need to be updated.

As part of this, the README should also be updated to explain what the files mean and how to choose/configure the right options.

Home Assistant MQTT JSON light change

I think HA 0.84 introduced a breaking change for mqtt json lights:
from:
platform: mqtt_json

to:
platform: mqtt
schema: json

I'm sure you already know, but just a tip for other folks.

Thanks for this awesome project!

adding support for WW/CW led strips

Hi corbanmailloux, thanks for this project, I've used it for a couple rgb strips and it's great!

I'm now hoping to use it with a new led strip that has Warm White/Cool White led chips run on separate wiring loops like regular rgb chips. Doing some research, it looks like:

  • your code has one white channel already
  • the MQTT JSON component already has colour temperature support built in

Is it possible to add support for a dual white mode to this firmware, so that I can then add a 'single' colour light to homeassistant that is brightness and colour temp variable?

Cheers!

Can this be used with cloud mqtt

HI is this limited to Home Assistant, can we use this with cloud mqtt ? I see only one topic when the device connects to the server, what messages do we have send to change the state of the device ?

cant compile

hi there
i get the next output error when i try to compile

Arduino:1.8.5 (Linux), Tarjeta:"NodeMCU 1.0 (ESP-12E Module), 80 MHz, 4M (1M SPIFFS), v2 Lower Memory, Disabled, None, Only Sketch, 115200"

mqtt_esp8266_light:26: error: 'CONFIG_STRIP' was not declared in this scope
 const bool rgb = (CONFIG_STRIP == RGB) || (CONFIG_STRIP == RGBW);
                   ^
mqtt_esp8266_light:26: error: 'RGB' was not declared in this scope
 const bool rgb = (CONFIG_STRIP == RGB) || (CONFIG_STRIP == RGBW);
                                   ^
mqtt_esp8266_light:26: error: 'CONFIG_STRIP' was not declared in this scope
 const bool rgb = (CONFIG_STRIP == RGB) || (CONFIG_STRIP == RGBW);
                                            ^
mqtt_esp8266_light:26: error: 'RGBW' was not declared in this scope
 const bool rgb = (CONFIG_STRIP == RGB) || (CONFIG_STRIP == RGBW);
                                                            ^
mqtt_esp8266_light:27: error: 'CONFIG_STRIP' was not declared in this scope
 const bool includeWhite = (CONFIG_STRIP == BRIGHTNESS) || (CONFIG_STRIP == RGBW);
                            ^
mqtt_esp8266_light:27: error: 'BRIGHTNESS' was not declared in this scope
 const bool includeWhite = (CONFIG_STRIP == BRIGHTNESS) || (CONFIG_STRIP == RGBW);
                                            ^
mqtt_esp8266_light:27: error: 'CONFIG_STRIP' was not declared in this scope
 const bool includeWhite = (CONFIG_STRIP == BRIGHTNESS) || (CONFIG_STRIP == RGBW);
                                                            ^
mqtt_esp8266_light:27: error: 'RGBW' was not declared in this scope
 const bool includeWhite = (CONFIG_STRIP == BRIGHTNESS) || (CONFIG_STRIP == RGBW);
                                                                            ^
/home/mefizto/Documentos/esp-mqtt-rgb-led-master/mqtt_esp8266_light/mqtt_esp8266_light.ino: In function 'void setup()':
mqtt_esp8266_light:86: error: 'CONFIG_PIN_RED' was not declared in this scope
     pinMode(CONFIG_PIN_RED, OUTPUT);
             ^
mqtt_esp8266_light:87: error: 'CONFIG_PIN_GREEN' was not declared in this scope
     pinMode(CONFIG_PIN_GREEN, OUTPUT);
             ^
mqtt_esp8266_light:88: error: 'CONFIG_PIN_BLUE' was not declared in this scope
     pinMode(CONFIG_PIN_BLUE, OUTPUT);
             ^
mqtt_esp8266_light:91: error: 'CONFIG_PIN_WHITE' was not declared in this scope
     pinMode(CONFIG_PIN_WHITE, OUTPUT);
             ^
mqtt_esp8266_light:95: error: 'CONFIG_BUILTIN_LED_MODE' was not declared in this scope
   switch (CONFIG_BUILTIN_LED_MODE) {
           ^
mqtt_esp8266_light:110: error: 'CONFIG_DEBUG' was not declared in this scope
   if (CONFIG_DEBUG) {
       ^
mqtt_esp8266_light:115: error: 'CONFIG_MQTT_HOST' was not declared in this scope
   client.setServer(CONFIG_MQTT_HOST, CONFIG_MQTT_PORT);
                    ^
mqtt_esp8266_light:115: error: 'CONFIG_MQTT_PORT' was not declared in this scope
   client.setServer(CONFIG_MQTT_HOST, CONFIG_MQTT_PORT);
                                      ^
/home/mefizto/Documentos/esp-mqtt-rgb-led-master/mqtt_esp8266_light/mqtt_esp8266_light.ino: In function 'void setup_wifi()':
mqtt_esp8266_light:124: error: 'CONFIG_WIFI_SSID' was not declared in this scope
   Serial.println(CONFIG_WIFI_SSID);
                  ^
mqtt_esp8266_light:127: error: 'CONFIG_WIFI_PASS' was not declared in this scope
   WiFi.begin(CONFIG_WIFI_SSID, CONFIG_WIFI_PASS);
                                ^
/home/mefizto/Documentos/esp-mqtt-rgb-led-master/mqtt_esp8266_light/mqtt_esp8266_light.ino: In function 'bool processJson(char*)':
mqtt_esp8266_light:201: error: 'StaticJsonBuffer' was not declared in this scope
   StaticJsonBuffer<BUFFER_SIZE> jsonBuffer;
   ^
/home/mefizto/Documentos/esp-mqtt-rgb-led-master/mqtt_esp8266_light/mqtt_esp8266_light.ino:201:3: note: suggested alternative:
In file included from /home/mefizto/Arduino/libraries/ArduinoJson/src/ArduinoJson/StaticJsonDocument.hpp:8:0,
                 from /home/mefizto/Arduino/libraries/ArduinoJson/src/ArduinoJson.hpp:15,
                 from /home/mefizto/Arduino/libraries/ArduinoJson/src/ArduinoJson.h:9,
                 from /home/mefizto/Documentos/esp-mqtt-rgb-led-master/mqtt_esp8266_light/mqtt_esp8266_light.ino:19:
/home/mefizto/Arduino/libraries/ArduinoJson/src/ArduinoJson/Memory/StaticJsonBuffer.hpp:110:7: note:   'ArduinoJson::Internals::StaticJsonBuffer'
 class StaticJsonBuffer : public Internals::StaticJsonBufferBase {
       ^
mqtt_esp8266_light:201: error: 'jsonBuffer' was not declared in this scope
   StaticJsonBuffer<BUFFER_SIZE> jsonBuffer;
                                 ^
mqtt_esp8266_light:211: error: 'CONFIG_MQTT_PAYLOAD_ON' was not declared in this scope
     if (strcmp(root["state"], CONFIG_MQTT_PAYLOAD_ON) == 0) {
                               ^
mqtt_esp8266_light:214: error: 'CONFIG_MQTT_PAYLOAD_OFF' was not declared in this scope
     else if (strcmp(root["state"], CONFIG_MQTT_PAYLOAD_OFF) == 0) {
                                    ^
mqtt_esp8266_light:227: error: 'CONFIG_DEFAULT_FLASH_LENGTH' was not declared in this scope
       flashLength = CONFIG_DEFAULT_FLASH_LENGTH * 1000;
                     ^
mqtt_esp8266_light:269: error: 'CONFIG_COLORFADE_TIME_SLOW' was not declared in this scope
       transitionTime = CONFIG_COLORFADE_TIME_SLOW;
                        ^
mqtt_esp8266_light:272: error: 'CONFIG_COLORFADE_TIME_FAST' was not declared in this scope
       transitionTime = CONFIG_COLORFADE_TIME_FAST;
                        ^
/home/mefizto/Documentos/esp-mqtt-rgb-led-master/mqtt_esp8266_light/mqtt_esp8266_light.ino: In function 'void sendState()':
mqtt_esp8266_light:310: error: 'StaticJsonBuffer' was not declared in this scope
   StaticJsonBuffer<BUFFER_SIZE> jsonBuffer;
   ^
/home/mefizto/Documentos/esp-mqtt-rgb-led-master/mqtt_esp8266_light/mqtt_esp8266_light.ino:310:3: note: suggested alternative:
In file included from /home/mefizto/Arduino/libraries/ArduinoJson/src/ArduinoJson/StaticJsonDocument.hpp:8:0,
                 from /home/mefizto/Arduino/libraries/ArduinoJson/src/ArduinoJson.hpp:15,
                 from /home/mefizto/Arduino/libraries/ArduinoJson/src/ArduinoJson.h:9,
                 from /home/mefizto/Documentos/esp-mqtt-rgb-led-master/mqtt_esp8266_light/mqtt_esp8266_light.ino:19:
/home/mefizto/Arduino/libraries/ArduinoJson/src/ArduinoJson/Memory/StaticJsonBuffer.hpp:110:7: note:   'ArduinoJson::Internals::StaticJsonBuffer'
 class StaticJsonBuffer : public Internals::StaticJsonBufferBase {
       ^
mqtt_esp8266_light:310: error: 'jsonBuffer' was not declared in this scope
   StaticJsonBuffer<BUFFER_SIZE> jsonBuffer;
                                 ^
mqtt_esp8266_light:314: error: 'CONFIG_MQTT_PAYLOAD_ON' was not declared in this scope
   root["state"] = (stateOn) ? CONFIG_MQTT_PAYLOAD_ON : CONFIG_MQTT_PAYLOAD_OFF;
                               ^
mqtt_esp8266_light:314: error: 'CONFIG_MQTT_PAYLOAD_OFF' was not declared in this scope
   root["state"] = (stateOn) ? CONFIG_MQTT_PAYLOAD_ON : CONFIG_MQTT_PAYLOAD_OFF;
                                                        ^
mqtt_esp8266_light:329: error: 'CONFIG_COLORFADE_TIME_SLOW' was not declared in this scope
     if (transitionTime == CONFIG_COLORFADE_TIME_SLOW) {
                           ^
mqtt_esp8266_light:340: error: 'class ArduinoJson::JsonObject' has no member named 'measureLength'
   char buffer[root.measureLength() + 1];
                    ^
mqtt_esp8266_light:341: error: 'class ArduinoJson::JsonObject' has no member named 'printTo'
   root.printTo(buffer, sizeof(buffer));
        ^
mqtt_esp8266_light:341: error: 'buffer' was not declared in this scope
   root.printTo(buffer, sizeof(buffer));
                ^
mqtt_esp8266_light:343: error: 'CONFIG_MQTT_TOPIC_STATE' was not declared in this scope
   client.publish(CONFIG_MQTT_TOPIC_STATE, buffer, true);
                  ^
/home/mefizto/Documentos/esp-mqtt-rgb-led-master/mqtt_esp8266_light/mqtt_esp8266_light.ino: In function 'void reconnect()':
mqtt_esp8266_light:351: error: 'CONFIG_MQTT_CLIENT_ID' was not declared in this scope
     if (client.connect(CONFIG_MQTT_CLIENT_ID, CONFIG_MQTT_USER, CONFIG_MQTT_PASS)) {
                        ^
mqtt_esp8266_light:351: error: 'CONFIG_MQTT_USER' was not declared in this scope
     if (client.connect(CONFIG_MQTT_CLIENT_ID, CONFIG_MQTT_USER, CONFIG_MQTT_PASS)) {
                                               ^
mqtt_esp8266_light:351: error: 'CONFIG_MQTT_PASS' was not declared in this scope
     if (client.connect(CONFIG_MQTT_CLIENT_ID, CONFIG_MQTT_USER, CONFIG_MQTT_PASS)) {
                                                                 ^
mqtt_esp8266_light:353: error: 'CONFIG_MQTT_TOPIC_SET' was not declared in this scope
       client.subscribe(CONFIG_MQTT_TOPIC_SET);
                        ^
/home/mefizto/Documentos/esp-mqtt-rgb-led-master/mqtt_esp8266_light/mqtt_esp8266_light.ino: In function 'void setColor(int, int, int, int)':
mqtt_esp8266_light:365: error: 'CONFIG_INVERT_LED_LOGIC' was not declared in this scope
   if (CONFIG_INVERT_LED_LOGIC) {
       ^
mqtt_esp8266_light:373: error: 'CONFIG_PIN_RED' was not declared in this scope
     analogWrite(CONFIG_PIN_RED, inR);
                 ^
mqtt_esp8266_light:374: error: 'CONFIG_PIN_GREEN' was not declared in this scope
     analogWrite(CONFIG_PIN_GREEN, inG);
                 ^
mqtt_esp8266_light:375: error: 'CONFIG_PIN_BLUE' was not declared in this scope
     analogWrite(CONFIG_PIN_BLUE, inB);
                 ^
mqtt_esp8266_light:379: error: 'CONFIG_PIN_WHITE' was not declared in this scope
     analogWrite(CONFIG_PIN_WHITE, inW);
                 ^
mqtt_esp8266_light:382: error: 'CONFIG_DEBUG' was not declared in this scope
   if (CONFIG_DEBUG) {
       ^
exit status 1
'CONFIG_STRIP' was not declared in this scope

Este reporte podría tener más información con
"Mostrar salida detallada durante la compilación"
opción habilitada en Archivo -> Preferencias.

Think about fallback features

There should be some basic fallback (and documented how it works) to situations like:

  • MQTT server is not running on start
  • MQTT server stopped later
  • ESP crashes
  • ESP not boots / is removed

It is good practice in smart home UX to keep non-smart features if smart devices are not working. In lighting, switch on the wall should turn on and off the light (white, 100% brightness).

Add GPIO input to manually turn the light on and off

Add Gpio inputs to physically turn on and off the light, incase one does not have access to phone. this could be one momentary switch which would increase brightness or decrease if max bright is already met. or if pressed briefly could turn off light. not sure how you would handle RGB

Plans for development?

Seems this is the best RGB code for homeassistant at the moment. So wonder if there are any plans for further development?
Separate control for White light in RGB? More effects?

Way too low brightness

So as you said connect the gate to 3.3v rail I did now the brightness is good now but cant control the color or anything anymore.

Added inverson function

Hi, I modified the code to add a functional invert option - not being a full github guru, I'm just documenting it here!!

The purpose was to invert the output driver ranges so that I could use the code for a single RGB LED (Common anode) built into a dummy 'mains lamp' linked directly to the ESP I/O pins through current limiting resistors...the arrangement meant that a GPIO of 255 is full off, and 0 is full on (inverted logic)

config.h - added a definition:

//NK LED Type - Common anode uses reverse value logic for intensities
#define MODE_INVERT 1

In main code - added a variable at line 20:

const int modeInvert = MODE_INVERT;

Modified setColor:

 if (modeInvert == 1)
  {
    analogWrite(redPin, 255 - inR);
    analogWrite(greenPin, 255 - inG);
    analogWrite(bluePin, 255 - inB);
  }
  else
  {
  analogWrite(redPin, inR);
  analogWrite(greenPin, inG);
  analogWrite(bluePin, inB);
  }

To Run Simple LED from MQTT JSON in ESP32

I am trying to blink simple LED in ESP32 from JSON via MQTT but the code I run is compiled and flashed properly but It couldnt run properly.
Could you please provide a simple firmware for blinking an LED from JSON via MQTT :
In Below code I have published a JSON String {"Switch_Status":"FOR"}/ {"Switch_Status":"REV"}/ {"Switch_Status":"STOP"} but LED doesn't blink on this or it doesnt put the status in previous_state array:

#include <Arduino.h>
#include <WiFi.h>
#include <PubSubClient.h>
#include <ArduinoJson.h>
long last_time = 0;
char apName[] = "SmartDEVICE.";
char data[100];
// MQTT client
WiFiClient wifiClient;
PubSubClient mqttClient(wifiClient); 
char *mqttServer = "broker.hivemq.com";
int mqttPort = 1883;
const char *SSID = "Wifi_ID";
const char *PWD = "Password";
char previous_state[5];
int LED1=19;
int LED2=21;
void connectToWiFi() {
  Serial.print("Connectiog to ");
 
  WiFi.begin(SSID, PWD);
  Serial.println(SSID);

  while (WiFi.status() != WL_CONNECTED) {
    Serial.print(".");
    delay(500);
  }
  Serial.print("Connected.");  
} 
void setupMQTT() {
  mqttClient.setServer(mqttServer, mqttPort);
  // set the callback function
  mqttClient.setCallback(callback);
}
void setup() {
  Serial.begin(115200);
     ##pinMode(LED1,OUTPUT);
  pinMode(LED2,OUTPUT);
connectToWiFi();
setupMQTT();
  }
void reconnect() {
  Serial.println("Connecting to MQTT Broker...");
  while (!mqttClient.connected()) {
      Serial.println("Reconnecting to MQTT Broker..");
      String clientId = "ESP32Client-";
      clientId += String(random(0xffff), HEX);
       if (mqttClient.connect(clientId.c_str())) {
        Serial.println("Connected.");
        // subscribe to topic
        mqttClient.subscribe("swa/commands");
      }
      }
}
void loop() {
if (!mqttClient.connected())
    reconnect();
   mqttClient.loop();
   StaticJsonBuffer<200> JSONbuffer;
  JsonObject& JSONencoder = JSONbuffer.createObject();
  JSONencoder["Device_Name"] = apName;
  JSONencoder["Wifi_Status"]= "Wifi_OK";
  JSONencoder["LED_Status"]= previous_state;
 char JSONmessageBuffer[200];
  JSONencoder.printTo(JSONmessageBuffer, sizeof(JSONmessageBuffer));
  Serial.println("Sending message to MQTT topic..");
  Serial.println(JSONmessageBuffer);
 mqttClient.publish("esp/test", JSONmessageBuffer) ;
  if (mqttClient.publish("esp/test", JSONmessageBuffer) == true) {
    Serial.println("Success sending message");
  } else {
    Serial.println("Error sending message");
  }
  Serial.println("-------------");
  delay(5000);
  }
void callback(char* topic, byte* payload, unsigned int length) {
  StaticJsonBuffer<200> JSONBuffer;
  char JSONinData[150];
  Serial.print("Callback From- ");
  Serial.println(topic);
    Serial.print("data:");  
   Serial.print("payload: ");
  for(int i =0; i<length; i++){
  Serial.print((char)payload[i]);
   JSONinData[i] = (char)payload[i];
 }
 Serial.println();
 JsonObject& parsed = JSONBuffer.parseObject(JSONinData);  
if (!parsed.success()) {   //Check for errors in parsing
 Serial.println("Parsing failed");
    delay(2000);
    return;
 }
const char * val= parsed["Switch_Status"];
// DO SOMETHING WITH THE DATA THAT CAME IN!
 Serial.println("Parsed Data:");
 Serial.println(val); 
if( val=="FOR"){
  digitalWrite(LED1,HIGH);
  Serial.println("LED1 is ON");
  strcpy(previous_state , (const char*)parsed["LED_Status"]);
}
else if(val=="REV"){
  digitalWrite(LED2,HIGH);
  Serial.println("LED2 is ON");
  strcpy(previous_state , (const char*)parsed["LED_Status"]);
}
// change the return type of the function
else if(val =="STOP")
{
    digitalWrite(LED1,LOW);
      digitalWrite(LED2,LOW);
      strcpy(previous_state , (const char*)parsed["LED_Status"]);
}
}

Expose white channel as a separate light from RGB in Home Assistant

As the previous one was closed o will reopen.
Currently for RGBW there is a white value in HA. This controlls the the white diodes. But it only works together with RGB. So there is no way currently to switch on white diodes without switching on RGB. Exposing W value as a separate light will do the trick

White channel support

I just came across this project as I was looking to update my MQTT/RGBWW LEDstrip config and I did not want to reinvent the wheel. I was wondering whether it was on the roadmap for this project to add support for cool/warm white channels on RGBW(W) LED strips?

Project looks great!

How to set unique id for home assistant

Thanks for this code - I got it working on a wemos d1 mini and RGB LED strip without much trouble!

In home assistant I have the light set up in my configuration.yaml following your instructions, and I have mosquitto addon as my mqtt broker and the mqtt integration as well, and my device shows up but I can't assign it to an area because home assistant says: "This entity ("light.bedroom_rgb_led_strip") does not have a unique ID, therefore its settings cannot be managed from the UI. See the documentation for more detail."

Is there a way to make sure such an ID is assigned? I had defined the mqtt client id in the firmware:

#define CONFIG_MQTT_CLIENT_ID "BEDROOM_RGB_LED_STRIP" // Must be unique on the MQTT network

but it doesn't seem to use this to create a unique id for the entity.

Merge scripts into one

Although this would introduce some (ugly) #ifdef and #ifndef I think it makes sense because 90% of the code is shared and it is very tedious to add features in all three files.

Way too low brightness

I created this project today with Normal 12 DC RGB Led and IRF840N Channel Mosfet but this brightness is way too low any help ?

Can't get the MQT to work, any ideas ?

Hi,
I have put this into a nodemcu, it connects to WiFi and it also connects to the MWTT broker (i can see that in the serial terminal) however when i publish the json payload to /home/rgb1/set nothing shows up the serial terminal ? I tried two different MQTT servers, both mosquito and http://www.hivemq.com/try-out/ and none works. It's very strange, in the code i should be able to see "Message received..." but nothing comes in.

Any ideas what i might be doing wrong ?

mqtt light (2nd entry) not showing on home assistant

light:

  • platform: mqtt_json
    name: mqtt_json_light_1
    state_topic: "home/rgb1"
    command_topic: "home/rgb1/set"
    brightness: true
    rgb: true
    effect: true
    effect_list: [colorfade_slow, colorfade_fast, flash]
    optimistic: false
    qos: 0

    name: mqtt_json_light_2
    state_topic: "home/rgb2"
    command_topic: "home/rgb2/set"
    brightness: true
    rgb: true
    effect: true
    effect_list: [colorfade_slow, colorfade_fast, flash]
    optimistic: false
    qos: 0

Can you/anyone please assistant me what I am doing wrong.

I had compile the code no error, home assistant load perfectly but LED Switch is showing only for mqtt_json_light_2.

thanks

AA

Some leds of the strip stop giving lights

I am using your project on my nodemcu and like the nice fade between different brightnesses and colors.
But if a specific color an brightness is set, then after some time; 20 min and sometimes 1 hour, some leds of the ledstrip stop giving light. Mostly at the beginning of the strip. If i the update the light color or brightness the all the leds of the strip are shining. I am using an resistor at the Din of the led, and a 1000uf capacitor at the 5V source. I am also running other code like arduino OTA and a task for the temperature sensor. What do you think could be wrong? And have you maybe an idea what could be wrong?

White LED is always ON with 4-colours-in-1-LED (5050 RGBW)

Hi, first thank you for your great job!

I use the MQTT RGBW Solution and don't know if there's an issue with my hardware or the code.

The LED I use is the "BTF-LIGHTING 5050 RGBW" (amzn) which has 4 colours in 1 LED.

Your Code

enum strip {
  BRIGHTNESS, // only one color/only white
  RGB,        // RGB LEDs
  RGBW        // RGB LEDs with an extra white LED per LED       X   <-----
};

looks like it means such an LED. Am I right or do you know if this type of LED is not supported?

My HA (actual release) config is:

  • Home Assistant 2023.9.1
  • Supervisor 2023.08.3
  • Operating System 10.5
  • Frontend 20230908.0 - latest

Config-Yaml:

mqtt:
  light:
     schema: json
     name: xxx_TV_RGBW
     state_topic: "xxx/esp01/rgbwTV"
     command_topic: "xxx/esp01/rgbwTV/set"
     brightness: true
     color_mode: true
     supported_color_modes: ["rgbw"]
     effect: true
     effect_list: [colorfade_slow, colorfade_fast, flash]
     optimistic: false
     qos: 0

It's working but the colour white is always on.

Fun fact: During the effects the white LED goes out, in normal mode it's always on, I can't turn it off.
You cannot produce intense RGB colors with the white LED switched on.
Is there a way to turn off the white content using an extra switch or something?

Feican LED Bulb flashing

hey, i was able to flash your code to the lamp and control it using MQTT, thank you for your hard work!
my Feican lights are RGBW which means i can use the warm white lights too.
in your code then is no such option, do you think its possible to add the ability to control the white lights too?

thank you and have a great week

parseObject() failed

I think I did everything but I get an parseObject() failed message.

IP address: 
192.168.0.37
Attempting MQTT connection...connected
Message arrived [home/rgbw1/set] ON
parseObject() failed

Taking #RRGGBB hex string and using it to create the JSON block with decimal values

One for the notes/wiki??

I was using a color wheel icon/function in an Android-based MQTT app to test my RGB LED build with esp-mqtt-rgb-led and Node-red. I created this node function to turn the received hex MQTT payload (#RRGGBB) from the app into an input string for this code on an ESP8266. Might be useful for others...

// Convert #RRGGBB hex payload into JSON formatted string for
// corbanmailloux/esp-mqtt-rgb-led code
// https://github.com/corbanmailloux/esp-mqtt-rgb-led

if ((msg.payload.toString().length != 7) &&
    (msg.payload.toString().substring(0.1) != "#"))
  {return null;}

msg.payload = '{"state": "ON","brightness": 255,"color": {' + 
  '"r": ' + parseInt(msg.payload.toString().substring(1,3),16) + ',' + 
  '"g": ' + parseInt(msg.payload.toString().substring(3,5),16) + ',' +
  '"b": ' + parseInt(msg.payload.toString().substring(5),16) + 
  '},"transition": 2' +
  '}';

return msg;

Research: Using FastLED under the hood

FastLED is a great framework for working with digital LED strips (NeoPixels, for example) and animations, but it does also support "dumb" analog LEDs.

I'd like to research if it would be worth including FastLED into this project for some of its features. For example, it support color correction, which could cover #16 (gamma correction to make the strip look better) and #27 (supporting other color temperatures). Some other features, like global brightness and HSV support, could be helpful as well.

I don't think much of the animation stuff would be applicable, but I want to know if FastLED has a standard way to fade between two colors. If so, that would eliminate the big chunk of math and complexity as well as a lot of the timing dependencies.

One possible blocker for this is that FastLED doesn't seem to support RGBW at the moment. There should be ways to make it work in this project because we're dealing with simple, analog LEDs, but native support would be benefitial.

(This is mostly just a brain-dump at the moment. When I get to do some research, I'll update/comment here.)

Add gamma correction

Hi,

Thank you for writing and sharing this code. I do have one enhancement if possible. I'm new to the ESP&Arduino in general so am not able to contribute myself (yet). What i noticed that when setting the LED to yellow (i.e. #FFFF00). The light produces a more green then yellow light. And in general the true colors are somewhat "off".

So I think a gamma correction could/should be added. I found something in the likes of this:
https://learn.adafruit.com/led-tricks-gamma-correction/the-quick-fix

If this is what is needed it should fairly easy to implement. What do you think?

Thanks & kind regards,
Max

Add config option for toggling the on-board LED

On some board (like the ESP8266-01), there is an on-board LED that is seemingly on by default. To turn it off, I've added some code to explicitly set the LED off. Some people might not be bothered by it, or may want to use that pin as an additional GPIO.

This uses the built-in define of BUILTIN_LED, which should be defined by the board configuration automatically in the Arduino IDE.

Add a configuration option for what to do with the LED.

  • -1 = Do not change its default pin mode.
  • 0 = Explicitly set it to LOW
  • 1 = Explicitly set it to HIGH

Resistors used?

Hi,
What valuw resistors did you use, also the FET type. If you have the schematics that would be cool to see.

Ability to use only white led

Can you add the ability to control the white led while turning off all RGB leds. I could've sworn I opened an issue before where I either provided a full solution or someone else did but I can't find it. I think the colour wheel may have had a black option before but I can't find that either.

The simplest solution I can rethink off right off the top of my head is to change the code in the example sketch on line 183 from:
realWhite = map(white, 0, 255, 0, brightness);
to:
realWhite = map(white, 0, 255, 0, 255);

This maps the white value without regard to the brightness value which allows one to individually control RGB and WHITE.

In lieu of a better solution, please consider adding this modification to the example sketch.

Mosfet

Which mosfet to use ?

IRF840N Mosfet?

4x4 keypad Need Help

I can't seem to figure out hoe to find and include the zip file for the 4x4 keypad.

Configure over wifi using captive portal.

I made a change that lets you configure over wifi using the captive portal feature, and it saves the config to the filesystem as JSON. This is handy if you need to change the wifi settings, or if you want to reconfigure topics. (I have multiple LED strips in different rooms.)

Once I have merged your unified source layout I should be able to make a PR that will suit that.

RGBW ledstrip connection

Hi,
I have a question concerning this tutorial: ESP8266 MQTT RGB(W) Lights Using JSON for Home Assistant.
I use a RGBW led strip. It has 5 wires: RGB Black and white.
My led strip has separate led for white.
In your image I can't see the connection for the black wire and the white wire goes to the +12V.
Please can you describe what I have to change in order to get it working.
Thank you in advance.
Kind regards,
Yvonne

Brightness transitions can overshoot.

If I have a light set to brightness: 255 and color: 33, 255, 19, and then I fade it to brightness: 40 with a transition of 1, it seems to overshoot and I end up with a very dim purple.

If I send the same request again, the lights set to the correct value.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.