Reading in a string and passing it to another function (from a function)

Your clearMQTT() is way to complicated

void clearMQTT() {   //  Clear the MQTT Payload
  memset(payload_buff, 0, sizeof(payload_buff));
  memset(topic_buff, 0, sizeof(topic_buff));
}  // End of clearPaylod()

How about

void clearMQTTPayloadAndTopic() {
  payload_buff[0] = 0;
  topic_buff[0] = 0;
}

There is no reason to clear the whole buffer.

Whandall:
If you guarantee that payload is terminated with a zero byte
and both strings will never be too big to fit into the buffers,
two simple strcpy() calls would work just the same.

Thanks Whandall.

if during my MQTT callback function, the paylod was a byte
void callback(char* topic, byte* payload, unsigned int length) {

I’m surprised the memcpy work but my previous coded (below) which I thought did a conversion of the data. I was able to display the variable via serial when in the function, but it was nothing (or blank) after. Need to find a tutorial on this or dig deeper in a simplified code.

int i = 0;
for(i=0; i<100; i++) {
payload_buff[i] = payload[i];

All too confused with my minimum understand of this. Thank you much though, I appreciate it! Robin2, Thank you for your helpful guidance as well.

eeze: I'm surprised the memcpy work but my previous coded (below) which I thought did a conversion of the data.

byte and char are only different interpretations of the same 8 bit structure, there is no conversion neccessary or even possible.

Whandall: byte and char are only different interpretations of the same 8 bit structure, there is no conversion neccessary or even possible.

This seems to be a consistent point of confusion for beginners. They don't understand that, at the machine level, the representation in memory is binary. That is:

Number Base Representation As stored in memory (binary) 10 Decimal 10 00001010 10 Octal 012 00001010 10 Hex 0A 00001010

So whether you want the number representated in base 10, 8, or 16, the binary representation used in their code is the same.

Thanks guys. That does make sense.

The reason it's hard to grasp is because conversions request for ints, chars, strings (Strings).

eg. right now, i'm trying to figure out how how to get my hex to a unsight int for my fill_solid LED from fastLED.h

It seems once I get one thing working, it's another. This last effort to do the LED color change has caused WDT soft resets. Disable the WDT and how hardware resets come in.

I guess it's part of learning.