Text section exceeds available space in board

hi
i have nearly got this to work but at last minute i get (Sketch uses 1734329 bytes (132%) of program storage space. Maximum is 1310720 bytes.
Global variables use 60932 bytes (18%) of dynamic memory, leaving 266748 bytes for local variables. Maximum is 327680 bytes.
text section exceeds available space in board

Compilation error: text section exceeds available space in board)
ive got a wemos d1 mini esp32 as was suggested on here but now it comes up with this error

Sketch uses 1734329 bytes (132%) of program storage space. Maximum is 1310720 bytes.
Global variables use 60932 bytes (18%) of dynamic memory, leaving 266748 bytes for local variables. Maximum is 327680 bytes.
text section exceeds available space in board

Compilation error: text section exceeds available space in boardUse code tags to format >

hope its got code tags on it
is there anything i can or even get to clear this message this is water irrigation using wifi ,phone,alexa
colin

#include <LiquidCrystal_I2C.h>
#include <WiFi.h>
#include <ESPmDNS.h>
#include <WebServer.h>
#include <WiFiUdp.h>
#include <ArduinoOTA.h>
#include <BluetoothSerial.h>
#include <time.h>

#define I2C_ADDR 0x27
#define LCD_COLUMNS 16
#define LCD_ROWS 2

LiquidCrystal_I2C lcd(I2C_ADDR, LCD_COLUMNS, LCD_ROWS);

const char* ssid = "your_SSID";
const char* password = "your_PASSWORD";

BluetoothSerial SerialBT;
WebServer server(80);

const int relayPin = 23;
bool irrigationStatus = false;
unsigned long irrigationStart = 0;
const unsigned long irrigationDuration = 30000; // 30 seconds
unsigned long previousMillis = 0;
const long interval = 1000; // Interval to check time every second

void handleRoot() {
  String html = "<html><body><h1>ESP32 Irrigation System</h1><p>Status: ";
  html += irrigationStatus ? "On" : "Off";
  html += "</p><p><a href=\"/toggle\">Toggle Irrigation</a></p></body></html>";
  server.send(200, "text/html", html);
}

void handleToggle() {
  if (!irrigationStatus) {
    startIrrigation();
  } else {
    stopIrrigation();
  }
  handleRoot();
}

void startIrrigation() {
  irrigationStatus = true;
  irrigationStart = millis();
  digitalWrite(relayPin, HIGH);
  lcd.setCursor(0, 1);
  lcd.print("Watering: On  ");
}

void stopIrrigation() {
  irrigationStatus = false;
  digitalWrite(relayPin, LOW);
  lcd.setCursor(0, 1);
  lcd.print("Watering: Off ");
}

void setup() {
  Serial.begin(115200);
  SerialBT.begin("ESP32_Irrigation"); // Bluetooth device name
  lcd.begin();
  lcd.backlight();
  lcd.setCursor(0, 0);
  lcd.print("Irrigation Sys");

  pinMode(relayPin, OUTPUT);
  digitalWrite(relayPin, LOW);

  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  Serial.println("\nWiFi connected");
  lcd.setCursor(0, 1);
  lcd.print("WiFi Connected");

  ArduinoOTA.begin();
  if (MDNS.begin("esp32")) {
    Serial.println("MDNS responder started");
  }

  server.on("/", handleRoot);
  server.on("/toggle", handleToggle);
  server.begin();
  Serial.println("HTTP server started");

  configTime(0, 0, "pool.ntp.org");

  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("IP Address:");
  lcd.setCursor(0, 1);
  lcd.print(WiFi.localIP());
}

void loop() {
  ArduinoOTA.handle();
  server.handleClient();

  unsigned long currentMillis = millis();
  if (currentMillis - previousMillis >= interval) {
    previousMillis = currentMillis;

    struct tm timeinfo;
    if (getLocalTime(&timeinfo)) {
      char timeStr[16];
      snprintf(timeStr, sizeof(timeStr), "%02d:%02d:%02d", timeinfo.tm_hour, timeinfo.tm_min, timeinfo.tm_sec);
      lcd.setCursor(0, 0);
      lcd.print("Time:");
      lcd.setCursor(0, 1);
      lcd.print(timeStr);

      if ((timeinfo.tm_hour == 6 || timeinfo.tm_hour == 18) && timeinfo.tm_min == 0 && timeinfo.tm_sec == 0) {
        if (!irrigationStatus) {
          startIrrigation();
        }
      }
    }
  }

  if (irrigationStatus && currentMillis - irrigationStart >= irrigationDuration) {
    stopIrrigation();
  }

  if (SerialBT.available()) {
    String command = SerialBT.readStringUntil('\n');
    command.trim();
    if (command.equalsIgnoreCase("ON")) {
      startIrrigation();
    } else if (command.equalsIgnoreCase("OFF")) {
      stopIrrigation();
    }
    SerialBT.println(irrigationStatus ? "ON" : "OFF");
  }
}

[sterretje edit]
code tags fixed
[/end]

Thank you for posting the code, but you copied and pasted a "quote" (the greater-than symbol). Would you remove the ">" and move the ``` to the end of your code, above this:

code for the forum
hope its got code tags on it
is there anything i can or even get to clear this message this is water irrigation using wifi ,phone,alexa
colinUse code tags to format code for the forum
1 Like

You need to reconfigure the flash memory to allow more code space. Depending on how much flash you have you may have to give up OTA programming.

Looks like the code is too fat for your board, or the board is to skinny.

Fix the code tags.

I don't see anything obvious in the code that would take that much memory, bu some of the code is missing because of the lack of code tags.

Hi @gwencol100

I've fixed your attempt to use code tags. Code tags for a block of code are three backticks (```) before the code and three backticks after the code. They need to be on their own line.

If you put an escape (\) before the backtick (`), you can make three backticks look as the message edit box...

(```)

What was your last addition (that takes so much place)?
Did you introduce a new library?
Your code is pretty small. The libraries you use may be pretty big...
So it is worth looking at what can you miss?
Or look at the memory reconfiguration that was suggested by @oldcurmudgeon .

Do you need OTA or SPIFFS?
The WEMOS D1 MINI ESP32 has three options for Partition scheme, Default, No OTA (Large APP), and Minimal SPIFFS (Large APP with OTA). Your sketch is too big for Default, but fits within either of the other options.

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