-
Notifications
You must be signed in to change notification settings - Fork 210
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Not working with Arduino Zero #55
Comments
Please, may you paste your full code? |
Hello, this is the code I am using: #include "WiFiEsp.h"
char ssid[] = "TwimEsp"; // your network SSID (name)
char pass[] = "12345678"; // your network password
int status = WL_IDLE_STATUS; // the Wifi radio's status
int reqCount = 0; // number of requests received
WiFiEspServer server(80);
// use a ring buffer to increase speed and reduce memory allocation
WifiEspRingBuffer buf(8);
void setup()
{
Serial.begin(115200); // initialize serial for debugging
Serial1.begin(9600); // initialize serial for ESP module
WiFi.init(&Serial1); // initialize ESP module
// check for the presence of the shield
if (WiFi.status() == WL_NO_SHIELD) {
Serial.println("WiFi shield not present");
while (true); // don't continue
}
Serial.print("Attempting to start AP ");
Serial.println(ssid);
// uncomment these two lines if you want to set the IP address of the AP
//IPAddress localIp(192, 168, 111, 111);
//WiFi.configAP(localIp);
// start access point
status = WiFi.beginAP(ssid, 10, pass, ENC_TYPE_WPA2_PSK);
Serial.println("Access point started");
printWifiStatus();
// start the web server on port 80
server.begin();
Serial.println("Server started");
}
void loop()
{
WiFiEspClient client = server.available(); // listen for incoming clients
if (client) { // if you get a client,
Serial.println("New client"); // print a message out the serial port
buf.init(); // initialize the circular buffer
while (client.connected()) { // loop while the client's connected
if (client.available()) { // if there's bytes to read from the client,
char c = client.read(); // read a byte, then
buf.push(c); // push it to the ring buffer
// you got two newline characters in a row
// that's the end of the HTTP request, so send a response
if (buf.endsWith("\r\n\r\n")) {
sendHttpResponse(client);
break;
}
}
}
// give the web browser time to receive the data
delay(10);
// close the connection
client.stop();
Serial.println("Client disconnected");
}
}
void sendHttpResponse(WiFiEspClient client)
{
client.print(
"HTTP/1.1 200 OK\r\n"
"Content-Type: text/html\r\n"
"Connection: close\r\n" // the connection will be closed after completion of the response
"Refresh: 20\r\n" // refresh the page automatically every 20 sec
"\r\n");
client.print("<!DOCTYPE HTML>\r\n");
client.print("<html>\r\n");
client.print("<h1>Hello World!</h1>\r\n");
client.print("Requests received: ");
client.print(++reqCount);
client.print("<br>\r\n");
client.print("Analog input A0: ");
client.print(analogRead(0));
client.print("<br>\r\n");
client.print("</html>\r\n");
}
void printWifiStatus()
{
// print your WiFi shield's IP address
IPAddress ip = WiFi.localIP();
Serial.print("IP Address: ");
Serial.println(ip);
// print where to go in the browser
Serial.println();
Serial.print("To see this page in action, connect to ");
Serial.print(ssid);
Serial.print(" and open a browser to http://");
Serial.println(ip);
Serial.println();
} I simply modify the sample "WebServerAP". But to me by the error I wrote above. |
Try add |
I'll try soon and let you know. 2016-10-09 19:44 GMT+02:00 Xu Yiming [email protected]:
|
Hello, |
About to try it on my Due. |
Tested and fine with my Due. |
I'm trying this library with an Arduino Zero but does not work for me. I tried to solve with the solution #27 but I get this compile error:
How can I fix the problem?
The text was updated successfully, but these errors were encountered: