is it ok to use Serial.print("text" + String(variable))??

Hi
I’m using nodemcu E12 esp8266
as in the title is ( Serial.print(“text” + String(variable)) ) correct?
the variable could be int, double, unsigned long, or uint8_t… no char

but i am getting errors not sure is it because of this way i use in serial.print ?

the error message is:

Soft WDT reset

ctx: cont
sp: 3ffffc20 end: 3fffffd0 offset: 01b0

stack>>>
3ffffdd0: 00000034 0000000a 3ffef774 402057bc
3ffffde0: 3ffffe80 7fffffff 00000000 40205995
3ffffdf0: 3ffffe2e 00000010 00000000 40100575
3ffffe00: 3ffe980d 3ffe944d 3ffffe2d 40205a81
3ffffe10: 3ffef8f8 00000434 00000434 0000002d
3ffffe20: 00000010 3ffffec0 3ffffec0 0000002e
3ffffe30: 3ffef710 00000007 3ffef774 3ffe84f4
3ffffe40: 00000000 0000002e 3ffef774 402057bc
3ffffe50: 3ffe97fc 00000000 3ffffec0 40205995
3ffffe60: 3ffe8988 0000002e 3ffef774 402059c0
3ffffe70: 3ffef8f8 00000000 3ffef774 402059a8
3ffffe80: 3ffffecc 0000002e 3ffef774 402031cc
3ffffe90: 3ffef70c 00000000 3ffef774 40205e50
3ffffea0: 3ffffecc 00000000 3ffef774 0000002e
3ffffeb0: 3ffef710 00000000 3ffef774 40203271
3ffffec0: 00000000 00000000 00000000 00000000
3ffffed0: 00000000 00000000 00000000 00000000
3ffffee0: 00000000 3ffef774 3ffef6b5 40205995
3ffffef0: 00000000 3ffef6a8 3ffef774 402059c0
3fffff00: 3ffeff84 40204230 3ffef774 00000000
3fffff10: 3ffef700 3ffef6a8 3ffef774 40203e8f
3fffff20: 00000000 00000000 00000000 00000000
3fffff30: 00000000 00000000 3ffef774 3ffe8988
3fffff40: 3ffef74c 00000002 3ffef774 402057bc
3fffff50: 3ffe97fc 3ffef774 00000002 40205995
3fffff60: 3ffe97fc 3ffe8988 3ffef774 402059c0
3fffff70: 3ffeff84 40204230 3ffef774 402059c0
3fffff80: 3ffef74c 00000002 3ffef774 40202ebc
3fffff90: feefeffe feefeffe feefeffe feefeffe
3fffffa0: 00000000 00000000 00000001 3ffef7bc
3fffffb0: 3fffdad0 00000000 3ffef7b4 4020636c
3fffffc0: feefeffe feefeffe 3ffe860c 40100721
<<<stack<<<

then restart

(deleted)

Or preferably

Serial.print("text");
Serial.print(variable);

:slight_smile:

(deleted)

From what I've found, you can pass a single C string to print, or a String object, or you can concatenate various scalars with Strings using the + operator.

So you'd want

Serial.print(String("text") + variable)

So you'd want

Serial.print(String("text") + variable)

Personally I think that you would not want to use Strings at all

The NodeMCU seems to reset during execution. This means that the compiler accepted the code, then the syntax the OP proposed should be correct, no?
The error must come from something else…

lesept:
The NodeMCU seems to reset during execution. This means that the compiler accepted the code, then the syntax the OP proposed should be correct, no?
The error must come from something else...

yeah i found that i must use delay() or yeild() with every while and for loops

the Serial.print("text" + String(variable)) has not shown any problem yet

thank you all guys

(deleted)