Trying to create a web server to send data with ESP8266 and Arduino Uno R3

I am using the Arduino Uno R3 to store audio data into an SD card and then send the data with Wifi. this is the code I am using to create the web server:

#include <SoftwareSerial.h>
#include <SD.h>
#include <SPI.h>
#include <TMRpcm.h>
#include <ESPAsyncWebServer.h> // Include the AsyncWebServer library

SoftwareSerial client(2, 3); // RX, TX

String webpage = "";

int i = 0, k = 0;

String readString;

int x = 0;

boolean No_IP = false;

String IP = "";

char temp1 = '0';

String name = "<p>Circuit Digest</p>"; // 22

String dat = "<p>Data Received Successfully.....</p>"; // 21

AsyncWebServer server(80); // Create an AsyncWebServer instance

void check4IP(int t1)
{
  int t2 = millis();
  while (t2 + t1 > millis())
  {
    while (client.available() > 0)
    {
      if (client.find("WIFI GOT IP"))
      {
        No_IP = true;
      }
    }
  }
}

void get_ip()
{
  IP = "";
  char ch = 0;
  while (1)
  {
    client.println("AT+CIFSR");
    while (client.available() > 0)
    {
      if (client.find("STAIP,"))
      {
        delay(10000);
        Serial.print("IP Address:");
        while (client.available() > 0)
        {
          ch = client.read();
          if (ch == '+')
            break;
          IP += ch;
        }
      }
      if (ch == '+')
        break;
    }
    if (ch == '+')
      break;
    delay(10000);
  }
  Serial.print(IP);
  Serial.print("Port:");
  Serial.println(333);
}

void connect_wifi(String cmd, int t)
{
  int temp = 0, i = 0;
  while (1)
  {
    Serial.println(cmd);
    client.println(cmd);
    while (client.available())
    {
      if (client.find("OK"))
        i = 8;
    }
    delay(t);
    if (i > 5)
      break;
    i++;
  }
  if (i == 8)
    Serial.println("OK");
  else
    Serial.println("Error");
}

void wifi_init()
{
  connect_wifi("AT", 100);
  connect_wifi("AT+CWMODE=3", 100);
  connect_wifi("AT+CWQAP", 100);
  connect_wifi("AT+RST", 5000);
  check4IP(5000);
  if (!No_IP)
  {
    Serial.println("Connecting Wifi....");
    connect_wifi("AT+CWJAP_CUR=\"The Matrix\",\"Rogers1021\"", 7000); // provide your WiFi username and password here
    // connect_wifi("AT+CWJAP=\"vpn address\",\"wireless network\"",7000);
  }
  else
  {
  }
  Serial.println("Wifi Connected");
  get_ip();
  connect_wifi("AT+CIPMUX=1", 100);
  connect_wifi("AT+CIPSERVER=1,333", 100);
}

void sendwebdata(String webPage)
{
  int ii = 0;
  while (1)
  {
    unsigned int l = webPage.length();
    Serial.print("AT+CIPSEND=0,");
    client.print("AT+CIPSEND=0,");
    Serial.println(l + 2);
    client.println(l + 2);
    delay(100);
    Serial.println(webPage);
    client.println(webPage);
    while (client.available())
    {
      // Serial.print(Serial.read());
      if (client.find("OK"))
      {
        ii = 11;
        break;
      }
    }
    if (ii == 11)
      break;
    delay(100);
  }
}

void setup()
{
  Serial.begin(115200);
  client.begin(115200);
  wifi_init();
  Serial.println("System Ready..");

  // Initialize the SD card
  if (!SD.begin(4)) {  
    Serial.println("SD failed"); 
    return;
  } else {
    Serial.println("SD OK"); 
  }

  // Set up a route for serving the audio file
  server.on("/playaudio", HTTP_GET, [](AsyncWebServerRequest *request) {
    request->send(SD, "/test2.wav", "audio/wav");
  });

  // Start the web server
  server.begin();
}

void loop()
{
}

I am currently getting an error that is:

  1. In file included from C:\Users\Shane\Desktop\Fourth Year\ELE 70A\code\Automatic_Wifi\Automatic_Wifi.ino:5:0: c:\Users\Shane\Documents\Arduino\libraries\AsyncTCP\src/AsyncTCP.h:26:10: fatal error: sdkconfig.h: No such file or directory
    #include "sdkconfig.h"
    ^~~~~~ ~~~~~ ~~

compilation terminated.
exit status 1

Compilation error: exit status 1

I have tried downloading a sdkconfig.h file into the directory and reinstalling the ESP8266 core, none of which have worked. Does anyone have any idea/solutions for this? Thank you.

regarding ESPAsyncWebServer

For ESP8266 it requires ESPAsyncTCP To use this library you might need to have the latest git versions of ESP8266Arduino Core

For ESP32 it requires AsyncTCP to work To use this library you might need to have the latest git versions of ESP32Arduino Core

have this at the start of your include section

#ifdef ESP32
#include <WiFi.h>
#include <AsyncTCP.h>
#elif defined(ESP8266)
#include <ESP8266WiFi.h>
#include <ESPAsyncTCP.h>
#endif
#include <ESPAsyncWebServer.h>

that will include the right stuff

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.