noob3
January 12, 2018, 10:04am
#1
really new to arduino.
when trying to compile the given sketch i am getting the following error.
Arduino: 1.8.5 (Windows 7), Board: “Arduino/Genuino Uno”
C:\Users\jay2\Desktop\sketch_jan12a\sketch_jan12a.ino: In function ‘void Send()’:
sketch_jan12a:174: error: unable to find string literal operator ‘operator""http’
webpage = "<a href=“http://circuitdigest.com/ ”;
^
exit status 1
unable to find string literal operator ‘operator""http’
This report would have more information with
“Show verbose output during compilation”
option enabled in File → Preferences.
what can be done with this error?
thanks in advance
sketch_jan12a.ino (3.25 KB)
pert
January 12, 2018, 10:13am
#2
You need to escape the quote in the string literal by adding a backslash before it:
webpage = "<a href=\"http://circuitdigest.com/";
boylesg
January 12, 2018, 10:19am
#3
The only way an arduino can send data to a web page is to write the data into the html as it is transmitting it to the ESP8266.
A rough example would be:
#define serialESP8266 Serial1 // Assuming arduino mega
void sendWebPage()
{
serialESP8266.write(F("<p><font size=\"3\" color=\"red\"><b>SENSOR READINGS</b></font></p>"));
serialESP8266.write(F("<p><font size=\"2\" color=\"blue\">Sensor 1 = "));
serialESP8266.write(analogRead(A0));
serialESP8266.write(F("</font></p>"));
}
Juraj
January 12, 2018, 3:09pm
#4
boylesg:
The only way an arduino can send data to a web page is to write the data into the html as it is transmitting it to the ESP8266.
Not the only way. You can have the static files (html, css, js) elsewhere for example in SPIFFS of the esp or on SD card or on some hosting server. And in Arduino you implement a REST server which returns for example json requested from the script in a webpage.
a snippet from my project:
void handleRestServer() {
NetClient client = restServer.available();
if (!client)
return;
if (client.connected()) {
if (client.available()) {
char buff[100];
buff[client.readBytesUntil('\n', buff, 100)] = 0;
strcpy(msg, buff);
client.flush();
client.println(F("HTTP/1.1 200 OK"));
client.println(F("Content-Type: application/json"));
client.println(F("Connection: close"));
client.println(F("Cache-Control: no-store"));
client.println(F("Access-Control-Allow-Origin: *"));
client.println();
if (strstr(buff, "events.json")) {
events.printJson(client);
} else if (strstr(buff, "alarm.json")) {
printAlarmJson(client);
} else if (strstr(buff, "pumpAlarmReset")) {
if (stopCause == AlarmCause::PUMP) {
stopAlarm();
}
} else if (strstr(buff, "manualRun")) {
manualRunRequest = true;
} else {//if (s.indexOf("index.json") != -1) {
printValuesJson(client);
}
}
}
client.stop();
}
I have the static files in SPIFFS of the esp and a web server on port 80 serves them. The rest server in Arduino is on port 81 so Access-Control-Allow-Origin: * is important.