Hi!
This is probably very simple, but I'm totally new to Arduino.
I use a library with a function like this:
publish(char)
In that char, I need to put the following:
"Temperature is: " + degreesint
degreesint is an int variable with the temperature. This can be 1 or 2 digits.
I tried:
publish(strcat("Temperature is: ", degreesint)); //This outputs "Temperature is: "
publish("Temperature is: " + degreesint)); //This outputs incomplete stuff like "rature is: " or "perature is: ". It changes every time
Finally I also tried:
char *degreeschar = malloc(3);
sprintf(degreeschar , "%02d", degreesint);
publish(strcat("Temperature is: ", degreeschar));
This outputs "Temperature is: 14". The next time "Temperature is: 1418". Next "Temperature is: 141819", and so on. It just adds the temperature reads one after the other. This looks like a memory problem to me, but I'm rubish at handling that.
Can anyone provide some help? I tried many more things, but I lost the code for those.
Thanks you!