You should not be trying to concatenate String objects on an Arduino. It's a sure-fire way of mullering your memory.
Instead, just print each section of your string literal separately:
Serial.print("Temperatura del sensor: ");
Serial.print(temperatura);
Serial.print(" voltaje: ");
Serial.println(voltaje);
If you must build up a single string with embedded variable content, you should really be using char arrays (C strings) and using sprintf() to construct the content from a format string:
Asiergr:
In the first case we have 2 Strings concatenated with + simbol. This report error.
Incorrect, you are trying to concatenate two strings, not two Strings. The compiler interprets the string surrounded by quotes as a string, not a String. Pick Strings (Zoomkat's recommendation) or strings (everybody else's recommendation) and stick with it.
Hey davekw7x, I hope this reply isn't too late and gets buried, but this is my first post. I am new to Arduino and I was going through some documentation, and just playing around and practicing. I was playing with the StringAddition operator, and there is code on that page that shows how to concatenate strings. I didn't copy all of the code verbatim, just typed up some of the necessary parts the program needed, and make a bare bones version. I attached an image of what my program has and what the serial monitor reads after the code is executed. I tried messing around with different uses of print and println, removing the new lines, trying different strings and the first line is always never correctly printed to the serial monitor. This is the thread I found that this subject was most on topic. I apologize if I shouldn't have posted in this thread for this topic, I don't even know if this is where I should post this question! I hope to hear your reply!!
nrtyc4:
Hey davekw7x, I hope this reply isn't too late and gets buried, but this is my first post. I am new to Arduino and I was going through some documentation, and just playing around and practicing. I was playing with the StringAddition operator, and there is code on that page that shows how to concatenate strings. I didn't copy all of the code verbatim, just typed up some of the necessary parts the program needed, and make a bare bones version. I attached an image of what my program has and what the serial monitor reads after the code is executed. I tried messing around with different uses of print and println, removing the new lines, trying different strings and the first line is always never correctly printed to the serial monitor. This is the thread I found that this subject was most on topic. I apologize if I shouldn't have posted in this thread for this topic, I don't even know if this is where I should post this question! I hope to hear your reply!!
Blimey... I haven't seen a TIFF file in active use for about 20 years!
In this forum we don't post images of code, we post actual code - copy it and paste it between [ code ] [ /code ] tags.
If you have a specific problem with a piece if code it is usually best to start a new forum topic with your code in it, along with what you expect to get out of it, and what you actually get out of it, rather than adding on at the end of someone else's topic (albeit a similar topic).