Red board cannot work with my project(Wifi)

From the last topic Red board UNO wifi cannot be sketched - Installation & Troubleshooting - Arduino Forum I can use my what's next red board to run the codes in that topic. Very thanks for Juraj's solution for me to follow this https://whatsnext.shop/make/be-ready-to-start-red to setup my red board.

Now, i encounter new problem about my new project. I have to use my red board's WIFI to send my data into firebase. It is not working on this red board. The error is about ESP8266 Library which i dont understand how to solve this problem. I have already installed ESP8266wifi library. The error message and my codes are below.
Can someone help me out please? Thank you

Note: Before i use this red board, i use this codes for my Wemos D1 mini and there is no error about my ESP8266 library like this. Everything is fine. The data can send into my database.

IDE imagehttps://www.img.in.th/image/VAHwbk

Arduino: 1.8.5 (Windows 10), Board: "red, AVR 328p"

C:\Users\User\Desktop\Project\for_box\for_box.ino:1:25: fatal error: ESP8266WiFi.h: No such file or directory

 #include <ESP8266WiFi.h>

                         ^

compilation terminated.

exit status 1
Error compiling for board red.

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

My codes for this project

#include <ESP8266WiFi.h>
#include <FirebaseArduino.h>
#include <SoftwareSerial.h> //delete
#include <PZEM004T.h>
#include <time.h>

// Config WiFi
#define WIFI_SSID     "Pengg'"
#define WIFI_PASSWORD "pongpeng"

// Config Firebase
#define FIREBASE_HOST "electricity-consumption-da63c.firebaseio.com"
#define FIREBASE_AUTH "Ejp8h9kVUWIsc37hIMZqRVXN1A4Tj9FGMl9WIq5CH"

#ifndef min
#define min(a,b) ((a)<(b)?(a):(b))
#endif

float calBill(float Unit, float ft, bool over_150_Unit_per_month = false) ;

// Config time
int timezone = 7;

// Config bill
#define FIX_FT 0

char ntp_server1[20] = "ntp.ku.ac.th";
char ntp_server2[20] = "fw.eng.ku.ac.th";
char ntp_server3[20] = "time.uni.net.th";

int dst = 0;
unsigned long lastUpdateEnergy = 0, lastUpdateFirebase = 0;
float Volt, Amp, Power;
//unsigned long Energy = 0;
float Energy = 0;
PZEM004T pzem(10, 11);  // (RX,TX) connect to TX,RX of PZEM
IPAddress ip(192, 168, 1, 1);

void setup() {
  Serial.begin(115200);

  Serial.println();
  while (!pzem.setAddress(ip)) {
    Serial.println("Connecting to PZEM...");
    delay(500);
  }

  WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
  Serial.print("connecting");
  while (WiFi.status() != WL_CONNECTED) {
    Serial.print(".");
    delay(500);
  }
  Serial.println();
  Serial.print("connected: ");
  Serial.println(WiFi.localIP());

  configTime(timezone * 3600, dst, ntp_server1, ntp_server2, ntp_server3);
  Serial.println("Waiting for time");
  while (!time(nullptr)) {
    Serial.print(".");
    delay(500);
  }
  Serial.println();
  Serial.println("Now: " + getTime());

  Firebase.begin(FIREBASE_HOST, FIREBASE_AUTH);
}

void loop() {
  if ((millis() - lastUpdateEnergy) >= 1000) {
    lastUpdateEnergy = millis();

    unsigned long startTime = millis();
    Volt = pzem.voltage(ip);
    Volt = Volt > 0 ? Volt : 0;
    Amp = pzem.current(ip);
    Amp = Amp > 0 ? Amp : 0;
    Power = Volt * Amp;
    Energy += Power/3600;
    Serial.print("Load time: ");
    Serial.print(millis() - startTime);
    Serial.println("ms");
    Serial.println("Voltage: " + String(Volt, 2));
    Serial.println("Current: " + String(Amp, 2));
    Serial.println("Power: " + String(Power, 2));
    Serial.println("Energy: " + String(Energy));
    Serial.println("--------------------");
    
  }

  time_t now = time(nullptr);
  struct tm* nowTime = localtime(&now);
  if ((nowTime->tm_sec % 30) == 0) {
    lastUpdateFirebase = millis();

    StaticJsonBuffer<200> jsonBuffer;
    JsonObject& root = jsonBuffer.createObject();
    root["volt"] = Volt;
    root["amp"] = Amp;
    root["time"] = getTime();

    String name = Firebase.push("/logPower", root);
    // handle error
    if (Firebase.failed()) {
      Serial.print("pushing failed:");
      Serial.println(Firebase.error());
      return;
    }
    Serial.print("pushed: /logPower/");
    Serial.println(name);

    Firebase.setInt("/energy", Energy);
    if (Firebase.failed()) {
      Serial.print("pushing failed:");
      Serial.println(Firebase.error());
      return;
    }

    Firebase.setFloat("/amount", calBill(Energy / 1000, FIX_FT, false));
    if (Firebase.failed()) {
      Serial.print("pushing failed:");
      Serial.println(Firebase.error());
      return;
    }
  }

  delay(0); // Disable WDT
}

String getTime() {
  time_t now = time(nullptr);
  struct tm* newtime = localtime(&now);

  String tmpNow = "";
  tmpNow += String(newtime->tm_year + 1900);
  tmpNow += "-";
  tmpNow += String(newtime->tm_mon + 1);
  tmpNow += "-";
  tmpNow += String(newtime->tm_mday);
  tmpNow += " ";
  tmpNow += String(newtime->tm_hour);
  tmpNow += ":";
  tmpNow += String(newtime->tm_min);
  tmpNow += ":";
  tmpNow += String(newtime->tm_sec);
  return tmpNow;
}

float calBill(float Unit, float ft, bool over_150_Unit_per_month) {
  float Service = over_150_Unit_per_month ? 38.22 : 8.19;

  float total = 0;

  if (!over_150_Unit_per_month) {
    float Rate15 = 2.3488;
    float Rate25 = 2.9882;
    float Rate35 = 3.2405;
    float Rate100 = 3.6237;
    float Rate150 = 3.7171;
    float Rate400 = 4.2218;
    float RateMore400 = 4.4217;

    if (Unit >= 0) total += min(Unit, 15) * Rate15;
    if (Unit >= 16) total += min(Unit - 15, 10) * Rate25;
    if (Unit >= 26) total += min(Unit - 25, 10) * Rate35;
    if (Unit >= 36) total += min(Unit - 35, 65) * Rate100;
    if (Unit >= 101) total += min(Unit - 100, 50) * Rate150;
    if (Unit >= 151) total += min(Unit - 150, 250) * Rate400;
    if (Unit >= 401) total += (Unit - 400) * RateMore400;
  } else {
    float Rate150 = 3.2484;
    float Rate400 = 4.2218;
    float RateMore400 = 4.4217;

    total += min(Unit, 150) * Rate150;
    if (Unit >= 151) total += min(Unit - 150, 150) * Rate400;
    if (Unit >= 401) total += (Unit - 400) * RateMore400;
  }

  total += Service;
  total += Unit * (ft / 100);
  total += total * 7 / 100;

  return total;
}

Update

I try changing my #include <ESP8266WiFi.h> to #include <WiFiConn.h> which is library from what's next.

The error is here again...

Arduino: 1.8.5 (Windows 10), Board: "red, AVR 328p"

In file included from C:\Users\User\Desktop\Project\for_box\for_box.ino:4:0:

C:\Users\User\Documents\Arduino\libraries\firebase-arduino-master\src/FirebaseArduino.h:20:18: fatal error: string: No such file or directory

 #include <string>

                  ^

compilation terminated.

exit status 1
Error compiling for board red.

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

the FirebaseArduino library is for esp8266 sketch. you can't use it for Atmega

Juraj:
the FirebaseArduino library is for esp8266 sketch. you can't use it for Atmega

Ok. so any alternative library i can use for this work?

firebase requires SSL secure connection, which is not possible with 8-bit Atmega. this old projects offer some solution GitHub - robertcedwards/httpFirebase: A PHP Solution for Arduino to Firebase

of course you could write a sketch for the esp8266 on the red, but it is simpler to take a standalone esp8266 board like Wemos or NodeMCU and connect the sensor to it.

Juraj:
firebase requires SSL secure connection, which is not possible with 8-bit Atmega. this old projects offer some solution GitHub - robertcedwards/httpFirebase: A PHP Solution for Arduino to Firebase

of course you could write a sketch for the esp8266 on the red, but it is simpler to take a standalone esp8266 board like Wemos or NodeMCU and connect the sensor to it.

Thank you Juraj, the reason why i try using this red because my Wemos randomly resets my electricity consumption data to 0. For example, i can collected the data about 3 days and my electricity charge is around 6-7$. But when the forth day, i look to my realtime database(in firebase) it tells that the charge is around 2$ which can be considered that the data is reseted if not my charge should be more than 6-7$. I thought maybe it is from my Wemos that have to do many things such as recieving data from sensor, calculating the electricity charge and power by V I from sensor and connecting to my firebase database. Maybe wemos flash memory cant handle? so i try changing the harddware first.
Any sugeestion for me Juraj? im so confused and dont know how to fix this resetting problem

freezelle:
Thank you Juraj, the reason why i try using this red because my Wemos randomly resets my electricity consumption data to 0. For example, i can collected the data about 3 days and my electricity charge is around 6-7$. But when the forth day, i look to my realtime database(in firebase) it tells that the charge is around 2$ which can be considered that the data is reseted if not my charge should be more than 6-7$. I thought maybe it is from my Wemos that have to do many things such as recieving data from sensor, calculating the electricity charge and power by V I from sensor and connecting to my firebase database. Maybe wemos flash memory cant handle? so i try changing the harddware first.
Any sugeestion for me Juraj? im so confused and dont know how to fix this resetting problem

how do you save the data on wemos?

if you want to split the work to atmega and esp8266 on red, you would need to write the communication between them over SPI.