Resource Usage and Feature Trimming
Resource Usage and Feature Trimming
This document determines "which features go into firmware, which should be disabled". Build sections, environment lists and macro definition locations: Build Configuration; this page only covers resource budgets, trimming strategies and pre-delivery checklists to avoid duplicate maintenance of full platformio.ini descriptions.
ESP32 Memory Background
| Resource | ESP32 | ESP32-S3 | ESP32-C3 | ESP32-C6 |
|---|---|---|---|---|
| Internal SRAM | ~320KB | ~512KB | ~400KB | ~512KB |
| Available Heap (after boot) | ~220KB | ~310KB | ~140KB | ~220KB |
| PSRAM | 4-8MB optional | 2-8MB optional | None | None |
| Flash | 4-16MB | 8-16MB | 4MB | 4MB |
Key constraints:
- WiFi, lwIP, FreeRTOS, TLS handshakes still require internal DRAM and cannot fully rely on PSRAM.
- PSRAM is suitable for HTTP/JSON buffers and larger temporary objects, not for high-real-time or hardware-required internal DRAM structures.
- ESP32-C3/C6 4MB no-PSRAM environments should prefer Lite and disable display, network and advanced protocol modules for unconnected hardware.
- For long-term operation, largest contiguous heap block matters more than total free heap; with 35KB total free but only 8KB max contiguous block, large object allocation may still fail.
Feature Flag Method
Feature flags are set through build_flags in platformio.ini:
build_flags =
-DFASTBEE_ENABLE_XXX=1 ; Enable
-DFASTBEE_ENABLE_XXX=0 ; DisableDefault values are defined in include/core/FeatureFlags.h; values in platformio.ini override defaults. Typically you first select lite_flags, standard_flags or full_flags, then override individual items in specific [env:*] sections.
Trimming Priority Order
| Priority | Module | Recommendation |
|---|---|---|
| 1 | BLE | Full preset keeps FASTBEE_ENABLE_BLE=1, but there is no complete BLE provisioning page or processing chain; do not rely on it for delivery by default |
| 2 | 4G / Ethernet | Disable if hardware not connected; Standard edition disables 4G and Ethernet by default |
| 3 | TCP / HTTP / CoAP | Only enable for Full or when device actively connecting to external services is needed |
| 4 | OTA / File Manager / File Logging / User Roles | Enable based on maintenance needs for delivery; do not enable OTA by default on 4MB environments |
| 5 | LCD/OLED, NeoPixel, LED Matrix, RFID, IR, I2C Advanced Sensors | Disable if modules not connected; do not enable for reserved hardware in production configs |
| 6 | Rule Script / Command Script | Enable when field automation and scripting is needed; prefer fixed actions in low-memory environments |
Module Resource Budget
These are estimates for selection and trimming decisions; actual usage is determined by current build output and runtime /api/system/info.
Peripherals & Display
| Flag Macro | RAM | Flash | Preset | Notes |
|---|---|---|---|---|
FASTBEE_ENABLE_LCD | ~1.2KB | ~20KB | Lite/Standard/Full enabled by default | OLED/LCD, depends on U8g2 |
FASTBEE_ENABLE_NEOPIXEL | ~2KB + 3B/pixel | ~12KB | Enabled by default | WS2812 LED strip; use FASTBEE_NEOPIXEL_MAX_LEDS to lower cap |
FASTBEE_ENABLE_LED_SCREEN | Dynamic allocation | ~10KB | Standard/Full | WS2812B LED matrix |
FASTBEE_ENABLE_I2C_SENSORS | ~500B | ~15KB | Standard/Full | BMP280, MPU6050, SHT31, BH1750, AHT20 etc. |
FASTBEE_ENABLE_RFID | ~200B | ~12KB | Standard/Full | MFRC522 |
FASTBEE_ENABLE_IR_REMOTE | ~300B | ~8KB | Standard, disabled on S3 | ESP32-S3 conflicts with IRremoteESP8266 RMT driver |
FASTBEE_ENABLE_SENSOR_DRIVER | ~200B | ~8KB | Enabled by default | DHT, DS18B20 and other basic sensors |
FASTBEE_ENABLE_SEVEN_SEGMENT | ~32B/instance | ~3KB | Enabled by default | TM1637 digital tube |
FASTBEE_ENABLE_DS1302 | ~100B | ~2KB | Disabled by default | Usually unnecessary when NTP is available |
FASTBEE_ENABLE_LCD1602 | ~100B | ~3KB | Disabled by default | LCD1602/LCD2004 I2C character display |
Network & Protocol
| Flag Macro | RAM | Flash | Preset | Notes |
|---|---|---|---|---|
FASTBEE_ENABLE_MQTT | ~4-8KB | ~15KB | Enabled by default | Core cloud communication capability |
FASTBEE_ENABLE_MODBUS | ~3-5KB | ~20KB | Standard/Full | Common in industrial settings |
FASTBEE_MODBUS_SLAVE_ENABLE | ~440B | ~10KB | Full | Requires FASTBEE_ENABLE_MODBUS=1 |
FASTBEE_ENABLE_TCP | ~2-3KB | ~10KB | Full | Native TCP service |
FASTBEE_ENABLE_HTTP | ~2KB | ~8KB | Full | HTTP client |
FASTBEE_ENABLE_COAP | ~1KB | ~12KB | Full | CoAP protocol |
FASTBEE_ENABLE_ETHERNET | ~8KB | ~8KB | Full | W5500, disable if Ethernet hardware not connected |
FASTBEE_ENABLE_CELLULAR | ~10-15KB | ~15KB | Full | EC801E 4G, high RAM usage |
FASTBEE_ENABLE_BLE | ~20-30KB | ~80KB | Full reserved | No complete BLE provisioning page or processing chain; verify dependencies before enabling |
FASTBEE_ENABLE_MDNS | ~2KB | ~5KB | Enabled by default | Disabling removes fastbee.local access |
FASTBEE_ENABLE_DNS | ~1KB | ~3KB | Enabled by default | Commonly used on AP provisioning page |
FASTBEE_ENABLE_AP_MODE | ~1-2KB | ~2KB | Enabled by default | Disabling affects first-time provisioning |
System & Web
| Flag Macro | RAM | Flash | Preset | Notes |
|---|---|---|---|---|
FASTBEE_ENABLE_WEB_SERVER | ~20-30KB | ~25KB | Enabled by default | Web console and REST API core |
FASTBEE_ENABLE_PERIPH_EXEC | ~2-4KB | ~8KB | Enabled by default | Timer, event, platform trigger automation rules |
FASTBEE_ENABLE_RULE_SCRIPT | ~4-8KB | ~8KB | Standard/Full | Rule script engine |
FASTBEE_ENABLE_COMMAND_SCRIPT | ~1-2KB | ~3KB | Inherits rule script | Command script |
FASTBEE_ENABLE_OTA / FASTBEE_ENABLE_OTA_FS | ~4-6KB | ~10KB | Full | Only enable when Flash >= 8MB |
FASTBEE_ENABLE_STORAGE_CACHE | ~2-4KB | ~1KB | Disabled by default | Large config files bypass cache to avoid peak doubling |
FASTBEE_ENABLE_FILE_LOGGING | ~500B | ~3KB | Full | Continuous Flash writes affect lifespan |
FASTBEE_ENABLE_USER_ADMIN | ~500B | ~5KB | Full | Multi-user management |
FASTBEE_ENABLE_FILE_MANAGER | ~500B | ~3KB | Full | File manager |
FASTBEE_ENABLE_HEALTH_MONITOR | ~200B | ~4KB | Enabled by default | Not recommended to disable |
FASTBEE_ENABLE_LOGGER | ~300B | ~6KB | Enabled by default | Can reduce FASTBEE_LOG_BUFFER_SIZE |
Performance Tuning Parameters
| Parameter | Recommendation | Notes |
|---|---|---|
FASTBEE_USE_PSRAM / BOARD_HAS_PSRAM | Only enable on environments with actual PSRAM | Combined with heap_caps_malloc_extmem_enable(512) to prefer PSRAM for larger HTTP/JSON allocations |
FASTBEE_JSON_DOC_SIZE | Reduce from 4096/8192 in low-memory environments | Reduces JSON document peak, but not so small that config parsing breaks |
CONFIG_ASYNC_TCP_MAX_CONNECTIONS | Conservative for C3/C6, can increase for S3+PSRAM | Each connection consumes internal DRAM and lwIP PCB |
ARDUINO_LOOP_STACK_SIZE | Keep sufficient stack for Modbus, config save, script paths | Stack overflow manifests as Stack canary watchpoint triggered |
FASTBEE_STRIP_INFO_LOGS | Recommend 1 for production | Compile-time stripping of INFO log strings, saves Flash |
FASTBEE_DEBUG_LOG / CORE_DEBUG_LEVEL | Keep at low level for production | Debug logs increase Flash and runtime output pressure |
Typical Configurations
ESP32-C3/C6 4MB Lite
Goal: retain MQTT, Web/API, basic GPIO/sensor and AP provisioning; disable Modbus, OTA, scripts, 4G/Ethernet, display and advanced peripherals. If LED strip is not used, also disable NeoPixel:
-DFASTBEE_ENABLE_MODBUS=0
-DFASTBEE_ENABLE_OTA=0
-DFASTBEE_ENABLE_RULE_SCRIPT=0
-DFASTBEE_ENABLE_COMMAND_SCRIPT=0
-DFASTBEE_ENABLE_LCD=0
-DFASTBEE_ENABLE_NEOPIXEL=0
-DFASTBEE_ENABLE_I2C_SENSORS=0
-DFASTBEE_STRIP_INFO_LOGS=1
-DFASTBEE_LOG_BUFFER_SIZE=128ESP32 4MB Standard
Goal: WiFi + MQTT + Modbus + basic peripherals. Standard preset already disables 4G, Ethernet, BLE, TCP/HTTP/CoAP and OTA; additionally disable display, RFID, IR and other unused modules based on actual wiring.
-DFASTBEE_ENABLE_OTA=0
-DFASTBEE_ENABLE_ETHERNET=0
-DFASTBEE_ENABLE_CELLULAR=0
-DFASTBEE_ENABLE_LCD=0
-DFASTBEE_ENABLE_RFID=0
-DFASTBEE_ENABLE_IR_REMOTE=0ESP32-S3/ESP32 with PSRAM Full
Goal: complete networking, OTA, file/logging and advanced rules. Full enables 4G and Ethernet by default and retains BLE compile flag; when 4G/Ethernet hardware is not connected, actively disable the corresponding macros; also recommend disabling BLE until implementation is complete.
-DFASTBEE_USE_PSRAM=1
-DBOARD_HAS_PSRAM
-DFASTBEE_ENABLE_BLE=0Resource Limit Reference
| Parameter | ESP32-C3 Lite | ESP32 Standard | ESP32-S3 Full |
|---|---|---|---|
| Max Peripherals | 16 | 24 | 32 |
| Recommended Execution Rules | 12 | 16 | 32 |
| Sensor Cache Entries | 16 | 24 | 32 |
| TCP Concurrent Budget | 4 | 6 | 8 |
| SSE Connection Budget | 1 | 1 | 2 |
| HTTP Connection Budget | 3 | 5 | 6 |
| TCP Exhaustion Threshold | 10 | 12 | 14 |
Configuration Checklist
- Confirm which peripheral modules are actually connected to the hardware.
- Confirm required networking: WiFi, Ethernet or 4G.
- Confirm protocol needs: MQTT usually retained, Modbus/TCP/HTTP/CoAP enabled as needed.
- Do not enable OTA when Flash is less than 8MB.
- Only enable
FASTBEE_USE_PSRAM=1andBOARD_HAS_PSRAMon environments with actual PSRAM. - Unconnected peripherals, network modules and management features are disabled by default.
- When BLE is needed, also verify dependencies, source entry points, Web/API capabilities, provisioning workflow and resource validation; device-side defaults to WiFi AP/Web provisioning.
- After modifications, run
pio run -e <env>and check RAM/Flash usage in build output. - After flashing, check
heapFree,heapMaxAlloc, PSRAM and feature tier via dashboard or/api/system/infoto confirm they meet expectations.
