Skip to content

What is in my ESP32?

    In programming, header files are a fundamental concept that plays a central role in many programming languages, especially in C and C++. They are a type of file that contains definitions, declarations and prototypes of functions, classes and variables that are used in other source code files. Header files usually have the extension .h and allow developers to make the code clean, modular and reusable.

    Header files facilitate the organization of code by centralizing the declarations of functions and classes. This makes it possible to organize the main code in different files without repeating the implementation details over and over again. When compiling, the content of the header files is inserted into the corresponding source code files, which leads to better structuring and clarity of the code.

    In the world of microcontroller programming, such as the ESP32, header files are particularly important for managing and using the functions and libraries that control the microcontroller’s hardware. One such header file is ESP32.h, which provides a variety of functions to control the different features and hardware components of the ESP32.

    This function is defined in the source code of the ESP32 Arduino Core, and you can find it in the header files of the ESP32 Arduino Core library.

    Functions of the ESP32.h

    In the following sections, we will explain the main functions of the ESP32.h header file. These functions are crucial for programming and using the ESP32 microcontroller and provide access to a variety of hardware and system resources. From querying the flash memory to managing the PSRAM size and the chip’s MAC address, the ESP32.h file is a key tool for developing projects with the ESP32. You can find the article on determining the data here!

    Based on the fact that not all boards have the properties that are declared on various sales portals, I have looked into the possibility of accessing the chip data. I don’t want to withhold the information from you.


    Memory

    The heap memory in the ESP32 is the area of the main memory that is used for dynamic memory allocations. This memory is usually managed by functions such as malloc() and free() in the C programming language. In contrast to the stack memory, which is used to manage local variables and function calls, the heap memory enables the flexible allocation and release of memory during the runtime of the program.

    getHeapSize()
    The function returns the total size of the available heap memory. This function is particularly useful for obtaining information about the current size of the heap memory available for executing programs on the ESP32.

    getFreeHeap()
    This tells us how much memory is still available in the heap.

    getMaxAllocHeap()
    Returns the maximum heap size available for a single memory allocation.

    These functions are useful for monitoring memory usage and ensuring that your ESP32 project uses the available memory efficiently.


    What is PSRAM?

    • PSRAM stands for Pseudo-Static Random-Access Memory. It is a type of DRAM (Dynamic RAM) that works like SRAM (Static RAM), but is usually less expensive and memory dense. Unlike SRAM, PSRAM requires periodic refreshing, as is common with DRAM, but it is still a widely used and useful memory variant.
    • PSRAM is often used to expand the available memory of a microcontroller, especially for more demanding applications that require more memory than the microcontroller’s internal SRAM can provide.

    getPsramSize()
    The function is used to determine the size of the available external PSRAM. PSRAM is often available on ESP32 modules that support this additional memory. This function returns the size of the PSRAM in bytes.

    Further functions are getFreePsram(), getMinFreePsram(), getMaxAllocPsram() which are actually self-explanatory.


    Chip data

    Chip-Revision: This refers to the version or model of a microcontroller that has certain features or improvements over previous versions. Manufacturing processes and designs can change over time, and new revisions of a chip may include bug fixes, performance improvements or additional features.

    The getChipRevision() function returns a value that specifies the revision of the chip. This revision can be a numeric identifier that provides information about the hardware version of the ESP32. This is particularly useful if you want to ensure that your code is compatible with a specific revision of the chip or if you want to use functions that may only be available in certain revisions.

    getChipModel(): gives us the model name
    getChipCores(): gives us the number of cores
    getCpuFreqMHz(): determines the clock frequency of the ESP32

    CPU frequency” or “CPU clock frequency” in megahertz (MHz) describes the number of clock cycles that the processor can execute per second. The CPU frequency is an important indicator of the processing power of the microcontroller. A higher frequency usually means that the CPU can perform more calculations per second, resulting in better performance.

    ESP32-specific details

    Adjustable frequency: In many cases, the CPU frequency can be adjusted by software to optimize energy consumption or improve performance. This is often made possible by functions in the ESP-IDF (Espressif IoT Development Framework) or in the Arduino IDE.

    Standard CPU frequency: The ESP32, for example, has a CPU frequency of up to 240 MHz. This means that the CPU can execute up to 240 million clock cycles per second.


    What is flash memory?

    Flash memory: The flash memory in the ESP32 is the non-volatile memory in which the code and data are permanently stored. This is the memory that is initialized when the ESP32 is booted and is used for uploading firmware, saving configurations and permanently storing program data.

    getFlashChipSize() – Determine the size of the flash memory
    getFlashChipSpeed() – Speed, how fast the chip can be written to
    getFlashChipMode() – The values that getFlashChipMode() can return are typically constants that describe the communication modes of the flash memory.


    Program memory

    getSketchSize() – Determine the size of the program memory
    getFreeSketchSpace() – is a method that gives you the amount of remaining flash memory

    getSketchMD5() – The getSketchMD5() function is a useful method in the Arduino environment that returns the MD5 hash value of the currently uploaded sketch (program) on the microcontroller.

    What is MD5?
    MD5 (Message Digest Algorithm 5): MD5 is a cryptographic hash algorithm that generates a 128-bit hash value (16 bytes) from any amount of data. It is often used to verify data integrity by creating a unique fingerprint for the data. For software and firmware, this can help to ensure that the code has not been altered or corrupted.


    What is a MAC address?

    MAC address: A MAC address is a unique hardware address that is assigned to each network device. It consists of 48 bits (6 bytes) and is usually represented in hexadecimal notation. It is used to identify devices within a network and to send data packets to the correct device. We will come to this at the latest when we deal with ESP NOW

    What does getEfuseMac() do?
    This function returns the MAC address of the ESP32, which is burned into the so-called eFuse memory of the chip. The eFuse memory is a special area of flash memory that can be programmed once to permanently store data such as MAC addresses, serial numbers or other unique identifiers.

    We have now collected a lot of wood to better understand the data of an ESP.
    I hope this is also useful for you. You are welcome to leave your feedback in a comment.

    In the next article, we will look at programming the ESP to read out the ESP data.

    0 Kommentare
    Inline Feedbacks
    View all comments