I try to start my first application with an Arduino Nano V3, combined with an ESP8266-01 with adapter.
Whatever I try, ESP8266WiFi.h will not be installed.
Where can I find this file?
My Program:
/*
PROGRAMNAME:
Name ESP8266_2Lampen-01.ino
Version: 01
Author: Electronics Forum
Website: https://www.electronicsforu.com/electronics-projects/smallest-iot-home-automation-esp8266-01
Created: Unknown
Edited by: xxxx
Modified: 2020-09-25
WHAT DOES THIS PROGRAM:
- The Arduino with ESP8266-01 can receive commands from your telephone via WIFI and do some actions (f.i. activating relays)
HARDWARE:
- Arduino Nano V3
- ESP8266 shield with ESP-01 adapter
- RX of ESP-shield connected to Arduino Nano pin RX
- TX of ESP-shield connected to Arduino Nano pin TX
- VCC of ESP-shield connected to Arduino Nano 5V
- GND of ESP-shield connected to Arduino Nano GND
- Mini USB program cable
TESTED ON:
IDE 1.8.13 and Arduino Nano V3
*/
//====================
//Libraries
#include <ESP8266WiFi.h> // This library helps to provide the functions of the ESP8266
const char* ssid = "xxxxxxxxx-gast"; // Declare your Wi-Fi name here within the double quotes
const char* password = "xxxxxxxxxx"; // Declare your Wi-Fi password here within the double quotes
WiFiServer server(80); // Create an instance of the server and specify the port to listen on as an argument
void setup()
{
Serial.begin(9600); // set baud rate
delay(10);
pinMode(4, OUTPUT); // set GPIO 4 as OUTPUT
pinMode(5, OUTPUT); // set GPIO 5 as OUTPUT
digitalWrite(4, 0); // initially set GPIO 4 as Low
digitalWrite(5, 0); // initially set GPIO 5 as Low
Serial.println();
Serial.println();
Serial.print("Connecting to "); // Connect to WiFi network
Serial.println(ssid);
WiFi.mode(WIFI_STA);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED)
{
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");
server.begin(); // Start the server
Serial.println("Server started");
Serial.println(WiFi.localIP()); // Print the IP address
}
void loop()
{
WiFiClient client = server.available(); // Check if a client has connected
if (!client)
{
return; // Wait until the client sends some data
}
Serial.println("new client");
while(!client.available())
{ delay(1); }
String req = client.readStringUntil('\r'); // Read the first line of the request
Serial.println(req);
client.flush();
int val1;
int val2;
if (req.indexOf("/gpio1/0") != -1) // Match the request
val1 = 1;
else if (req.indexOf("/gpio1/1") != -1)
val1 = 0;
else if (req.indexOf("/gpio2/0") != -1)
val2 = 1;
else if (req.indexOf("/gpio2/1") != -1)
val2 = 0;
else
{
Serial.println("invalid request");
client.stop();
return;
}
digitalWrite(2, val1); // Set GPIO 2 according to the request
digitalWrite(0, val2); // Set GPIO 0 according to the request
client.flush();
String s = "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\n<!DOCTYPE HTML>\r\n<html>"; // Prepare the response
s += "<body><h1>ESP8266 Smallest Home Automation</h1>\r\nGPIO1 is now ";
s += (val1)?"high":"low";
s += "\n GPIO2 is now ";
s += (val2)?"high":"low";
s += "</html>\n";
client.print(s); // Send the response to the client
delay(1);
Serial.println("Client disonnected"); // The client will actually be disconnected and when the function returns and 'client' object is detroyed
}
Error message:
Arduino: 1.8.13 (Windows Store 1.8.42.0) (Windows 10), Board: "Arduino Nano, ATmega328P (Old Bootloader)"
ESP8266_2Lampen-01:31:10: fatal error: ESP8266WiFi.h: No such file or directory
#include <ESP8266WiFi.h> // This library helps to provide the functions of the ESP8266
^~~~~~~~~~~~~~~
compilation terminated.
exit status 1
ESP8266WiFi.h: No such file or directory
This report would have more information with "Show verbose output during compilation" option enabled in File -> Preferences.