Need help Combining MQQT esp8266 and RGB driver

Hi Guys,

Attaches are 2 working scripts MQTT_RGB that runs a older larger RGB light strip driver and SingleLEDStrip that i can use on my new slim RGB driver and changes color. i have

I cant seem to be able to work them together and i’m hoping someone can help

Thanks Guys

Arduino-Help.zip (62.9 KB)

Hi,

I highly doubt anyone will want to download a zip file (security concerns).

What is your experiece with coding? If it is not very high, i suggest you start with an easier project first. EG, read a button and light an LED at the same time. It will help you learn how to combine these too files, because short of doing it for your you, theres no way to explain in detail everything that needs to be done in order to get MQQT and RGB led control working at the same time.

This is a good start:

doing multiple things at once

So, you have two sketches that, individually, work properly. You shared them. You have a third sketch that doesn't work, that you need help with. You didn't share that.

Apparently, you just wanted to vent your frustrations. Hope that it helped.

Hi Qdeathstar i have what id say is a healthy knowledge of the arduino language as ive managed to get MQTT working with an RGB controller. the only reason i used a zip was so i could include the libraries

And PaulS I have about 16 different copies of me trying to get this working and didnt think anyone would need to see my failed attempts haha

didnt think anyone would need to see my failed attempts

This is the part of the forum where we help you convert failed attempts into successful code.

The default mqqt library uses a lot of while statements which block, you need to change them to if statements...

my latest attempt to get this working is attached but the serial is printing :

wdt reset
load 0x4010f000, len 1384, room 16 
tail 8
chksum 0x2d
csum 0x2d
v09f0c112
~ld

Sorry, this is only my second post, but yeah i get having my butchered code may help

MQTT_RGBDriver.ino (6.79 KB)

void callback(char* p_topic, byte* p_payload, unsigned int p_length) {
  // concat the payload into a string
  String payload;
  for (uint8_t i = 0; i < p_length; i++) {
    payload.concat((char)p_payload[i]);
  }

Why are you pissing away resources on the String class? Cast the p_payload as a char *, and use it as a string (after adding a NULL terminator).

  if (String(MQTT_LIGHT_COMMAND_TOPIC).equals(p_topic)) {

It makes NO sense to try to create a String out of data that is NOT in SRAM without properly accessing the data in PROGMEM.

    if (payload.equals(String(LIGHT_ON))) {

See above.

The rest of your code makes the same incorrect assumption that accessing PROGMEM data is exactly the same as accessing data from SRAM. It is not.

You need to:
Stop using Strings. Completely. Now and forever.
Learn to use memcmp_P, strcmp_P, etc.