Error installing Wifi.h or WifiEsp.h libraries?

When trying to use the #include <WiFi.h> library I get the following errors:

Arduino: 1.8.5 (Windows 10), Board: "NodeMCU 0.9 (ESP-12 Module), 80 MHz, 115200, 4M (3M SPIFFS)"

In file included from C:\Program Files (x86)\Arduino\libraries\WiFi\src\WiFiUdp.cpp:29:0:

C:\Program Files (x86)\Arduino\libraries\WiFi\src\WiFiUdp.h:27:7: error: redefinition of 'class WiFiUDP'

 class WiFiUDP : public UDP {

       ^

In file included from C:\Program Files (x86)\Arduino\libraries\WiFi\src\utility/wifi_drv.h:26:0,

                 from C:\Program Files (x86)\Arduino\libraries\WiFi\src\WiFiUdp.cpp:26:

C:\Users\RyanB96\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0-rc2\libraries\ESP8266WiFi\src/WiFiUdp.h:32:7: error: previous definition of 'class WiFiUDP'

 class WiFiUDP : public UDP, public SList<WiFiUDP> {

       ^

C:\Program Files (x86)\Arduino\libraries\WiFi\src\WiFiUdp.cpp: In constructor 'WiFiUDP::WiFiUDP()':

C:\Program Files (x86)\Arduino\libraries\WiFi\src\WiFiUdp.cpp:35:22: error: class 'WiFiUDP' does not have any field named '_sock'

 WiFiUDP::WiFiUDP() : _sock(NO_SOCKET_AVAIL) {}

                      ^

C:\Program Files (x86)\Arduino\libraries\WiFi\src\WiFiUdp.cpp: In member function 'virtual uint8_t WiFiUDP::begin(uint16_t)':

C:\Program Files (x86)\Arduino\libraries\WiFi\src\WiFiUdp.cpp:45:9: error: '_sock' was not declared in this scope

         _sock = sock;

         ^

C:\Program Files (x86)\Arduino\libraries\WiFi\src\WiFiUdp.cpp:46:9: error: '_port' was not declared in this scope

         _port = port;

         ^

C:\Program Files (x86)\Arduino\libraries\WiFi\src\WiFiUdp.cpp: In member function 'virtual int WiFiUDP::available()':

C:\Program Files (x86)\Arduino\libraries\WiFi\src\WiFiUdp.cpp:56:7: error: '_sock' was not declared in this scope

   if (_sock != NO_SOCKET_AVAIL)

       ^

C:\Program Files (x86)\Arduino\libraries\WiFi\src\WiFiUdp.cpp: In member function 'virtual void WiFiUDP::stop()':

C:\Program Files (x86)\Arduino\libraries\WiFi\src\WiFiUdp.cpp:66:8: error: '_sock' was not declared in this scope

    if (_sock == NO_SOCKET_AVAIL)

        ^

C:\Program Files (x86)\Arduino\libraries\WiFi\src\WiFiUdp.cpp:69:26: error: '_sock' was not declared in this scope

    ServerDrv::stopClient(_sock);

                          ^

C:\Program Files (x86)\Arduino\libraries\WiFi\src\WiFiUdp.cpp: In member function 'virtual int WiFiUDP::beginPacket(IPAddress, uint16_t)':

C:\Program Files (x86)\Arduino\libraries\WiFi\src\WiFiUdp.cpp:88:7: error: '_sock' was not declared in this scope

   if (_sock == NO_SOCKET_AVAIL)

       ^

C:\Program Files (x86)\Arduino\libraries\WiFi\src\WiFiUdp.cpp:90:7: error: '_sock' was not declared in this scope

   if (_sock != NO_SOCKET_AVAIL)

       ^

C:\Program Files (x86)\Arduino\libraries\WiFi\src\WiFiUdp.cpp: In member function 'virtual int WiFiUDP::endPacket()':

C:\Program Files (x86)\Arduino\libraries\WiFi\src\WiFiUdp.cpp:101:32: error: '_sock' was not declared in this scope

  return ServerDrv::sendUdpData(_sock);

                                ^

C:\Program Files (x86)\Arduino\libraries\WiFi\src\WiFiUdp.cpp: In member function 'virtual size_t WiFiUDP::write(const uint8_t*, size_t)':

C:\Program Files (x86)\Arduino\libraries\WiFi\src\WiFiUdp.cpp:111:27: error: '_sock' was not declared in this scope

  ServerDrv::insertDataBuf(_sock, buffer, size);

                           ^

C:\Program Files (x86)\Arduino\libraries\WiFi\src\WiFiUdp.cpp: In member function 'virtual int WiFiUDP::read()':

C:\Program Files (x86)\Arduino\libraries\WiFi\src\WiFiUdp.cpp:125:23: error: '_sock' was not declared in this scope

    ServerDrv::getData(_sock, &b);

                       ^

C:\Program Files (x86)\Arduino\libraries\WiFi\src\WiFiUdp.cpp: In member function 'virtual int WiFiUDP::read(unsigned char*, size_t)':

C:\Program Files (x86)\Arduino\libraries\WiFi\src\WiFiUdp.cpp:137:31: error: '_sock' was not declared in this scope

    if (!ServerDrv::getDataBuf(_sock, buffer, &size))

                               ^

C:\Program Files (x86)\Arduino\libraries\WiFi\src\WiFiUdp.cpp: In member function 'virtual int WiFiUDP::peek()':

C:\Program Files (x86)\Arduino\libraries\WiFi\src\WiFiUdp.cpp:152:22: error: '_sock' was not declared in this scope

   ServerDrv::getData(_sock, &b, 1);

                      ^

C:\Program Files (x86)\Arduino\libraries\WiFi\src\WiFiUdp.cpp: In member function 'virtual IPAddress WiFiUDP::remoteIP()':

C:\Program Files (x86)\Arduino\libraries\WiFi\src\WiFiUdp.cpp:166:25: error: '_sock' was not declared in this scope

  WiFiDrv::getRemoteData(_sock, _remoteIp, _remotePort);

                         ^

C:\Program Files (x86)\Arduino\libraries\WiFi\src\WiFiUdp.cpp: In member function 'virtual uint16_t WiFiUDP::remotePort()':

C:\Program Files (x86)\Arduino\libraries\WiFi\src\WiFiUdp.cpp:176:25: error: '_sock' was not declared in this scope

  WiFiDrv::getRemoteData(_sock, _remoteIp, _remotePort);

                         ^

exit status 1
Error compiling for board NodeMCU 0.9 (ESP-12 Module).

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

When trying to use the #include <WiFiEsp.h> library I get the following errors:

Arduino: 1.8.5 (Windows 10), Board: "NodeMCU 0.9 (ESP-12 Module), 80 MHz, 115200, 4M (3M SPIFFS)"

C:\Users\RyanB96\Documents\Arduino\libraries\WiFiEsp\src\utility\EspDrv.cpp:20:26: fatal error: avr/pgmspace.h: No such file or directory

 #include <avr/pgmspace.h>

                          ^

compilation terminated.

exit status 1
Error compiling for board NodeMCU 0.9 (ESP-12 Module).

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

Anyone know why?

Thanks in advance!

Ryanlb96:
When trying to use the #include <WiFi.h> library I get the following errors:

ESP8266 has its own WiFi library named ESP8266WiFi. The WiFi library is for use with the Arduino WiFi Shield, which is a completely different piece of hardware. So, unless you're using the Arduino WiFi Shield on the ESP8266 (which almost surely would make no sense to do), you should not have the line:

#include <WiFi.h>

in your ESP8266 code.

Ryanlb96:
When trying to use the #include <WiFiEsp.h> library I get the following errors:

The WiFiEsp library is to be used when you have an ESP8266 module running the AT firmware attached to a standard Arduino board (e.g. Uno, Nano, Mega, Leonardo). You would be uploading the code that uses the WiFiEsp library to that Arduino board, not the ESP8266. But you have an ESP8266 board selected and so it doesn't compile (nor would doing so make sense in any case).

I think it's time for you to provide a complete description of what you're attempting to accomplish.

Hi, thank you for the response!

All of that makes sense, so thank you!

I am trying to upload from arduino to SQL database. I think I am almost there, its just creating the "client" for the "client.connect" etc. I cant find the syntax for!

Here is my complete code:

#include <TinyGPS++.h>
#include <SoftwareSerial.h>
#include <ESP8266WiFi.h>
#include <SPI.h>
//#include <WiFly.h>
//#include <Ethernet.h>
//#include <WiFi.h>
//#include <WiFiEsp.h>
//#include <WiFiEspClient.h>
//#include <WiFiEspUdp.h>

// GPS Variables
static const int TXPin = 5; //(RX GPS -> D1(MCU)/TX(MCU)
static const int RXPin = 4; //(TX GPS -> D2(MCU)/RX(MCU)
static const uint32_t GPSBaud = 9600;
int i = 0;
float latitude;
float longitude;
IPAddress ip(192, 168, 0, 11);

// The TinyGPS++ object
TinyGPSPlus gps;

// The serial connection to the GPS device
SoftwareSerial ss(RXPin, TXPin);

//WiFi Variables
const char* ssid = "Pretty Fly for a Wifi";
const char* password = "!153Rolleston153!";
WiFiServer server(80);

Client client(ip,80);

/*//Server Variables
  char hostserver[] = "192.168.0.11";
  unsigned long lastConnectionTime = 0;
  const unsigned long postingInterval = 20UL * 1000UL;
  WiFiClient client; */

void setup()
{
  //Starts GPS modules
  Serial.begin(115200);
  ss.begin(GPSBaud);

  // Connect to WiFi network
  connectwifi();

  // 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("/");

  Serial.println("Setup Complete.");
}



void loop()
{
  /*  while (client.available())
    {
      char c = client.read();
      Serial.write(c);
    }
    // if ten seconds have passed since your last connection,
    // then connect again and send data:
    if (millis() - lastConnectionTime > postingInterval) {
      httpRequest();
    }*/

  Serial.println("\nTest: ");
  Serial.println(1);
  delay(500);
  // This sketch displays information every time a new sentence is correctly encoded.
  while (ss.available() > 0)
    if (gps.encode(ss.read()))
      displayInfo();

  if (millis() > 5000 && gps.charsProcessed() < 10)
  {
    Serial.println(F("No GPS detected: check wiring."));
    while (true);
  }
  i++;

  if (client.connect())
  {
    client.print("GET /send_data.php?latitude=");
    client.print(latitude);
    client.print("&longitude=");
    client.print(longitude);
    client.println(" HTTP/1.1");
    client.println("Host: 192.168.0.11"); // SERVER ADDRESS
    client.println( "Content-Type: text/php" );
    client.println("Connection: close");
    client.println();
    client.println();
  }
  delay(5000);
}

void displayInfo()
{
  Serial.print(F("Location: "));
  if (gps.location.isValid())
  {
    latitude = gps.location.lat();
    longitude = gps.location.lng();
    Serial.print(gps.location.lat(), 6);
    Serial.print(F(","));
    Serial.print(gps.location.lng(), 6);
  }
  else
  {
    Serial.print(F("INVALID"));
  }
  Serial.println();
}


void connectwifi() {
  Serial.println();
  Serial.println();
  Serial.print("Connecting to ");
  Serial.println(ssid);
  WiFi.begin(ssid, password);

  while (WiFi.status() != WL_CONNECTED)
  {
    delay(500);
    Serial.print("\nAttempting to Connect..");
  }
  //Acknowledge the connection
  Serial.println("");
  Serial.println("WiFi connected to");
  Serial.println(ssid);
}

What is your hardware configuration? Are you using only a NodeMCU board or do you have it connected to a standard Arduino board?

NodeMCU board! I thought I had cracked it - but although my code now compiles and seems to work - it doesnt actually add to my database?

#include <TinyGPS++.h>
#include <SoftwareSerial.h>
#include <ESP8266WiFi.h>
#include <SPI.h>

// GPS Variables
static const int TXPin = 5; //(RX GPS -> D1(MCU)/TX(MCU)
static const int RXPin = 4; //(TX GPS -> D2(MCU)/RX(MCU)
static const uint32_t GPSBaud = 9600;
int i = 0, x = 0, loop1 = 0;
float latitude;
float longitude;

// The TinyGPS++ object
TinyGPSPlus gps;

// The serial connection to the GPS device
SoftwareSerial ss(RXPin, TXPin);

//WiFi Variables
const char* ssid = "Pretty Fly for a Wifi";
const char* password = "!153Rolleston153!";
WiFiServer server(80);



//Server Variables
const char* host = "192.168.0.11";
WiFiClient client;



void setup()
{
  //Starts GPS modules
  Serial.begin(115200);
  ss.begin(GPSBaud);

  // Connect to WiFi network
  connectwifi();

  // 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("/");

  Serial.println("Setup Complete.");
}



void loop()
{
  Serial.println("\nTest: ");
  Serial.println(i);
  delay(500);

  while (ss.available() < 0)
  {
  }
  // This sketch displays information every time a new sentence is correctly encoded.
  while (ss.available() > 0)
    if (gps.encode(ss.read()))
    {
      displayInfo();
    }
    else
    {
      Serial.println("Data not encoded");
    }

  if (millis() > 5000 && gps.charsProcessed() < 10)
  {
    Serial.println(F("No GPS detected: check wiring."));
    while (true);
  }
  i++;

  if (x == 10)
    while (1) {
      Serial.println("LOOP STUCK");
    }
}


void displayInfo()
{
  Serial.print(F("Location: "));
  if (gps.location.isValid())
  {
    latitude = gps.location.lat();
    longitude = gps.location.lng();
    Serial.print(gps.location.lat(), 6);
    Serial.print(F(", "));
    Serial.print(gps.location.lng(), 6);
    if (client.connect(host, 80))
    {

      Serial.println("\nAdding to database...");

      client.print("GET / send_data.php ? latitude = ");
      client.print(latitude);
      client.print("&longitude = ");
      client.print(longitude);
      client.println(" HTTP / 1.1");
      client.println("Host : 192.168.0.11"); // SERVER ADDRESS
      client.println( "Content - Type : text / php" );
      client.println("Connection : close");
      client.println();
      client.println();
      x++;
    }
    delay(5000);
  }
  else
  {
    Serial.print(F("INVALID"));
  }
  Serial.println();
}

void connectwifi() {
  Serial.println();
  Serial.println();
  Serial.print("Connecting to ");
  Serial.println(ssid);
  WiFi.begin(ssid, password);

  while (WiFi.status() != WL_CONNECTED)
  {
    delay(500);
    Serial.print("\nAttempting to Connect..");
  }
  //Acknowledge the connection
  Serial.println("");
  Serial.printf("\nConnected to the host : % s...", host);
}