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.
In this article, we will delve into the process of installing and running the SLM(small language model) Gemma2 on the Single Board Computer (SBC) Raspberry Pi 5 using the Ollama runtime framework.