Hello I am very new to Arduino Developing. Generally I am developing iOS Apps. I have Arduino Uno R3 and ESP8266-01 Module. I want to connect my arduino board with my wifi network through ESP8266-01. I have schematic is like this:
Arduino -> ESP8266
power 3.3V -> vcc , CH_PD
ground -> ground
pin2 -> rx
pin3 -> tx
Now I have installed ESP8266 Library to Arduino Board from http://arduino.esp8266.com/stable/package_esp8266com_index.json
My arduino program is like this:
#include <ESP8266WiFi.h>
const char* ssid = "your-ssid";
const char* password = "your-password";
int ledPin = 2; // GPIO2
WiFiServer server(80);
void setup() {
Serial.begin(115200);
delay(10);
pinMode(ledPin, OUTPUT);
digitalWrite(ledPin, LOW);
// Connect to WiFi network
Serial.println();
Serial.println();
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");
// Start the server
server.begin();
Serial.println("Server started");
// Print the IP address
Serial.print("Use this URL to connect: ");
Serial.print("http://");
Serial.print(WiFi.localIP());
Serial.println("/");
}
void loop() {
// Check if a client has connected
WiFiClient client = server.available();
if (!client) {
return;
}
// Wait until the client sends some data
Serial.println("new client");
while(!client.available()){
delay(1);
}
// Read the first line of the request
String request = client.readStringUntil('\r');
Serial.println(request);
client.flush();
// Match the request
int value = LOW;
if (request.indexOf("/LED=ON") != -1) {
digitalWrite(ledPin, HIGH);
value = HIGH;
}
if (request.indexOf("/LED=OFF") != -1) {
digitalWrite(ledPin, LOW);
value = LOW;
}
// Set ledPin according to the request
//digitalWrite(ledPin, value);
// Return the response
client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println(""); // do not forget this one
client.println("<!DOCTYPE HTML>");
client.println("<html>");
client.print("Led pin is now: ");
if(value == HIGH) {
client.print("On");
} else {
client.print("Off");
}
client.println("<br><br>");
client.println("Click <a href=\"/LED=ON\">here</a> turn the LED on pin 2 ON<br>");
client.println("Click <a href=\"/LED=OFF\">here</a> turn the LED on pin 2 OFF<br>");
client.println("</html>");
delay(1);
Serial.println("Client disonnected");
Serial.println("");
}
When I compile my code I am getting error:
In file included from /Users/Mohak/Documents/Arduino/libraries/ESP8266WiFi/src/ESP8266WiFi.h:39:0, from /Users/Mohak/Desktop/sohan Demos/Arduino Sketches/wifiweb_Server/wifiweb_Server.ino:1: /Users/Mohak/Documents/Arduino/libraries/ESP8266WiFi/src/WiFiClient.h:24:18: fatal error: memory: No such file or directory #include ^ compilation terminated. exit status 1 Error compiling.
Please help me to solve this problem or give me any other correct path to connect my arduino board with my wifi network. any help would be appreciated. sorry for my bad english and thanks in advance. :)