Chat freely about anything...

User avatar
By Sirquil
#84322 Added four, new iframes generated by "ThingSpeak.com." Program now does not compile.
Only change from the last good compile was adding the iframes.

Compiler error is: "stray error in program."

Code: Select all // Check the action to see if it was a GET request.
                         else if (strcmp(path, "/Graphs") == 0)   // Respond with the path that was accessed.
                         {

                              //delayTime =1000;

                              // First send the success response code.
                              client.println("HTTP/1.1 200 OK");
                              client.println("Content-Type: html");
                              client.println("Connnection: close");
                              client.println("Server: ESP32");
                              // Send an empty line to signal start of body.
                              client.println("");
                              // Now send the response data.
                              // output dynamic webpage
                              client.println("<!DOCTYPE HTML>");
                              client.println("<html>");
                              client.println("<body>");
                              client.println("<head><title>Graphed Weather Observations</title></head>");
                              // add a meta refresh tag, so the browser pulls again every 15 seconds:
                              //client.println("<meta http-equiv=\"refresh\" content=\"15\">");
                              client.println("<br>");
                              client.println("<h2>Graphed Weather Observations</h2><br>");
                              client.println("<p>");
                              client.println("<frameset rows='30%,70%' cols='33%,34%'>");
                              client.println("<iframe width="450" height="260" style="border: 1px solid #cccccc;" src="https://thingspeak.com/channels/290421/charts/1?bgcolor=%23ffffff&color=%23d62020&dynamic=true&results=60&title=Temperature&type=line&xaxis=Date+and+Time&yaxis=Temperature+++++%C2%B0+F."></iframe>");
                              client.println("<iframe width="450" height="260" style="border: 1px solid #cccccc;" src="https://thingspeak.com/channels/290421/charts/2?bgcolor=%23ffffff&color=%23d62020&dynamic=true&results=60&title=Relative+Humidity&type=line&xaxis=Date+and+Time&yaxis=Relative+Humidity++%25"></iframe>");
                              client.println("<br>");
                              client.println("<br>");
                              delayTime = 200;
                              client.println("</frameset>");
                              client.println("<frameset rows='30%,70%' cols='33%,34%'>");
                              client.println("<iframe width="450" height="260" style="border: 1px solid #cccccc;" src="https://thingspeak.com/channels/290421/charts/3?bgcolor=%23ffffff&color=%23d62020&dynamic=true&results=60&title=Barometric+Pressure&type=line&xaxis=Date+and+Time&yaxis=Pressure+++inHg"></iframe>");
                              client.println("<iframe width="450" height="260" style="border: 1px solid #cccccc;" src="https://thingspeak.com/channels/290421/charts/4?bgcolor=%23ffffff&color=%23d62020&dynamic=true&results=60&title=Dew+Point&type=line&xaxis=Date+and+Time&yaxis=Dew+Point++++%C2%B0++F."></iframe>");
                              client.println("<br><br>");
                              client.println("<a href=http://" + publicIP + ":" +  LISTEN_PORT + "/Weather    >Current Observations</a><br>");
                              client.println("<br>");
                              client.println("</p>");
                              client.println("</body>");
                              client.println("</html>");

                              end();

                         }


How do you split code too long for one line?

William
User avatar
By Pablo2048
#84325 William, you forgot to escape some characters. For example:
Code: Select allclient.println("<iframe width="450" height="260" style="border: 1px solid #cccccc;" src="https://thingspeak.com/channels/290421/charts/3?bgcolor=%23ffffff&color=%23d62020&dynamic=true&results=60&title=Barometric+Pressure&type=line&xaxis=Date+and+Time&yaxis=Pressure+++inHg"></iframe>");

is malformed - you have to use \" instead of just " - see:
Code: Select allclient.println("<iframe width=\"450\" height=\"260\" style=\"border: 1px solid #cccccc;\" src=\"https://thingspeak.com/channels/290421/charts/3?bgcolor=%23ffffff&color=%23d62020&dynamic=true&results=60&title=Barometric+Pressure&type=line&xaxis=Date+and+Time&yaxis=Pressure+++inHg\"></iframe>");
User avatar
By Sirquil
#84327 Good Afternoon Pavel,

Earlier project "NTP_Web_Interface_Data_Logger" used iframes from "ThingSpeak.com" that only had to be "copy and pasted" into web server code; they look mostly identical to new iframes, the older, iframes required no escape characters.

Code from "NTP_Web_Interface_Data_Logger":

Code: Select all else if (strcmp(path, "/Graphs") == 0)   // Respond with the path that was accessed.
                    {

                         //delayTime =1000;

                         // First send the success response code.
                         client.println("HTTP/1.1 200 OK");
                         client.println("Content-Type: html");
                         client.println("Connnection: close");
                         client.println("Server: Robotdyn D1 R2");
                         // Send an empty line to signal start of body.
                         client.println("");
                         // Now send the response data.
                         // output dynamic webpage
                         client.println("<!DOCTYPE HTML>");
                         client.println("<html>");
                         client.println("<body>");
                         client.println("<head><title>Graphed Weather Observations</title></head>");
                         // add a meta refresh tag, so the browser pulls again every 15 seconds:
                         //client.println("<meta http-equiv=\"refresh\" content=\"15\">");
                         client.println("<br>");
                         client.println("<h2>Graphed Weather Observations</h2><br>");
                         client.println("<p>");
                         client.println("<frameset rows='30%,70%' cols='33%,34%'>");
                         client.println("<iframe width="450" height="260" style="border: 1px solid #cccccc;" src="https://thingspeak.com/channels/290421/charts/1?bgcolor=%23ffffff&color=%23d62020&dynamic=true&results=60&title=Temperature&type=line&xaxis=Date+and+Time&yaxis=Temperature++F%C2%B0"></iframe>");
                         client.println("<iframe width="450" height="260" style="border: 1px solid #cccccc;" src="https://thingspeak.com/channels/290421/charts/2?bgcolor=%23ffffff&color=%23d62020&dynamic=true&results=60&title=Humidity&type=line&xaxis=Date+and+Time&yaxis=Relative+Humidity++%25"></iframe>");
                         client.println("<br>");
                         client.println("<br>");
                         client.println("<iframe width="450" height="260" style="border: 1px solid #cccccc;" src="https://thingspeak.com/channels/290421/charts/3?bgcolor=%23ffffff&color=%23d62020&dynamic=true&results=60&title=Barometric+Pressure&type=line&xaxis=Date+and+Time&yaxis=Pressure+++inHg"></iframe>");


client.println("<iframe width="450" height="260" style="border: 1px solid #cccccc;" src="https://thingspeak.com/channels/290421/charts/4?bgcolor=%23ffffff&color=%23d62020&dynamic=true&results=60&title=Dew+Point&type=line&xaxis=Date+and+Time&yaxis=Dew+Point++F%C2%B0"></iframe>");
                         delay(200);
                         //client.println("</frameset>");
                         //client.println("<frameset rows='30%,70%' cols='33%,34%'>");
client.println("<iframe width="450" height="260" style="border: 1px solid #cccccc;" src="https://thingspeak.com/channels/290421/charts/3?bgcolor=%23ffffff&color=%23d62020&dynamic=true&results=60&title=Barometric+Pressure&type=line&xaxis=Date+and+Time&yaxis=Pressure+++inHg"></iframe>");
client.println("<iframe width="450" height="260" style="border: 1px solid #cccccc;" src="https://thingspeak.com/channels/290421/charts/4?bgcolor=%23ffffff&color=%23d62020&dynamic=true&results=60&title=Dew+Point&type=line&xaxis=Date+and+Time&yaxis=Dew+Point++F%C2%B0"></iframe>");                         
                         client.println("</frameset>");
                         client.println("<br><br>");
                         client.println("<a href=http://" + publicIP + ":" + LISTEN_PORT + "/Weather    >Current Observations</a><br>");
                         client.println("<br>");
                         client.println("</p>");
                         client.println("</body>");
                         client.println("</html>");

                         end();

                    }


Used the same process on both sets iframes; second iframe set is the one giving the "stray # in program." Will try new iframe with escape characters. Have tried acquiring "fresh" iframes ; thinking first iframes copying process, somehow had failed.

William