Arduino (Node MCU) web server syntax issue

Hello all,
Im trying to print a value to the web server however i cannot figure out what the syntax is…

int lightLevel, high = 0, low = 1023;

Here is the code:


Light Level = " + lightLevel + “


It throws this error:

WebServer:140:61: error: invalid operands of types ‘const char*’ and ‘const char [5]’ to binary ‘operator+’

Any help would be amazing!

client.println("<p>Light Level = " + lightLevel + "</p>");

The + operator only works when concatenating Strings (capital S)

Either turn lightLevel into a String or use C style strings (lowercase) throughout and put the fixed text and variable into a buffer using snprintf() then send that


client.printf("<p>Light Level = %d</p>", lightLevel);


client.printf("<p>Light Level = %d</p>", lightLevel);

Nailed it!

Thanks PaulRB