trying to experiment with Wemos D1 and LM35. Need to have temperature reading on the ESP IP. Found the following project to be exactly matching my requirements but I am having certain errors in it. Since, I am not that expert with C programming, hence I am unable to resolve the issues and the website admins are also not replying. If you can please help get this program work or point me to some other source. (There are a lot which involve thingspeak.com but I do not want that. A simple WiFi connection to ESP through mobile and get the data on the esp server IP page which is in Wemos.)

Here is the link, http://blog.circuits4you.com/2016/03/web-server-data-logger.html

First error I get is "temp is not declared". If I declare temp as int then the compiler gives error on spnprintf statement saying "Invalid conversion from int to char*". Tried to read snprintf reference but could not understand the error. Perhaps there will be more errors after this line too. Kindly help.

  • Read into this. Your code gets an error and it literally describes what's happening: look into it. I'm also voting to close this question because it does not relate to Arduino, it relates to C++ and programming in general.
    – Len
    Sep 22, 2016 at 10:27

2 Answers 2


It's expecting buffer to write all that data: char temp[400];. The snprintf writes at most 399 characters and termination character '\0'. And nobody cares that it generates ugly html:

  char temp[400];
  snprintf ( temp, 400,
    "<meta http-equiv='refresh' content='5'/>"
    "<title>Circuits4You.com Temperature Monitoring Server Demo</title>"
      "body { background-color: #cccccc; font-family: Arial, Helvetica, Sans-Serif; Color: #000088; }"
    "<p>Temperature: %04d</p>"
"</html>", analog

It seems like you haven't declared the variable 'temp' from the line

server.send ( 200, "text/html", temp );

It should work fine if you declare it.

  • 1
    I already said that I declared temp as int later on. Then I am getting the second error on snprintf. Sep 19, 2016 at 21:27
  • You can't declare variables "later on". They have to be declared before they are used.
    – Nick Gammon
    Sep 20, 2016 at 6:39
  • 1
    by later on i meant after executing the program first time...it gave the variable declaration error so I declared it. Later on did not mean later on in the program :D Sep 22, 2016 at 0:16
  • 1
    and is it working now?
    – krishna
    Sep 22, 2016 at 13:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.