{"id":42287,"date":"2021-04-26T10:05:57","date_gmt":"2021-04-26T02:05:57","guid":{"rendered":"\/blog\/?p=42287"},"modified":"2021-09-29T16:20:27","modified_gmt":"2021-09-29T08:20:27","slug":"managing-arduino-memory-flash-sram-eeprom","status":"publish","type":"post","link":"https:\/\/www.seeedstudio.com\/blog\/2021\/04\/26\/managing-arduino-memory-flash-sram-eeprom\/","title":{"rendered":"Managing Arduino Memory: Flash, SRAM, EEPROM!"},"content":{"rendered":"\n<p>Most of us have a general idea that the memory on our Arduino microcontrollers is an essential part of what allows them to store and run code. For the most part, that understanding is sufficient, but only if we\u2019re working with simple programs! On the other hand, when trying to build a more advanced application like TinyML, a deeper understanding of Arduino memory can go a long way to help make the most of our beloved microcontrollers. Fortunately, this article is going to give you just that!<\/p>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>We will be covering the following content and more!<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Why should you know about Arduino memory?<\/li><li>What is Memory in Arduino?<\/li><li>How to Measure Arduino Memory Usage<\/li><li>How to Optimise Memory Usage on Arduino<\/li><li>Arduinos for Memory Intensive Projects<\/li><\/ul>\n\n\n\n<div style=\"height:25px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<figure class=\"wp-block-image size-large\"><img fetchpriority=\"high\" decoding=\"async\" width=\"1030\" height=\"601\" src=\"https:\/\/blog.seeedstudio.com\/wp-content\/uploads\/2021\/04\/ArduinoMemCover-1030x601.png\" alt=\"\" class=\"wp-image-42316\" srcset=\"https:\/\/www.seeedstudio.com\/blog\/wp-content\/uploads\/2021\/04\/ArduinoMemCover-1030x601.png 1030w, https:\/\/www.seeedstudio.com\/blog\/wp-content\/uploads\/2021\/04\/ArduinoMemCover-300x175.png 300w, https:\/\/www.seeedstudio.com\/blog\/wp-content\/uploads\/2021\/04\/ArduinoMemCover-768x448.png 768w, https:\/\/www.seeedstudio.com\/blog\/wp-content\/uploads\/2021\/04\/ArduinoMemCover-1536x896.png 1536w, https:\/\/www.seeedstudio.com\/blog\/wp-content\/uploads\/2021\/04\/ArduinoMemCover-2048x1195.png 2048w, https:\/\/www.seeedstudio.com\/blog\/wp-content\/uploads\/2021\/04\/ArduinoMemCover-1024x597.png 1024w\" sizes=\"(max-width: 1030px) 100vw, 1030px\" \/><\/figure>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<div style=\"height:1px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Why Should You Know About Arduino Memory?<\/strong><\/h2>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>In broad and simple terms, the purpose of memory blocks in Arduino microcontrollers is to store run-time data or information temporarily or permanently. For example, both the code that you upload to your Arduino and the variables declared in that code are stored in memory. In fact, memory is an essential component of any type of computer!<\/p>\n\n\n\n<div style=\"height:10px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>Microcontrollers like Arduino are built small and affordable to serve specific purposes and thus have relatively limited computing resources. Compared to modern computers which have Gigabytes (10<sup>9<\/sup>) of memory as norm, microcontrollers function with memory sizes of Kilobytes (10<sup>3<\/sup>) to a few Megabytes (10<sup>6<\/sup>). Hence, it\u2019s important to use the memory resources on our Arduino with careful consideration.<\/p>\n\n\n\n<div style=\"height:25px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter is-resized\"><img decoding=\"async\" src=\"https:\/\/lh5.googleusercontent.com\/fcu0IXcAVxo5HoYGsNdbT2oX_l11rdhpUct6mPMmdzY14JSwHmzhzE_WQW56-2Zxus9mgkk3TEREt3dNIyxwFFT_95YawCA7H85BwYlLz-wTi0qlW13vIzrQPgnFR2cF1avOOU2n\" alt=\"\" width=\"600\"\/><figcaption><em>Source: Dots and Brackets<\/em><\/figcaption><\/figure><\/div>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>When memory is not managed well, your Arduino might fail in a variety of ways. Sometimes, this can be as obvious as the code not uploading to your board like shown above. In other cases, everything might appear to run fine for awhile, only for the microcontroller to stop responding later on &#8211; that\u2019s much more tricky!<\/p>\n\n\n\n<div style=\"height:10px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>In any case, unless you&#8217;re working with a faulty board, it\u2019s almost certain that any code that compiles but doesn\u2019t work as it should is suffering from a memory problem. When that happens, it\u2019s important to understand what goes on behind the scenes so that we can diagnose and fix the problem!<\/p>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<div style=\"height:1px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>What is Memory in Arduino?<\/strong><\/h2>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>There are three types of Arduino memory that you should be aware of:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><strong>Flash<\/strong> or Program Memory (PROGMEM)<\/li><li><strong>SRAM<\/strong> &#8211; Static Random Access Memory<\/li><li><strong>EEPROM<\/strong> &#8211; Electronically Erasable Programmable Read-Only Memory<\/li><\/ul>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Flash Memory<\/strong><\/h3>\n\n\n\n<div style=\"height:10px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>Flash memory is a type of memory that is used for storage, similar to what we see in USB thumb drives and SD cards. It is non-volatile, meaning that it will retain stored information even if no power is supplied.<\/p>\n\n\n\n<div style=\"height:10px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>In an Arduino, Flash used to store the program code and any additional data. Since data held in flash memory can\u2019t be modified by executing code, they are first copied into the SRAM before the code is run.<\/p>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>SRAM<\/strong><\/h3>\n\n\n\n<div style=\"height:10px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>SRAM stands for Static Random Access Memory, and is arguably the most important component of diagnosing memory issues in Arduino. You can imagine it as a memory block that is shared amongst three main components: <strong>Static Data<\/strong>, <strong>Heap<\/strong> &amp; <strong>Stack<\/strong>.<\/p>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter is-resized\"><img decoding=\"async\" src=\"https:\/\/lh6.googleusercontent.com\/ciSun0iad56BhZFiZiZJySA392t8Yq3jZoqwRnUV7CBv334DfqEkDX2Ik687C070niTX4hqKvNzqJCspaqMATG882SYo4k9N3NgedSn8yMyAt-2dGj4lJNEUeV1w0u6X1hRFihhJ\" alt=\"\" width=\"700\"\/><\/figure><\/div>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<ul class=\"wp-block-list\"><li><strong>Static Data <\/strong>&#8211; This section of the SRAM stores data that doesn\u2019t change in the programme, such as global and static variables.<\/li><\/ul>\n\n\n\n<div style=\"height:5px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<ul class=\"wp-block-list\"><li><strong>Heap<\/strong> &#8211; The heap exists next to static data an is used for dynamically allocated data items, such as variables created by executing code.<\/li><\/ul>\n\n\n\n<div style=\"height:5px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<ul class=\"wp-block-list\"><li><strong>Stack<\/strong> &#8211; The stack is used to keep track of function parameters, including local variables, interrupts, and function calls. Each function call will increase the size of the stack, while returning from a function will return that memory to the free memory pool.<\/li><\/ul>\n\n\n\n<div style=\"height:25px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>You might have noticed that the stack and heap are located on opposite ends of the free memory. As either of them grow, they consume more and more of the free memory, effectively \u201cmoving towards\u201d each other. Most memory problems are the result of the stack and heap \u201ccolliding\u201d, which can cause a corruption of the data held in memory. As mentioned, some corruptions may cause an immediate crash, or the code may still continue to run for a period before problems emerge. It depends!<\/p>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>EEPROM<\/strong><\/h3>\n\n\n\n<div style=\"height:10px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>Similar to flash, EEPROM is another form of non-volatile memory that you can use to read and write data. However, you will have to do so byte by byte, which can be slightly more inconvenient than what we\u2019re typically used to. You can think of it as an in between of both flash and SRAM &#8211; a read\/writable flash or non-volatile SRAM, as you will!<\/p>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p><strong>Note:<\/strong> Most EEPROMs have lifespan of around 100,000 write\/erase cycles, so be careful with placing EEPROM read \/ writes in loops!<\/p>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<div style=\"height:1px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>How to Measure Arduino Memory Usage<\/strong><\/h2>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>Before optimisations, we\u2019ll have to begin our diagnosis by measuring the amount of memory that our program uses.<\/p>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Flash<\/strong><\/h3>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>It\u2019s super convenient to measure Flash memory &#8211; in fact, the Arduino IDE will do it for you! Whenever you compile or upload your code, the IDE will show you exactly how much memory is being used by your upload and what percentage of the selected board\u2019s memory that uses. For example, the sketch I uploaded below uses just 35K or 7% of the Wio Terminal\u2019s flash memory &#8211; very comfortable!<\/p>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter is-resized\"><img decoding=\"async\" src=\"https:\/\/lh5.googleusercontent.com\/GD3UeMW-i8vRBpZyiBzmRutmqwmCVr-9OwEQxAxIbKs0tksiyKJYCGWwu3iF17srCTTnxfVw8Vyy0fDfqEZFybxSC7BzBVqQNgvDOKYYQcp83CFHTT18rOdyQfnh_R4RhollDQ_Q\" alt=\"\" width=\"600\"\/><\/figure><\/div>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>EEPROM<\/strong><\/h3>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>You have to write to the EEPROM byte by byte, so you should know exactly which addresses are being used. When in doubt, you should double check your code! While it\u2019s not the main focus of our article, an example of reading and writing data with the EEPROM is shown for reference below. You can also learn more about how to use the EEPROM on an Arduino with the <a href=\"https:\/\/www.arduino.cc\/en\/Reference\/EEPROM\">official documentation<\/a>!<\/p>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ Write data to a given address\n#include &lt;EEPROM.h&gt;\nEEPROM.write(address, value);\nEEPROM.read(address);<\/code><\/pre>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>SRAM<\/strong><\/h3>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>To measure the usage of our Arduino\u2019s SRAM, we can use a convenient function call from this <a href=\"https:\/\/github.com\/mpflaga\/Arduino-MemoryFree\">arduino library<\/a> which measures the free RAM available, freeMemory(), which is also defined below.<\/p>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<pre class=\"wp-block-code\"><code>#ifdef __arm__\n\/\/ should use uinstd.h to define sbrk but Due causes a conflict\nextern \"C\" char* sbrk(int incr);\n#else  \/\/ __ARM__\nextern char *__brkval;\n#endif  \/\/ __arm__\n \nint freeMemory() {\n char top;\n#ifdef __arm__\n return &amp;top - reinterpret_cast&lt;char*&gt;(sbrk(0));\n#elif defined(CORE_TEENSY) || (ARDUINO &gt; 103 &amp;&amp; ARDUINO != 151)\n return &amp;top - __brkval;\n#else  \/\/ __arm__\n return __brkval ? &amp;top - __brkval : &amp;top - __malloc_heap_start;\n#endif  \/\/ __arm__\n}<\/code><\/pre>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>Recall that the objective when managing SRAM is to avoid a collision between the heap and the stack. Thus, what freeMemory() actually provides us with is the amount of free memory available between them.<\/p>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter is-resized\"><img decoding=\"async\" src=\"https:\/\/lh6.googleusercontent.com\/gcnYjmEoxJrSN1k7aC_xkqQb6mdS0vWke13butwJvVxf03tB2zmpbvIz1k-qNUWszHBSBc_3HwKpEQyVMnZBnt3FkA5PFMQeqaAYPHAza89W5vBC-Q_5iZ96689ZOLib8eVBD4sI\" alt=\"\" width=\"700\"\/><\/figure><\/div>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>Since the size of the heap and the stack will change throughout the program execution (ie. they are dynamic), it\u2019s also important to monitor the free memory available throughout various points of the code by calling the freeMemory() function regularly.<\/p>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<div style=\"height:1px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Greatest Memory Offenders<\/strong><\/h2>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>Despite our best efforts to optimise memory, some devices and drivers will simply require more SRAM to function. In those cases, it\u2019s important to identify the offenders and work around them!<\/p>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Filesystems<\/strong><\/h3>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>If your Arduino interfaces with a SD or MicroSD card, a large memory buffer of 512 bytes will need to be allocated to facilitate the reading and writing of data. If possible, it\u2019s advised to move the contents of your program to your flash memory, since it will also be faster.<\/p>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Anything with Pixels<\/strong><\/h3>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>OLED displays, RGB lights, you name it &#8211; these things hog memory! Each pixel is defined as a combination of Red, Green, Blue (RGB) values, and will consume 3 bytes of SRAM. Don\u2019t underestimate that number, since small displays can already easily have thousands of pixels! Of course, monochrome (single colour) displays will only require 1 byte for every 8 pixels, but that\u2019s still 1K for SRAM for a display as small as 128 by 64 &#8211; choose wisely!<\/p>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>TinyML<\/strong><\/h3>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>TinyML is a new concept that aims to bring machine learning to tiny and cost effective microcontrollers. Considering that most ML is done on desktop-class computers, there\u2019s no doubt that this stretches the memory consumption on microcontrollers. If you want to build edge ML applications, you\u2019ll have to be even more careful of memory consumption since it\u2019s necessary to work around the ML model.<\/p>\n\n\n\n<p>If you\u2019re keen to learn more about Edge ML, I highly encourage you to read our previous article <a href=\"https:\/\/www.seeedstudio.com\/blog\/2021\/04\/02\/edge-ai-what-is-it-and-what-can-it-do-for-edge-iot\/\">here<\/a>.<\/p>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<div style=\"height:1px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Optimising Memory Usage on Arduino<\/strong><\/h2>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>If your program is failing due to a memory problem, you\u2019re in luck. For each type of Arduino memory, there are a few basic modifications that we can make to our code in order to&nbsp; reduce the memory used. With some finesse, you just might be able to once again get it under the memory limits! In this section, we\u2019ll only talk about optimising flash and SRAM, since EEPROM memory tends to be quite straightforward.<\/p>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p><strong>Note:<\/strong> Memory optimisation is a deep and advanced topic in the world of computing; deeper knowledge on this subject can certainly bring you much further! The steps shared in this article are just some of the steps that beginners can take to optimise their code!<\/p>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Optimising Flash Memory<\/strong><\/h2>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>The best way to reduce the size of your program is to identify which of its parts are really necessary, and to eliminate those that aren\u2019t to save space. For example:<\/p>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<ul class=\"wp-block-list\"><li>Eliminate <strong>unused libraries, functions and variables<\/strong>.<\/li><li>Look out for <strong>unreachable code<\/strong>, such as conditionals that will never be true.<\/li><li><strong>Consolidate repetitive code<\/strong> by wrapping it in a reusable function.<\/li><\/ul>\n\n\n\n<div style=\"height:25px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>On the extreme end of things, you can consider eliminating the bootloader to save even more space. However, I wouldn\u2019t recommend this as bootloaders serve several important functions in development processes and can make your life easier. If you\u2019re still keen on making this happen, have a look at our <a href=\"https:\/\/www.seeedstudio.com\/blog\/2021\/04\/02\/arduino-bootloader-programming-getting-started-with-arm-microcontrollers\/\">bootloader programming article<\/a>.<\/p>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Optimising SRAM<\/strong><\/h2>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>SRAM is the most complex of all three memory types to use, but there are also more options when it comes to optimising it.<\/p>\n\n\n\n<div style=\"height:10px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Understand the Behaviours<\/strong><\/h3>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>An important aspect of SRAM management that may confuse some beginners has to do with the heap. We know that the heap is used for dynamically allocated variables in the program, but there is an important issue that arises if you don\u2019t use it carefully, known as <strong>heap fragmentation<\/strong>. Let\u2019s look at an illustration of a heap to understand this.<\/p>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter is-resized\"><img decoding=\"async\" src=\"https:\/\/lh6.googleusercontent.com\/bdDI7i5w7qrOPzqHKKbmpxeKiX68oqiyNMxLtC_EgUPUr_XfeCsW6De76BrfvBGFDYcnDpRTraOSy_g2NVt_cryu_zoOQ13aaFis09zfR1XJ0mEPQxHcgOPQg4lTsfeoTQVEmDn_\" alt=\"\" width=\"550\"\/><figcaption><em>Source: Brew<\/em><\/figcaption><\/figure><\/div>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>The entire heap holds 64KB of memory. Up until Step 3, subsequent allocations take up neighbouring memory addresses, which is rather straightforward. Now, observe what happens when the second allocation is freed. Although we now theoretically have 32KB of free memory like we did in Step 2, the maximum size of any subsequent allocation is now 16KB instead of 32KB! In this case, the memory available from freeing the second allocation is known as <strong>buried heap space<\/strong>, and <strong>heap fragmentation<\/strong> has occurred.<\/p>\n\n\n\n<div style=\"height:10px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>Buried heap space is not usable by the stack, but can be used for subsequent heap allocations. Hence, poor heap management can cause the heap to grow quickly towards the stack, accelerating a memory corruption!<\/p>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Use Local Variables<\/strong><\/h3>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>A good way to circumvent the heap problem is to use local variables in your functions. Local variables are variables which are declared inside a function, and are only available for use within that function. This way, the memory usage becomes part of the stack as opposed to the heap. The benefit of this is that the memory used by stacks are <strong>completely freed<\/strong> when the function is returned, which allows our code to work in the same manner without opening it up to vulnerabilities from heap fragmentation!<\/p>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Offloading to Flash \/ PROGMEM<\/strong><\/h3>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>Normally, our code dynamically loads static variables into SRAM, which wastes precious memory in the heap since we\u2019ll never have to modify them. Fortunately, there are several methods to tell our program to leave such variables out of SRAM, and to instead reference them directly from flash memory.<\/p>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p><strong>For Strings:<\/strong><\/p>\n\n\n\n<p>Literal strings consume a very large amount of memory, but there is fortunately an easy way to reduce their memory usage. By wrapping strings with a F() macro as shown below, we tell the program to store the string in Flash, saving us a ton of precious SRAM!<\/p>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<pre class=\"wp-block-code\"><code>Serial.println(F(\u201cThis is a string that eats a lot of memory, but not anymore!\u201d));<\/code><\/pre>\n\n\n\n<div style=\"height:10px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p><strong>For Other Data:<\/strong><\/p>\n\n\n\n<div style=\"height:10px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>You can also do something similar to other data types by using the <a href=\"https:\/\/www.arduino.cc\/reference\/en\/language\/variables\/utilities\/progmem\/\">PROGMEM modifier<\/a>. After the data is moved into the Flash memory, you will need to use special functions defined in the <a href=\"https:\/\/www.nongnu.org\/avr-libc\/user-manual\/group__avr__pgmspace.html\">pgmspace.h<\/a> library to read and write data. As you might tell, this presents a slight inconvenience, but is great for reducing SRAM consumption!<\/p>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Reserve() Memory<\/strong><\/h3>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>The reserve() function creates a buffer for a string that might grow in the future. That way, the program will not have to reallocate memory to the string as it is being modified by the program.<\/p>\n\n\n\n<div style=\"height:10px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>Why is this important? Well, when strings are being modified, it\u2019s common for intermediary variables to be created to facilitate the operation. When this happens, the heap memory allocation gets chaotic and a new section of memory often has to be allocated for the final string object. This creates opportunities for heap fragmentation to occur, which will reduce the memory efficiency of our program!<\/p>\n\n\n\n<div style=\"height:10px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>To use reserve(), you can follow the syntax below. More information can also be found on the <a href=\"https:\/\/www.arduino.cc\/reference\/en\/language\/variables\/data-types\/string\/functions\/reserve\/\">official documentation<\/a>.<\/p>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<pre class=\"wp-block-code\"><code>myString.reserve(size);\n\/\/ where myString is a variable of type String\n\/\/ the number of bytes (unsigned int) in memory to reserve.<\/code><\/pre>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Modify Buffer Sizes<\/strong><\/h3>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>Just like we can do with reserve(), different components of our code that work in the backend use buffers to manage memory consumption. However, the buffers allocated can sometimes be excessive for your specific use case. If you need to free up some additional memory, modifying the buffer sizes can be a useful option.<\/p>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p><strong>Your Own Buffers<\/strong> &#8211; It goes without saying to check the sizes of the buffers you allocate. They shouldn&#8217;t be bigger than they need to be!<\/p>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p><strong>Libraries<\/strong> &#8211; Some libraries also create buffers in the background to help their components run smoothly. If you have the patience to read through the library code, this may be an opportunity to reduce memory consumption.<\/p>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p><strong>System Buffers<\/strong> &#8211; Different systems will allocate buffers for various backend services, like the 64 byte serial receive buffer. If you\u2019re not intending to use high speed serial communication, you can reduce the buffer size that is defined in the HardwareSerial.h file in your Arduino installation by modifying the following line:<\/p>\n\n\n\n<div style=\"height:20px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<pre class=\"wp-block-code\"><code>#define SERIAL_BUFFERSIZE 64<\/code><\/pre>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Use the Right Data Types<\/strong><\/h3>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>Different data types use different amounts of memory! You can vastly reduce the amount of memory used by your code if you use the smallest data type where possible. For example, use a byte instead of an integer, and an integer instead of a float!<\/p>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter is-resized\"><img decoding=\"async\" src=\"https:\/\/lh6.googleusercontent.com\/c38J7oEga1uFSgwkb9z8sul17BEEXwE24deqZwNh2czwH00l3vNc7yLqu7SDMki3YeqOo5Mn0YoriA6e8sZwbUI0NSmWK-t77ixStuB0X1t5uUQ4B_ionEXpth0Lygx_SKUcshvh\" alt=\"\" width=\"800\"\/><\/figure><\/div>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<div style=\"height:1px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Arduino Recommendations<\/strong><\/h2>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>In the worst case, the amount of physical memory that your Arduino board has may simply not be sufficient for the application you are trying to build. Fortunately, Seeed offers a number of Arduino-compatible microcontroller boards that are sure to provide you with enough power and memory to get the job done!<\/p>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Seeeduino XIAO<\/strong><\/h3>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>The Seeeduino XIAO is the smallest Arduino compatible board in the Seeeduino Family. Despite its small size, the Seeeduino XIAO is equipped with the powerful SAMD21 microchip and a variety of hardware interfaces. With 256KB Flash and 32KB SRAM, the Seeeduino XIAO houses 16 times more SRAM than the popular Arduino UNO!<\/p>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter is-resized\"><img decoding=\"async\" src=\"https:\/\/lh4.googleusercontent.com\/DGl7oFIJvmTFj88oh8EY3TIUEGP0zxRVwzrPUjlYhK9FPGGsasIiwMfdyBCdLTN01JHwuaEOiy6KOdUzh-6BZoLUjeYEPd3r-1fKHj-aD4Ox81ap8BipH4VUvMhLZYdk0PFGD434\" alt=\"\" width=\"400\"\/><\/figure><\/div>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p><strong>Product Features:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>ARM Cortex-M0+ 32bit 48MHz microcontroller (SAMD21G18) with 256KB Flash, 32KB SRAM<\/li><li>Compatible with Arduino IDE &amp; MicroPython<\/li><li>Easy Project Operation: Breadboard-friendly<\/li><li>Small Size: As small as a thumb (20\u00d717.5mm) for wearable devices and small projects<\/li><li>11 digital\/analog pins, 10 PWM Pins, 1 DAC output, 1 SWD Bonding pad interface, 1 I2C interface, 1 UART interface, 1 SPI interface<\/li><\/ul>\n\n\n\n<div style=\"height:25px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>Keen to learn more about the Seeeduino XIAO? Visit its <a href=\"https:\/\/www.seeedstudio.com\/Seeeduino-XIAO-Arduino-Microcontroller-SAMD21-Cortex-M0+-p-4426.html\">product page<\/a> on our Seeed Online Store now!<\/p>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Wio Terminal<\/strong><\/h3>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>The Wio Terminal is a complete Arduino development platform based on the ATSAMD51, with wireless connectivity powered by Realtek RTL8720DN. An all-in-one microcontroller, it has an onboard 2.4\u201d LCD Display, IMU, microphone, buzzer, microSD card slot, light sensor &amp; infrared emitter. With a whopping 4MB of flash memory and 192KB of RAM, it&#8217;s a perfect candidate for memory intensive uses like TinyML!<\/p>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter is-resized\"><img decoding=\"async\" src=\"https:\/\/lh4.googleusercontent.com\/9p_0sZzWT5lDlV3g7dKCLUcflyfzzv_SIrATBwI1DJyA9Rt8PseK1nDZFys9CV6wEXqxpfbmIVj1Ur1yz_bIPEYxd9n6U6rP6YJd94drANS3NoygMhUUJFP2zOLz5TmaRNsmXLT2\" alt=\"\" width=\"500\"\/><\/figure><\/div>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p><strong>Product Features:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Powerful MCU: Microchip ATSAMD51P19 with ARM Cortex-M4F core running at 120MHz<\/li><li>Reliable Wireless Connectivity: Equipped with Realtek RTL8720DN, dual-band 2.4GHz \/ 5GHz Wi-Fi (supported only by Arduino)<\/li><li>Highly Integrated Design: 2.4\u201d LCD Screen, IMU and Compact Enclosure with built-in magnets &amp; mounting holes<\/li><li>Raspberry Pi 40-pin Compatible GPIO<\/li><li>Compatible with over 300 plug&amp;play Grove modules to explore with IoT<\/li><li>USB OTG Support<\/li><li>Support Arduino, CircuitPython, Micropython, ArduPy, AT Firmware, Visual Studio Code<\/li><li>TELEC Certified<\/li><\/ul>\n\n\n\n<div style=\"height:25px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>If you\u2019re interested to pick up a Wio Terminal, please visit its <a href=\"https:\/\/www.seeedstudio.com\/Wio-Terminal-p-4509.html\">product page<\/a> on the Seeed Online Store!<\/p>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<div style=\"height:1px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Summary<\/strong><\/h2>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>That concludes today\u2019s article on managing Arduino memory! This has been a very simple introduction to understanding how the different types of memories on the Arduino, as well as how to make better use of them. Just remember, these suggestions are merely the tip of the iceberg, and there are many more ways to optimise memory usage, like understanding the space complexity of the code write! In any case, I hope you\u2019ve now gotten a better idea of where to start!<\/p>\n\n\n\n<div style=\"height:15px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p>If you\u2019d like to learn more, it may be worth your while to give the following content a read:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><a href=\"https:\/\/www.seeedstudio.com\/blog\/2021\/04\/02\/edge-ai-what-is-it-and-what-can-it-do-for-edge-iot\/\">Edge AI &#8211; What is it and What can it do for Edge IoT?<\/a><\/li><li><a href=\"https:\/\/www.seeedstudio.com\/blog\/2021\/04\/02\/arduino-bootloader-programming-getting-started-with-arm-microcontrollers\/\">Arduino Bootloader Programming \u2013 Getting Started with ARM Microcontrollers<\/a><\/li><li>Multitasking with Arduino \u2013 Millis(), RTOS &amp; More!<\/li><li>RTOS Basics: Getting Started with Microcontrollers<\/li><\/ul>\n\n\n\n<div style=\"height:50px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Most of us have a general idea that the memory on our Arduino microcontrollers is<\/p>\n","protected":false},"author":3537,"featured_media":42316,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_lmt_disableupdate":"","_lmt_disable":"","_price":"","_stock":"","_tribe_ticket_header":"","_tribe_default_ticket_provider":"","_tribe_ticket_capacity":"0","_ticket_start_date":"","_ticket_end_date":"","_tribe_ticket_show_description":"","_tribe_ticket_show_not_going":false,"_tribe_ticket_use_global_stock":"","_tribe_ticket_global_stock_level":"","_global_stock_mode":"","_global_stock_cap":"","_tribe_rsvp_for_event":"","_tribe_ticket_going_count":"","_tribe_ticket_not_going_count":"","_tribe_tickets_list":"[]","_tribe_ticket_has_attendee_info_fields":false,"iawp_total_views":0,"footnotes":""},"categories":[1],"tags":[6,1109,2216,3275,2982,3003],"class_list":["post-42287","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-news","tag-arduino","tag-arduino-beginner","tag-arduino-ide","tag-ram","tag-seeeduino-xiao","tag-wio-terminal"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.0 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Managing Arduino Memory: Flash, SRAM, EEPROM! - Latest News from Seeed Studio<\/title>\n<meta name=\"description\" content=\"When building advanced applications, a deeper understanding of Arduino memory can go a long way to help make the most of our beloved microcontrollers!\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.seeedstudio.com\/blog\/2021\/04\/26\/managing-arduino-memory-flash-sram-eeprom\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Managing Arduino Memory: Flash, SRAM, EEPROM! - Latest News from Seeed Studio\" \/>\n<meta property=\"og:description\" content=\"When building advanced applications, a deeper understanding of Arduino memory can go a long way to help make the most of our beloved microcontrollers!\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.seeedstudio.com\/blog\/2021\/04\/26\/managing-arduino-memory-flash-sram-eeprom\/\" \/>\n<meta property=\"og:site_name\" content=\"Latest News from Seeed Studio\" \/>\n<meta property=\"article:published_time\" content=\"2021-04-26T02:05:57+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-09-29T08:20:27+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.seeedstudio.com\/blog\/wp-content\/uploads\/2021\/04\/ArduinoMemCover.png\" \/>\n\t<meta property=\"og:image:width\" content=\"3000\" \/>\n\t<meta property=\"og:image:height\" content=\"1750\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Jonathan Tan\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Jonathan Tan\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"15 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.seeedstudio.com\/blog\/2021\/04\/26\/managing-arduino-memory-flash-sram-eeprom\/\",\"url\":\"https:\/\/www.seeedstudio.com\/blog\/2021\/04\/26\/managing-arduino-memory-flash-sram-eeprom\/\",\"name\":\"Managing Arduino Memory: Flash, SRAM, EEPROM! - Latest News from Seeed Studio\",\"isPartOf\":{\"@id\":\"https:\/\/www.seeedstudio.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.seeedstudio.com\/blog\/2021\/04\/26\/managing-arduino-memory-flash-sram-eeprom\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.seeedstudio.com\/blog\/2021\/04\/26\/managing-arduino-memory-flash-sram-eeprom\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.seeedstudio.com\/blog\/wp-content\/uploads\/2021\/04\/ArduinoMemCover.png\",\"datePublished\":\"2021-04-26T02:05:57+00:00\",\"dateModified\":\"2021-09-29T08:20:27+00:00\",\"author\":{\"@id\":\"https:\/\/www.seeedstudio.com\/blog\/#\/schema\/person\/61e29862da8741ee517eacd92f4cd094\"},\"description\":\"When building advanced applications, a deeper understanding of Arduino memory can go a long way to help make the most of our beloved microcontrollers!\",\"breadcrumb\":{\"@id\":\"https:\/\/www.seeedstudio.com\/blog\/2021\/04\/26\/managing-arduino-memory-flash-sram-eeprom\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.seeedstudio.com\/blog\/2021\/04\/26\/managing-arduino-memory-flash-sram-eeprom\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.seeedstudio.com\/blog\/2021\/04\/26\/managing-arduino-memory-flash-sram-eeprom\/#primaryimage\",\"url\":\"https:\/\/www.seeedstudio.com\/blog\/wp-content\/uploads\/2021\/04\/ArduinoMemCover.png\",\"contentUrl\":\"https:\/\/www.seeedstudio.com\/blog\/wp-content\/uploads\/2021\/04\/ArduinoMemCover.png\",\"width\":3000,\"height\":1750},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.seeedstudio.com\/blog\/2021\/04\/26\/managing-arduino-memory-flash-sram-eeprom\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.seeedstudio.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Managing Arduino Memory: Flash, SRAM, EEPROM!\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.seeedstudio.com\/blog\/#website\",\"url\":\"https:\/\/www.seeedstudio.com\/blog\/\",\"name\":\"Latest News from Seeed Studio\",\"description\":\"Emerging IoT, AI and Autonomous Applications on the Edge\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.seeedstudio.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.seeedstudio.com\/blog\/#\/schema\/person\/61e29862da8741ee517eacd92f4cd094\",\"name\":\"Jonathan Tan\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.seeedstudio.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/d8dd1a4a7882386e8818e110c9322897?s=96&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/d8dd1a4a7882386e8818e110c9322897?s=96&r=g\",\"caption\":\"Jonathan Tan\"},\"url\":\"https:\/\/www.seeedstudio.com\/blog\/author\/jonathan-tan\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Managing Arduino Memory: Flash, SRAM, EEPROM! - Latest News from Seeed Studio","description":"When building advanced applications, a deeper understanding of Arduino memory can go a long way to help make the most of our beloved microcontrollers!","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.seeedstudio.com\/blog\/2021\/04\/26\/managing-arduino-memory-flash-sram-eeprom\/","og_locale":"en_US","og_type":"article","og_title":"Managing Arduino Memory: Flash, SRAM, EEPROM! - Latest News from Seeed Studio","og_description":"When building advanced applications, a deeper understanding of Arduino memory can go a long way to help make the most of our beloved microcontrollers!","og_url":"https:\/\/www.seeedstudio.com\/blog\/2021\/04\/26\/managing-arduino-memory-flash-sram-eeprom\/","og_site_name":"Latest News from Seeed Studio","article_published_time":"2021-04-26T02:05:57+00:00","article_modified_time":"2021-09-29T08:20:27+00:00","og_image":[{"width":3000,"height":1750,"url":"https:\/\/www.seeedstudio.com\/blog\/wp-content\/uploads\/2021\/04\/ArduinoMemCover.png","type":"image\/png"}],"author":"Jonathan Tan","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Jonathan Tan","Est. reading time":"15 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.seeedstudio.com\/blog\/2021\/04\/26\/managing-arduino-memory-flash-sram-eeprom\/","url":"https:\/\/www.seeedstudio.com\/blog\/2021\/04\/26\/managing-arduino-memory-flash-sram-eeprom\/","name":"Managing Arduino Memory: Flash, SRAM, EEPROM! - Latest News from Seeed Studio","isPartOf":{"@id":"https:\/\/www.seeedstudio.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.seeedstudio.com\/blog\/2021\/04\/26\/managing-arduino-memory-flash-sram-eeprom\/#primaryimage"},"image":{"@id":"https:\/\/www.seeedstudio.com\/blog\/2021\/04\/26\/managing-arduino-memory-flash-sram-eeprom\/#primaryimage"},"thumbnailUrl":"https:\/\/www.seeedstudio.com\/blog\/wp-content\/uploads\/2021\/04\/ArduinoMemCover.png","datePublished":"2021-04-26T02:05:57+00:00","dateModified":"2021-09-29T08:20:27+00:00","author":{"@id":"https:\/\/www.seeedstudio.com\/blog\/#\/schema\/person\/61e29862da8741ee517eacd92f4cd094"},"description":"When building advanced applications, a deeper understanding of Arduino memory can go a long way to help make the most of our beloved microcontrollers!","breadcrumb":{"@id":"https:\/\/www.seeedstudio.com\/blog\/2021\/04\/26\/managing-arduino-memory-flash-sram-eeprom\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.seeedstudio.com\/blog\/2021\/04\/26\/managing-arduino-memory-flash-sram-eeprom\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.seeedstudio.com\/blog\/2021\/04\/26\/managing-arduino-memory-flash-sram-eeprom\/#primaryimage","url":"https:\/\/www.seeedstudio.com\/blog\/wp-content\/uploads\/2021\/04\/ArduinoMemCover.png","contentUrl":"https:\/\/www.seeedstudio.com\/blog\/wp-content\/uploads\/2021\/04\/ArduinoMemCover.png","width":3000,"height":1750},{"@type":"BreadcrumbList","@id":"https:\/\/www.seeedstudio.com\/blog\/2021\/04\/26\/managing-arduino-memory-flash-sram-eeprom\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.seeedstudio.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Managing Arduino Memory: Flash, SRAM, EEPROM!"}]},{"@type":"WebSite","@id":"https:\/\/www.seeedstudio.com\/blog\/#website","url":"https:\/\/www.seeedstudio.com\/blog\/","name":"Latest News from Seeed Studio","description":"Emerging IoT, AI and Autonomous Applications on the Edge","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.seeedstudio.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.seeedstudio.com\/blog\/#\/schema\/person\/61e29862da8741ee517eacd92f4cd094","name":"Jonathan Tan","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.seeedstudio.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/d8dd1a4a7882386e8818e110c9322897?s=96&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/d8dd1a4a7882386e8818e110c9322897?s=96&r=g","caption":"Jonathan Tan"},"url":"https:\/\/www.seeedstudio.com\/blog\/author\/jonathan-tan\/"}]}},"modified_by":"Lily","views":52446,"featured_image_urls":{"full":["https:\/\/www.seeedstudio.com\/blog\/wp-content\/uploads\/2021\/04\/ArduinoMemCover.png",3000,1750,false],"thumbnail":["https:\/\/www.seeedstudio.com\/blog\/wp-content\/uploads\/2021\/04\/ArduinoMemCover-80x80.png",80,80,true],"medium":["https:\/\/www.seeedstudio.com\/blog\/wp-content\/uploads\/2021\/04\/ArduinoMemCover-300x175.png",300,175,true],"medium_large":["https:\/\/www.seeedstudio.com\/blog\/wp-content\/uploads\/2021\/04\/ArduinoMemCover-768x448.png",640,373,true],"large":["https:\/\/www.seeedstudio.com\/blog\/wp-content\/uploads\/2021\/04\/ArduinoMemCover-1030x601.png",640,373,true],"1536x1536":["https:\/\/www.seeedstudio.com\/blog\/wp-content\/uploads\/2021\/04\/ArduinoMemCover-1536x896.png",1536,896,true],"2048x2048":["https:\/\/www.seeedstudio.com\/blog\/wp-content\/uploads\/2021\/04\/ArduinoMemCover-2048x1195.png",2048,1195,true],"visody_icon":["https:\/\/www.seeedstudio.com\/blog\/wp-content\/uploads\/2021\/04\/ArduinoMemCover.png",32,19,false],"magazine-7-slider-full":["https:\/\/www.seeedstudio.com\/blog\/wp-content\/uploads\/2021\/04\/ArduinoMemCover-1536x1020.png",1536,1020,true],"magazine-7-slider-center":["https:\/\/www.seeedstudio.com\/blog\/wp-content\/uploads\/2021\/04\/ArduinoMemCover-936x897.png",936,897,true],"magazine-7-featured":["https:\/\/www.seeedstudio.com\/blog\/wp-content\/uploads\/2021\/04\/ArduinoMemCover-1024x597.png",1024,597,true],"magazine-7-medium":["https:\/\/www.seeedstudio.com\/blog\/wp-content\/uploads\/2021\/04\/ArduinoMemCover-720x380.png",720,380,true],"magazine-7-medium-square":["https:\/\/www.seeedstudio.com\/blog\/wp-content\/uploads\/2021\/04\/ArduinoMemCover-675x450.png",675,450,true]},"author_info":{"display_name":"Jonathan Tan","author_link":"https:\/\/www.seeedstudio.com\/blog\/author\/jonathan-tan\/"},"category_info":"<a href=\"https:\/\/www.seeedstudio.com\/blog\/category\/news\/\" rel=\"category tag\">News<\/a>","tag_info":"News","comment_count":"0","_links":{"self":[{"href":"https:\/\/www.seeedstudio.com\/blog\/wp-json\/wp\/v2\/posts\/42287","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.seeedstudio.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.seeedstudio.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.seeedstudio.com\/blog\/wp-json\/wp\/v2\/users\/3537"}],"replies":[{"embeddable":true,"href":"https:\/\/www.seeedstudio.com\/blog\/wp-json\/wp\/v2\/comments?post=42287"}],"version-history":[{"count":31,"href":"https:\/\/www.seeedstudio.com\/blog\/wp-json\/wp\/v2\/posts\/42287\/revisions"}],"predecessor-version":[{"id":42481,"href":"https:\/\/www.seeedstudio.com\/blog\/wp-json\/wp\/v2\/posts\/42287\/revisions\/42481"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.seeedstudio.com\/blog\/wp-json\/wp\/v2\/media\/42316"}],"wp:attachment":[{"href":"https:\/\/www.seeedstudio.com\/blog\/wp-json\/wp\/v2\/media?parent=42287"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.seeedstudio.com\/blog\/wp-json\/wp\/v2\/categories?post=42287"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.seeedstudio.com\/blog\/wp-json\/wp\/v2\/tags?post=42287"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}