0

I want to turn my esp8266 into access point so that i would able to connect directly to it.i use the following sketch but when i select GENERIC module ESP8266 from menu the two libraries which is ESP8266WiFi.h and #include ESP8266WebServer.h become available but at this point i was unable to upload sketch to arduino.Also when i select Board as arduino uno(Which i have really) and then what to upload then the above two files becomes unavailable and says fatal error no such file...no idea what to do next...Thanks in advance for kind attention.

#include <ESP8266wifi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>
#include<WiFi.h>
#include<SoftwareSerial.h>
SoftwareSerial esp(2,3);
IPAddress local_IP(192,168,4,22);
IPAddress gateway(192,168,4,9);
IPAddress subnet(255,255,255,0);
 String ssid="Wisal";
 String pass="12345678";
 ESP8266WebServer server(80);
 boolean isAccessPointCreated=false;
void setup(){
  esp.begin(115200);
  Serial.begin(115200);

  WiFi.mode(WIFI_AP);
  Serial.print("Setting soft-AP configuration ... ");
  Serial.println(WiFi.softAPConfig(local_IP, gateway, subnet) ? "Ready" : "Failed!");

  Serial.print("Setting soft-AP ... ");
  Serial.println(WiFi.softAP("ESPsoftAP_01") ? "Ready" : "Failed!");
  Serial.print("Soft-AP IP address = ");
  Serial.println(WiFi.softAPIP());

}

void loop(){
  while(esp.available()>0){
    char a = esp.read();
      if(a == '\0')
        continue;
      if(a != '\r' && a != '\n' && (a < 32))
        continue;
      Serial.print(a);
   }
}
  • Are you trying upload to an Uno or an ESP8266? The hardware package and libraries you're referring to are for use directly on an ESP8266, not an Uno using an ESP8266 for WiFi communications. – per1234 Feb 25 '17 at 17:38
  • i upload the sketch to arduino uno and the esp8266 is connected to my arduino uno. – mtg Feb 25 '17 at 18:06
2

The ESP8266 core for Arduino that you're trying to use is for programming ESP8266 directly. You are trying to program an Uno with an ESP8266 connected to it for use as a WiFi module. For that application the ESP8266 core is of no use. For your application it's most common to run the AT firmware on the ESP8266 and communicate via serial. If you're doing that I recommend the WiFiEsp library:

https://github.com/bportaluri/WiFiEsp

Since you're uploading to the Uno you should have Arduino/Genuino Uno selected in the Tools > Board menu.

0

There are two ways to use an ESP8266.

Method 1

You seem to say you are using it as a slave to your UNO. You program you Uno from the IDE. The program will have code in it to send 'AT' commands to the ESP and this will make the ESP handle all the WIFI stuff.

Method 2

You remove you Uno and use the ESP as the main processor. This means you get to program the ESP with C++ like code through the IDE, just as if it was an UNO. HOWEVER you will need to install the ESP package from the board manager and there are certain limitations. You also have access to less IO ports, but you can connect the Uno (over serial or I2C) and use it as a slave (which you program through the IDE separately).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.