The objective of this ESP32 Arduino Tutorial is to explain how to obtain and print the ESP32 free heap, using the Arduino core. The tests of this ESP32 tutorial were performed using a DFRobot’s ESP-WROOM-32 device integrated in a ESP32 development board.
Introduction
The objective of this ESP32 Arduino Tutorial is to explain how to obtain and print the ESP32 free heap memory, using the Arduino core.
The code for this will be very simple, since we already have defined in the EspClass a method for obtaining the free heap value. Note that the methods of this class are exposed in an extern variable called ESP.
So, in the Arduino setup function, we starting by opening a serial connection, so we can output the value of the free heap.
Serial.begin(115200);
Next, to obtain the free heap, we simply call the getFreeHeap method of the ESP extern variable.
This method takes no arguments and returns as output the free heap, in bytes. Note that in its implementation, the getFreeHeap method calls the esp_get_free_heap_size function of the IDF framework, which is defined in this header file.
Serial.println(ESP.getFreeHeap());
You can check the full source code below. Note that we left the main loop function empty since we don’t need to use it for this tutorial.
To test, simply open the Arduino IDE serial monitor after compiling and uploading the code to your ESP32 device. You should get an output similar to figure 1, which shows the available heap space on the device.
Should you upgrade to HUSKYLENS 2? This comparison breaks down processor speed, AI capabilities, LLM integration, and custom model support. Find out which vision sensor fits your robotics or STEM project—specs, prices, and real-world use cases.
The landscape of K–12 education is rapidly evolving, moving from simple digital making to complex problem-solving with Artificial Intelligence. At DFRobot, we believe in equipping educators with the best tools and knowledge to navigate this shift. That is why we are thrilled to announce that DFRobot will be a featured presenter at the upcoming 2026 Fab Educators Summit on Friday, January 30th.
From smart wearables and robotic skins to industrial monitoring, Force Sensitive Resistors (FSR) and Thin Film Pressure Sensors are essential components for tactile feedback. DFRobot offers a comprehensive range of force sensors, but choosing the right one can be tricky.