corbanmailloux / esp-mqtt-rgb-led Goto Github PK
View Code? Open in Web Editor NEWMQTT RGB LEDs Using JSON for Home Assistant
License: MIT License
MQTT RGB LEDs Using JSON for Home Assistant
License: MIT License
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.
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.
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
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!
A features that could be great to have in this excellent project, is the ability to updates ESP8266/NODEMCU via OTA / OTA Uploading
http://esp8266.github.io/Arduino/versions/2.0.0/doc/ota_updates/ota_updates.html
Thanks.
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:
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?
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);
}
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.
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.)
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?
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"]);
}
}
One for brightness and one for controlling led?
But how to upload 2 files in 1 esp ?
Hi, as the human eye doesn't percieve light in a linear way, it would be great if brightness could be logarithmically corrected.
This effect is seen as there is a very big difference between 0% and 50% and neary no difference between 50 and 100%
https://en.wikipedia.org/wiki/Stevens%27s_power_law
I've modified your code following this example:
https://diarmuid.ie/blog/pwm-exponential-led-fading-on-arduino-or-other-platforms
And works pretty well
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?
Also set the number of colors dynamically.
Hey there,
don't suppose anyone knows how to modify this to work with the ethernet shield rather than an esp8266.
Many Thanks
Chris
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
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
There should be some basic fallback (and documented how it works) to situations like:
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).
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
As @depuits mentioned in #35 (comment), it would be great to find a way to extract the effects in some way.
I think that a couple of the bugs in this implementation at the moment are due to the interaction of variables from the different effects. See #34 for an example.
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
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.
I can't seem to figure out hoe to find and include the zip file for the 4x4 keypad.
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;
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
Hi,
What valuw resistors did you use, also the FET type. If you have the schematics that would be cool to see.
The Serial.print
lines aren't needed in the compiled version normally. Use defines to remove them.
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.
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 ?
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!
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.
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 ?
Every line errors with an example of 'CONFIG_STRIP' was not declared in this scope
Anyone know why?
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
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.
I created this project today with Normal 12 DC RGB Led and IRF840N Channel Mosfet but this brightness is way too low any help ?
The CONFIG_*
defines should be able to be used directly in most (all?) cases. Remove the redundant const
s.
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.
Which mosfet to use ?
IRF840N Mosfet?
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:
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!
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?
Also bring in any cleanups from the RGB example.
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
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.
If you change the colour using transition (tested with transition=1), the flash function does not work as expected.
Let me know if you need more info
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.