I Need to reduce the size of my esp32 program have no clue how
#include <esp_now.h>
#include <WiFi.h>
#include <pgmspace.h>
#include "BluetoothSerial.h" // Include BluetoothSerial header
#pragma GCC optimize ("Os")
const char deviceName[] PROGMEM = "ESPMaster";
const unsigned long bluetoothTimeout = 5000; // 5 seconds
unsigned long lastActivityTime = 0;
BluetoothSerial SerialBT; // Declare SerialBT instance
void setup() {
Serial.begin(115200);
WiFi.mode(WIFI_STA);
if (esp_now_init() != ESP_OK) {
Serial.println("Error initializing ESP-NOW");
return;
}
SerialBT.begin(deviceName); // Initialize SerialBT with deviceName
Serial.println(F("The device with name "ESPMaster" is started.nNow you can pair it with Bluetooth!"));
}
void loop() {
// Check for incoming data on Serial
while (Serial.available()) {
SerialBT.write(Serial.read());
lastActivityTime = millis();
}
// Check for Bluetooth timeout
if (millis() - lastActivityTime >= bluetoothTimeout) {
lastActivityTime = millis();
// Read acceleration data and send via Bluetooth
// (Assuming acceleration data is read from specific memory addresses as in previous examples)
float accelerationX = *((float*)0x3FF00000);
float accelerationY = *((float*)0x3FF00004);
float accelerationZ = *((float*)0x3FF00008);
char buffer[24]; // Reduced buffer size
snprintf_P(buffer, sizeof(buffer), PSTR("X: %.2f, Y: %.2f, Z: %.2f m/s^2n"), accelerationX, accelerationY, accelerationZ);
SerialBT.print(buffer);
}
}
Sketch uses 1480309 bytes (112%) of program storage space. Maximum is 1310720 bytes.
Global variables use 57044 bytes (17%) of dynamic memory, leaving 270636 bytes for local variables. Maximum is 327680 bytes.
Sketch too big; see https://support.arduino.cc/hc/en-us/articles/360013825179 for tips on reducing it.
text section exceeds available space in board
I have tried using some registers and removing unessery funtions
user25032913 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.