Compilation fails with "not declared in this scope" errors for several function calls in sketch

I have this problem:
Arduino: 1.8.18 (Windows 10), Board: "Generic ESP8266 Module, 80 MHz, Flash, Disabled (new aborts on oom), Disabled, All SSL ciphers (most compatible), 32KB cache + 32KB IRAM (balanced), Use pgm_read macros for IRAM/PROGMEM, dtr (aka nodemcu), 26 MHz, 40MHz, DOUT (compatible), 1MB (FS:64KB OTA:~470KB), 2, nonos-sdk 2.2.1+100 (190703), v2 Lower Memory, Disabled, None, Only Sketch, 115200"

C:\Users\oboeh\OneDrive\Dokumente\Arduino\sketch_aug19b\sketch_aug19b.ino: In function 'void setup()':

sketch_aug19b:81:2: error: 'initWiFi' was not declared in this scope

81 | initWiFi(); //initializes WiFi

  |  ^~~~~~~~

sketch_aug19b:82:3: error: 'initFS' was not declared in this scope; did you mean 'init'?

82 | initFS(); //initializes filesystem

  |   ^~~~~~

  |   init

sketch_aug19b:83:3: error: 'loadFSValues' was not declared in this scope

83 | loadFSValues(); //loads initial values from filesystem

  |   ^~~~~~~~~~~~

C:\Users\oboeh\OneDrive\Dokumente\Arduino\sketch_aug19b\sketch_aug19b.ino: In lambda function:

sketch_aug19b:97:18: error: 'getCurrentInputValues' was not declared in this scope

97 | String json = getCurrentInputValues();

  |                  ^~~~~~~~~~~~~~~~~~~~~

C:\Users\oboeh\OneDrive\Dokumente\Arduino\sketch_aug19b\sketch_aug19b.ino: In lambda function:

sketch_aug19b:115:11: error: 'writeFile' was not declared in this scope

115 | writeFile(LittleFS, alignmentPath, alignment.c_str());

  |           ^~~~~~~~~

sketch_aug19b:125:11: error: 'writeFile' was not declared in this scope

125 | writeFile(LittleFS, speedsliderPath, speedslider.c_str());

  |           ^~~~~~~~~

sketch_aug19b:135:11: error: 'writeFile' was not declared in this scope

135 | writeFile(LittleFS, devicemodePath, devicemode.c_str());

  |           ^~~~~~~~~

C:\Users\oboeh\OneDrive\Dokumente\Arduino\sketch_aug19b\sketch_aug19b.ino: In function 'void loop()':

sketch_aug19b:170:7: error: 'showNewData' was not declared in this scope

170 | showNewData(input1);

  |       ^~~~~~~~~~~

sketch_aug19b:172:7: error: 'showDate' was not declared in this scope

172 | showDate();

  |       ^~~~~~~~

sketch_aug19b:174:7: error: 'showClock' was not declared in this scope

174 | showClock();

  |       ^~~~~~~~~

Multiple libraries were found for "ESPAsyncTCP.h"

Used: C:\Users\oboeh\OneDrive\Dokumente\Arduino\libraries\ESPAsyncTCP

Not used: C:\Users\oboeh\OneDrive\Dokumente\Arduino\libraries\ESPAsyncTCP-master

exit status 1

'initWiFi' was not declared in this scope

can anyone help me please this is the code:

/*********
  Split Flap ESP Master
*********/
#include <Arduino.h>
#include <ESP8266WiFi.h>
#include <ESPAsyncTCP.h>
#include <ESPAsyncWebServer.h>
#include "LittleFS.h"
#include <Arduino_JSON.h>
#include <Wire.h>
#include <NTPClient.h>
#include <WiFiUdp.h>
#include <ezTime.h>


#define BAUDRATE 115200
#define ANSWERSIZE 1 //Size of unit's request answer
#define UNITSAMOUNT 10 //Amount of connected units !IMPORTANT!
#define FLAPAMOUNT 45 //Amount of Flaps in each unit
#define MINSPEED 1 //min Speed
#define MAXSPEED 12 //max Speed
#define ESPLED 1 //Blue LED on ESP01
//#define serial //uncomment for serial debug messages, no serial messages if this whole line is a comment!

// REPLACE WITH YOUR NETWORK CREDENTIALS
const char* ssid = "SSID";
const char* password = "12345678901234567890";

// Change this to your timezone, use the TZ database name
// https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
String timezoneString = "Europe/Berlin";

// If you want to have a different date or clock format change these two
// Complete table with every char: https://github.com/ropg/ezTime#getting-date-and-time
String dateFormat = "d.m.Y"; //Examples: d.m.Y -> 11.09.2021, D M y -> SAT SEP 21
String clockFormat = "H:i"; // Examples: H:i -> 21:19, h:ia -> 09:19PM


const char letters[] = {' ', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', '$', '&', '#', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ':', '.', '-', '?', '!'};
int displayState[UNITSAMOUNT];
String writtenLast;
unsigned long previousMillis = 0;

// Create AsyncWebServer object on port 80
AsyncWebServer server(80);

// Search for parameter in HTTP POST request
const char* PARAM_ALIGNMENT = "alignment";
const char* PARAM_SPEEDSLIDER = "speedslider";
const char* PARAM_DEVICEMODE = "devicemode";
const char* PARAM_INPUT_1 = "input1";

//Variables to save values from HTML form
String alignment;
String speedslider;
String devicemode;
String input1;

// File paths to save input values permanently
const char* alignmentPath = "/alignment.txt";
const char* speedsliderPath = "/speedslider.txt";
const char* devicemodePath = "/devicemode.txt";

JSONVar values;

Timezone timezone; //create ezTime timezone object


void setup() {
  // Serial port for debugging purposes
#ifdef serial
  Serial.begin(BAUDRATE);
  Serial.println("master start");
#endif

  //deactivate I2C if debugging the ESP, otherwise serial does not work
#ifndef serial
  Wire.begin(1, 3); //For ESP01 only
#endif
  //Wire.begin(D1, D2); //For NodeMCU testing only SDA=D1 and SCL=D2

  initWiFi(); //initializes WiFi
  initFS(); //initializes filesystem
  loadFSValues(); //loads initial values from filesystem

  //ezTime initialization
  waitForSync();
  timezone.setLocation(timezoneString);

  // Web Server Root URL
  server.on("/", HTTP_GET, [](AsyncWebServerRequest * request) {
    request->send(LittleFS, "/index.html", "text/html");
  });

  server.serveStatic("/", LittleFS, "/");

  server.on("/values", HTTP_GET, [](AsyncWebServerRequest * request) {
    String json = getCurrentInputValues();
    request->send(200, "application/json", json);
    json = String();
  });

  server.on("/", HTTP_POST, [](AsyncWebServerRequest * request) {
    int params = request->params();
    for (int i = 0; i < params; i++) {
      AsyncWebParameter* p = request->getParam(i);
      if (p->isPost()) {

        // HTTP POST alignment value
        if (p->name() == PARAM_ALIGNMENT) {
          alignment = p->value().c_str();
#ifdef serial
          Serial.print("Alignment set to: ");
          Serial.println(alignment);
#endif
          writeFile(LittleFS, alignmentPath, alignment.c_str());
        }

        // HTTP POST speed slider value
        if (p->name() == PARAM_SPEEDSLIDER) {
          speedslider = p->value().c_str();
#ifdef serial
          Serial.print("Speed set to: ");
          Serial.println(speedslider);
#endif
          writeFile(LittleFS, speedsliderPath, speedslider.c_str());
        }

        // HTTP POST mode value
        if (p->name() == PARAM_DEVICEMODE) {
          devicemode = p->value().c_str();
#ifdef serial
          Serial.print("Mode set to: ");
          Serial.println(devicemode);
#endif
          writeFile(LittleFS, devicemodePath, devicemode.c_str());
        }

        // HTTP POST input1 value
        if (p->name() == PARAM_INPUT_1) {
          input1 = p->value().c_str();
#ifdef serial
          Serial.print("Input 1 set to: ");
          Serial.println(input1);
#endif
        }
      }
    }
    request->send(LittleFS, "/index.html", "text/html");
  });
  server.begin();
#ifdef serial
  Serial.println("master ready");
#endif
}


void loop() {

  events(); //ezTime library function

  //Reset loop delay
  unsigned long currentMillis = millis();

  //Delay to not spam web requests
  if (currentMillis - previousMillis >= 1024) {
    previousMillis = currentMillis;

    //Mode Selection
    if (devicemode == "text") {
      showNewData(input1);
    } else if (devicemode == "date") {
      showDate();
    } else if (devicemode == "clock") {
      showClock();
    }
  }

}

I have an esp01 s board
thank you
OliverUse code tags to format code for the forum

Your topic has been moved to a more suitable location on the forum; this has nothing to do with Avrdude, stk500, Bootloader issues.

Where are those functions that it complains about?

I'm not a ESP user so can't help you much further.

The million dollar question !

the ESP8266WiFi library does not appear to have the function

  initWiFi(); //initializes WiFi

hence the error message: 'initWiFi' was not declared in this scope
have you tried simple WiFi programs on the ESP8266 before attemting the code in post 1?
confirm you are using an ESP01S module ?

I did not try a simple program I am using it for the first time.
Yes I have an esp01s

it is always a good idea to try simple programs before attempting a complex project
looking at split flag code the project consists of a number of .ino files, e.g. WiFiinit() is in file WiFifunctions.ino
looks like you are missing files from the project

So I guess that you copied the code from somewhere. In which case you probably only copied a part of it.

If you copied the sketch from somewhere, please provide a link.

EspMaster --> espMaster.ino
I putted then my ssid and my password in

image

WifiFunctions.ino contains e.g. initWiFi(), one of the function that the compiler is currently complaining about.

Your 'project' directory must be called ESPMaster and all files and directories (including files) must be there as in the image.

Thank you very much. It worked

1 Like

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