ESP32-audioI2S icon indicating copy to clipboard operation
ESP32-audioI2S copied to clipboard

Programsize is too big

Open blackbrv opened this issue 1 year ago • 2 comments

This is the code that i've been working on with the esp32 that have 38 pins

#include <Arduino.h> #include <Wire.h> #include <RTClib.h> #include <WiFi.h> #include <FirebaseESP32.h> #include <WiFiUdp.h> #include <NTPClient.h> #include <FPM.h> #include <Audio.h> #include "HX711.h" #include "addons/TokenHelper.h" #include "addons/RTDBHelper.h"

#define I2S_DOUT 25 #define I2S_BCLK 27 #define I2S_LRC 26 #define WIFI_SSID "" #define WIFI_PASSWORD "" #define API_KEY "--*-****" #define DATABASE_URL "kek.co" #define ESP32_KEY "myProj"

const int SDA_PIN = 21; const int SCL_PIN = 22; const int dirPin = 18; const int stepPin = 19; const int relaypin = 2; const int stepsPerRevolution = 200;

Audio audio; RTC_DS3231 rtc; FirebaseData fbdo; FirebaseAuth auth; FirebaseConfig config;

unsigned long sendDataPrevMillis = 0; bool signupOK = false;

String daysOfTheWeek[7] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};

WiFiUDP ntpUDP; NTPClient timeClient(ntpUDP, "pool.ntp.org", 25200, 60000);

void StepperRun();

void setup() { Serial.begin(115200); Wire.begin(SDA_PIN, SCL_PIN);

audio.setPinout(I2S_BCLK, I2S_LRC, I2S_DOUT); audio.setVolume(100);

if (!rtc.begin()) { Serial.println("Couldn't find RTC"); while (1); }

if (rtc.lostPower()) { Serial.println("RTC lost power, setting the time!"); rtc.adjust(DateTime(F(DATE), F(TIME))); }

WiFi.begin(WIFI_SSID, WIFI_PASSWORD); Serial.print("Connecting to Wi-Fi"); while (WiFi.status() != WL_CONNECTED) { delay(300); Serial.print("."); } Serial.println(); Serial.print("Connected with IP : "); Serial.println(WiFi.localIP()); Serial.println();

timeClient.begin(); while (!timeClient.update()) { timeClient.forceUpdate(); }

rtc.adjust(DateTime(timeClient.getEpochTime()));

config.api_key = API_KEY; config.database_url = DATABASE_URL;

if (Firebase.signUp(&config, &auth, "", "")) { Serial.println("signUp OK"); signupOK = true; } else { Serial.printf("%s\n", config.signer.signupError.message.c_str()); } config.token_status_callback = tokenStatusCallback; Firebase.begin(&config, &auth); Firebase.reconnectWiFi(true);

pinMode(stepPin, OUTPUT); pinMode(dirPin, OUTPUT); pinMode(relaypin, OUTPUT); }

void loop() { audio.loop(); DateTime now = rtc.now(); int hour1rtc = now.hour(); int minutes1rtc = now.minute(); String hari = daysOfTheWeek[now.dayOfTheWeek()];

if (Firebase.ready() && signupOK) { String path = String(ESP32_KEY) + "/time1"; if (Firebase.getString(fbdo, path.c_str())) { String time = fbdo.stringData(); int separatorIndex = time.indexOf(':'); if (separatorIndex != -1) { String hourString = time.substring(0, separatorIndex); String minutesString = time.substring(separatorIndex + 1); int hourFirebase = hourString.toInt(); int minutesFirebase = minutesString.toInt(); Serial.print("Data from Firebase: Hour"); Serial.print(hourFirebase); Serial.print(", Minutes "); Serial.println(minutesFirebase); Serial.print("Time,Now : "); Serial.print(hour1rtc, DEC); Serial.print(" : "); Serial.println(minutes1rtc, DEC); if (hour1rtc == hourFirebase && minutes1rtc == minutesFirebase) { audio.connecttospeech("Its time to drink your med", "en"); StepperRun(); } } else { Serial.println("Invalid time format from Firebase"); } } else { Serial.print("Failed to get data from Firebase: "); Serial.println(fbdo.errorReason()); }

delay(5000);

} }

void StepperRun() { digitalWrite(relaypin, HIGH); digitalWrite(dirPin, HIGH); for (int x = 0; x < stepsPerRevolution; x++) { digitalWrite(stepPin, HIGH); delayMicroseconds(1000); digitalWrite(stepPin, LOW); delayMicroseconds(1000); } delay(10000); digitalWrite(relaypin, LOW); }


This is the error that i've gotten on the platformIO

RAM: [== ] 15.7% (used 51284 bytes from 327680 bytes) Error: The program size (1487133 bytes) is greater than maximum allowed (1310720 bytes) Flash: [======*** [checkprogsize] Explicit exit, status1

I've been looking for the solution, most of the ppl that have this kind of problem, they had an error that they trying to use wifi and ble at the same time. Another solution that i've found that, i have to give up OTA to increase the memory size thing on the esp32, i kinda dont want to give the OTA feature to my project.

Can you guys help me on this problem 🙏 Thankyou

blackbrv avatar Nov 25 '23 10:11 blackbrv

You need to change esp32's partition layout. Maybe like this: https://github.com/biologist79/ESPuino/blob/master/custom_4mb_noota.csv

This needs to be referred in your platformio.ini.

biologist79 avatar Nov 25 '23 10:11 biologist79

This issue is stale because it has been open for 30 days with no activity.

github-actions[bot] avatar Jan 06 '24 02:01 github-actions[bot]