Hi!
A couple days ago I bought an arduino uno board with a builtin ESP8266 from jaycar electronics: https://www.jaycar.com.au/uno-with-wi-fi/p/XC4411
However, under the "Downloads" tab you can get a manual describing how to set the DIP switches, as well as some software to test out the board. The code for the ESP8266 is what's throwing me. I'm quite experienced with arduino code (As my earlier posts will show), but this code keeps throwing a compile error. You can download the code yourself from the jaycar website, or just copy it from here
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
#define SERIAL_BAUD 115200 //make sure this is the same in arduino.ino
ESP8266WebServer server(80);
String serialData = "";
//this is our HTML website that we send to the user, much easier to use SPIFFS in future.
const String html_page = "<!DOCTYPE html>"
"<html>"
" <head>"
" <meta name='viewport' content='width=device-width, initial-scale=1.0' />"
" </head>"
" <body>"
" <a href='/ledon'>turn LED on</a>"
" <a href='/ledoff'>turn LED off</a>"
" <h1>Latest data from arduino:</h1>"
" <pre id='reading'></pre>"
" <script>"
" (function() {"
" /* get new data every second*/"
" setInterval(function() {"
" fetch('/reading')"
" .then(response => { return response.text();})"
" .then(text => {"
" document.getElementById('reading').textContent = text;"
" });"
" }, 100);"
" })();"
" </script>"
" </body>"
"</html>";
const IPAddress serverIPAddress(10, 0, 0, 7);
void setup() {
Serial.begin(SERIAL_BAUD);
//here we set up as a hot spot, called XC4411 dual board
WiFi.softAPConfig(serverIPAddress, serverIPAddress, IPAddress(255, 255, 255, 0));
WiFi.softAP("XC4411 Dual Board example code");
//here we set server paramters, the main page is the html_page from above
server.on("/", []() { //send html code, from above
server.send(200, "text/html", html_page);
});
//reading is just a copy of the serial Data
server.on("/reading", []() { //send raw serial data
Serial.println();
Serial.println(serialData);
server.send(200, "text/plain", serialData);
});
server.on("/ledon", []() {
Serial.println("[LEDON]"); //send serial data to arduino
server.send(200, "text/plain", "ok");
});
server.on("/ledoff", []() {
Serial.println("[LEDOFF]"); //send serial data to arduino
server.send(200, "text/plain", "ok");
});
server.on("/ledtoggle", []() {
Serial.println("[LEDTOGGLE]"); //send serial data to arduino
server.send(200, "text/plain", "ok");
});
server.onNotFound(handleNotFound);
server.begin();
}
void loop() {
while (Serial.available()) { char x = Serial.read(); if (x == '\r') { continue; } serialData += x; }
server.handleClient();
}
void handleNotFound() {
String message = "File Not Found\n\n";
message += "URI: ";
message += server.uri();
message += "\nMethod: ";
message += (server.method() == HTTP_GET) ? "GET" : "POST";
message += "\nArguments: ";
message += server.args();
message += "\n";
for (uint8_t i = 0; i < server.args(); i++) {
message += " " + server.argName(i) + ": " + server.arg(i) + "\n";
}
server.send(404, "text/plain", message);
}
Normally I would just test out the example code to see it work, delete it, then start making my own code (I've worked with the ESP8266 before, so it's not that hard). HOWEVER, I cannot for the life of me find out why the compiler is throwing an error. The error shows:
Warning: Board breadboard:avr:atmega328bb doesn't define a 'build.board' preference. Auto-set to: AVR_ATMEGA328BB
In file included from C:\Users\aj200\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.6.3\libraries\ESP8266WebServer\src/ESP8266WebServer-impl.h:30:0,from C:\Users\aj200\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.6.3\libraries\ESP8266WebServer\src/ESP8266WebServer.h:235,
from C:\Users\aj200\Downloads\XC4411-softwareMain\dualcode\esp\esp.ino:3:
C:\Users\aj200\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.6.3\libraries\ESP8266WebServer\src/detail/RequestHandlersImpl.h:67:28: error: expected ')' before '&' token
StaticRequestHandler(FS& fs, const char* path, const char* uri, const char* cache_header)
^
esp:95:1: error: expected '}' at end of input
}
^
esp:95:1: error: expected unqualified-id at end of input
esp:95:1: error: expected '}' at end of input
exit status 1
expected '}' at end of input
I've gone through and checked to make sure the code doesn't have any random unclosed brackets, but nothing shows up. Am I missing something obvious here? I usually am missing the obvious.
Any help would be appreciated.
P.S. I actually work at Jaycar so I can put a note into IT tomorrow stating the issue