Esp2866 wifi command doubts from Arduino

I have been reading several documentation and I got lost on how to connect the esp2866 esp-01 wifi module.

I was under the impression that I could use the following API ESP8266WiFi library — ESP8266 Arduino Core 2.7.2-10-g2843a5ac documentation in my arduino code and call it in my Arduino program.

#include <ESP8266WiFi.h>
 
const char* ssid     = "my-ssid";
const char* password = "my-password";
 

void setup() {
  Serial.begin(115200);
  // We start by connecting to a 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(".");
  }
}

If I set my Board -> Arduino Uno, I am getting this error

exit status 1
ESP8266WiFi.h: No such file or directory

Does it mean that the only way to connect thru the internet thru the ESP2866 is thru the use of the AT command and sending it like this in Arduino?

void loop() {
 valSensor = getSensorData();
 String getData = "GET /update?api_key="+ API +"&"+ field +"="+String(valSensor);
sendCommand("AT+CIPMUX=1",5,"OK");
 sendCommand("AT+CIPSTART=0,\"TCP\",\""+ HOST +"\","+ PORT,15,"OK");
 sendCommand("AT+CIPSEND=0," +String(getData.length()+4),4,">");
 esp8266.println(getData);delay(1500);countTrueCommand++;
 sendCommand("AT+CIPCLOSE=0",5,"OK");
}
int getSensorData(){
  return random(1000); // Replace with 
}
void sendCommand(String command, int maxTime, char readReplay[]) {
  Serial.print(countTrueCommand);
  Serial.print(". at command => ");
  Serial.print(command);
  Serial.print(" ");
  while(countTimeCommand < (maxTime*1))
  {
    esp8266.println(command);//at+cipsend
    if(esp8266.find(readReplay))//ok
    {
      found = true;
      break;
    }
  
    countTimeCommand++;
  }
  
  if(found == true)
  {
    Serial.println("OYI");
    countTrueCommand++;
    countTimeCommand = 0;
  }
  
  if(found == false)
  {
    Serial.println("Fail");
    countTrueCommand = 0;
    countTimeCommand = 0;
  }
  
  found = false;
 }

I was under the impression that I can call the esp2866 library in my arduino code.

Is my understanding correct or am I missing something?

Is my understanding correct or am I missing something?

No, your understanding is not correct. You use the ESP8266WiFi library if you program the ESP8266 itself using the Arduino IDE. If you use the ESP-01 firmware you access the ESP from another microcontroller (p.e. an Arduino) but there you have to use the AT commands to access the features and you don't have all the options you have if you program the ESP8266 directly.

Even with the I/O limitations of the ESP-01 (four pins), it is almost always more useful to use it as the primary microcontroller and do away with any other Arduino. Using 2 pins for I2C allows you to connect many expander boards for I/O and sensors.

It is easy to swap back and forth between a programming adaptor and your target system with its 8-pin header. :grinning:

The "AT" command interface is just a pain! :astonished: