Skip to main content

Questions tagged [progmem]

PROGMEM is a keyword used when declaring a variable that keeps the data in flash instead of copying it into SRAM. It is part of the `pgmspace.h` library. Use this tag for discussions about using this attribute.

Filter by
Sorted by
Tagged with
13 votes
1 answer
18k views

Can I write to Flash Memory using PROGMEM?

On the documentation of Arduino, I quote: http://playground.arduino.cc/Learning/Memory Note: Flash (PROGMEM) memory can only be populated at program burn time. You can’t change > the values in ...
zzarbi's user avatar
  • 233
12 votes
2 answers
9k views

Why can I not use pointers instead of array with PROGMEM?

I'm currently changing some libraries to use flash instead of RAM for string storage so that I do not run out of SRAM on a project. Some strings in the library are declared in this manner: const ...
Cybergibbons's user avatar
  • 5,380
9 votes
3 answers
10k views

PROGMEM: do I have to copy data from flash to RAM for reading?

I have got some difficulties understanding the memory management. Arduino documentation says, it is possible to keep constants like strings or whatever I don't want to change during runtime in ...
Ariser's user avatar
  • 577
6 votes
1 answer
3k views

What are the benfits of global variables over static class members?

On an embedded system we use global variables often to keep dynamic memory consumption on heap and stack low. But global variables are also considered bad programming practice if they aren't used in a ...
Ariser's user avatar
  • 577
5 votes
4 answers
1k views

How can a function/method determine if a const array passed in is PROGMEM (flash) or not (RAM)?

Is it possible for a function/method to know if a constant array that has been passed in is in flash or RAM? If I have a method or function that receives a constant array that is in RAM, the array is ...
Casey's user avatar
  • 151
5 votes
2 answers
11k views

Using PROGMEM to store array of structs

I am hitting the limits of my arduino's SRAM and found that SRAM usage can be reduced by storing static stuff in flash memory instead of SRAM. My project can (optionally) be built with an included ...
Alex's user avatar
  • 181
4 votes
1 answer
2k views

Flash String Helper object as variable

So I have a Bunch of commonly used char arrays to build commands in my library. So to preserve memory, I have them put into flash, via PROGMEM ext, typedef const char PROGMEM ProgChar; ProgChar AT[] =...
Steven Venham's user avatar
3 votes
2 answers
638 views

How to correctly pack an unsigned long from 3 unsigned chars?

I would like to use 652 unsigned long values on an Arduino Uno, but it doesn't look like there's enough memory. I thought about the splitting unsigned long values to 3 unsigned chars to store in ...
George Profenza's user avatar
3 votes
2 answers
651 views

PROGMEM : pgm_read_float_near() equivalent for double? (Arduino Due)

I'm using an Arduino Due where double have a size of 8 bytes. In my software, I use double table const stored in prog memory, I was using an UNO before and used pgm_read_float_near() to retrieve these ...
snoob dogg's user avatar
3 votes
2 answers
3k views

How is a 41KB char array filling up 256KB of program memory?

I have an array of 41,400 elements of type char, which I am trying to put in program memory on a Mega2560. It should have 256KB of flash memory, but when I try to compile my sketch, it says the size ...
yigiped's user avatar
  • 33
2 votes
2 answers
206 views

PROGMEM char* mangled text

I wrote a program using PROGMEM for massive string arrays. One of the arrays worked, but when I added the second one, the serial output only puts out "th". Pastebin Code: http://pastebin.com/9U7QZQKn
Josh's user avatar
  • 45
2 votes
3 answers
583 views

How do I upload sketch (and parameters) through a user interface

I'm pretty new to Arduino and I'm developing my first real-world project. I have a Arduino Mega with a full working sketch in it which is going to be placed in several distant places and I have a ...
dirluca's user avatar
  • 123
2 votes
2 answers
282 views

PlatformIO and const PROGMEM

I'm using the DuinoWitchery LCD library (https://github.com/duinoWitchery/hd44780) in a PlatformIO Arduino project with CLion. The following code works if I stick it in main.cpp: // near top of class.....
Bitbang3r's user avatar
  • 543
2 votes
1 answer
398 views

PROGMEM doesn't cause Sketch size to change

I'm trying to pinpoint some strange behaviour involving the use of PROGMEM and the size of a Sketch. I've written a library that contains a number of functions, in addition to several large global ...
fritterdonut's user avatar
2 votes
1 answer
367 views

Problem when using PROGMEM on array holding notes for speaker on Arduino

The problem I've been having is a little weird. I'm trying to set up audio for my Arduino project and have been playing around with the example included in the IDE. The problem is whenever I try to ...
Jo-Bob Bubba's user avatar
2 votes
4 answers
6k views

How to pass a static const (progmem) array to a function

I'm implementing a voice synthesizer chip. To build a phrase, I create a list of phonemes like this: static const uint8_t PROGMEM heybuddy[] = { pPA5, pHH1, pEY, pPA5, pBB2, pAX, pDD2, pIY, pPA5,...
Rampant Creative Group's user avatar
2 votes
1 answer
136 views

Inherent delay running EEPROM.read()

I'm using EEPROM to store long term data for use in sketches (thanks to DarthRubik for the guidance). I store stuff like a location ("Garden") and a device name ("Greenhouse Monitor 02") plus ...
acpilot's user avatar
  • 653
2 votes
1 answer
1k views

Saving byte array in PROGMEM instead of SRAM

For an ethernet project I do, I need to store the Ethernet Shield's MAC address. I store it like that: byte mac[] = { 0x90, 0xA2, 0xDA, 0x0F, 0xE1, 0x85 }; That works OK, but in my project I need ...
Ido Daniel's user avatar
2 votes
1 answer
1k views

Better method for PROGMEM data access with multiple indirection?

-edit- This is a simplified recreation of personal learning project I have ongoing. My issue is in accessing data in flash, the path to which includes multiple layers of indirection. When the data ...
W. Barber's user avatar
2 votes
0 answers
273 views

Strange things happening with Arduino PROGMEM

I am currently working on a display library. The font should be stored in PROGMEM. The code looks something like this: unsigned int i = 0; Serial.println(pgm_read_byte(&font[1]),HEX); unsigned ...
w7sbc's user avatar
  • 21
2 votes
0 answers
525 views

Writing objects to PROGMEM

A few days ago I encountered memory problems (SRAM shortage) on my Arduino. I've read a lot and fixed the problem, now I have around 900 bytes free in SRAM. However, I still have difficulties ...
KeV's user avatar
  • 121
1 vote
2 answers
391 views

Is there a good reference for Arduino Due memory architecture and usage?

It's been harder than I expected to find a reference source or usage guide. There's a number of sources I've looked at along the road to this question: The Due is listed here and here as having 512KB ...
RowanP's user avatar
  • 869
1 vote
1 answer
98 views

Is there a way to "list" (in BASIC, or "cat" in LINUX) the current sketch loaded in my xxxDUINO? [duplicate]

I was surprised when I couldn't find an old post where someone asked this question. Seems like a natural beginner, uh excuse me, "newbie" question, but then I'm a throw-back to the days when a home ...
user avatar
1 vote
2 answers
253 views

Possible to determine at runtime whether a pointer is declared PROGMEM?

Is it possible to determine at runtime whether a pointer points to PROGMEM'ed values or regular values? This would give some flexibility when writing code that handles both.
Ana's user avatar
  • 480
1 vote
1 answer
757 views

Read bytes from PROGMEM array

Disclaimer: I just started using C++ and I'm a bit of a beginner. Keep that in mind as your answering. So I recently bought my first Arduino. It's a customized one and it has an 8x8 display attached ...
gurkensaas's user avatar
1 vote
2 answers
878 views

Printing elements of char array from PROGMEM

Given: const char* PROGMEM names[] = {"Foo","Bar"}; Serial.print(names[0]); I get garbage output. Is there some function that will print the string from PROGMEM? E.G.: Serial.print(<function ...
Bob Jones's user avatar
  • 131
1 vote
1 answer
709 views

Initialize and read from a PROGMEM array of pointers to PROGMEM arrays

I'm working on a project for the arduino uno for which I need multiple constant arrays of bytes. Such an array is initialized like so: const byte charR[] PROGMEM = { B01111111,//top half ...
Bo Thompson's user avatar
1 vote
1 answer
557 views

PROGMEM Corrupted Array

I am trying to store a large number of values into a couple of arrays using PROGMEM, but I am finding that a few of the values are read back corrupted. I am storing just 1s and 0s, but when I read ...
KaYBlitZ's user avatar
1 vote
1 answer
2k views

PROGMEM on Arduino Due (ARM Cortex M3)

I've been working with the PROGMEM function on my Arduino Uno and I'm thinking about changing to the bigger Arduino Due which is based on a ARM Cortex M3 processor instead of the AVR processor on the ...
tr01's user avatar
  • 117
1 vote
1 answer
606 views

Reading a 10-byte buffer out of a PROGMEM string stored in a string table

I'm storing a large snippet of text in three separate PROGMEM char arrays: const char script1[] PROGMEM = "...."; const char script2[] PROGMEM = "...."; const char script3[] PROGMEM = "...."; The ...
jozilla's user avatar
  • 43
1 vote
1 answer
650 views

Possible to "inline" PROGMEM strings into a structure array initialization?

I have the following structure: struct inst_t { const char *s1; const char *s2; }; I'd like to initialize a constant array of this structure like this where all the strings are PROGMEM'ed: ...
Ana's user avatar
  • 480
1 vote
1 answer
169 views

PROGMEM for IR command storage

I'm working on a code that is able to send raw data as IR signal to IR transmitter, the memory of arduino Nano is not enough to store the array in SRAM storage,so i'm about to use PROGMEM to store ...
M sayeh's user avatar
  • 31
1 vote
1 answer
133 views

Arduino Program Memory Ran Out

I have a Arduino sketch I made and I have run out of dynamic memory on my Arduino Nano. How could I possibly reduce the amount of memory the program takes? (I'm not that good at this stuff) P.S: The ...
JustAnotherBitcoin's user avatar
1 vote
2 answers
1k views

Arduino memory issue with old HP HDSP-2000 display chips

I'm running into memory issues with an Arduino Nano driving some old HDSP-2000/HDSP-2011 chips. I cannot seem to get the ASCII 5x7 array into PROGMEM and have it read properly. It's so low on memory ...
MEANMACHINE's user avatar
1 vote
1 answer
109 views

Sketch stops printing after writing a few times

I am trying to build a random horoscope printer. I have a series of strings in an array which I am storing in program memory. I then pick a random number and print that index concatenated with a title....
Tom's user avatar
  • 165
1 vote
0 answers
182 views

Using a 48 characters char[] for PROGMEM

I am trying to create a charliplexed display of 6x8 LEDS using a Arduino Nano with the ATMega328p chip. Because of the limited storage I am trying to use PROGMEM. I did my research and found some ...
sdieters's user avatar
0 votes
2 answers
889 views

Initialize object with PROGMEM constants

I have a class which has a const char * property: class A { public: const PROGMEM char* text; }; void setup() { // A a{"Hello World!"}; // A a{PSTR("...
zhekaus's user avatar
  • 439
0 votes
1 answer
140 views

Unrecognizable Message From PROGMEM char*

I'm using a PROGMEM char* to store a massive array. When I try to print a certain part of the array, the message comes out mangled. How do I fix this? The output should be "Poliwag", but it comes out ...
Josh's user avatar
  • 45
0 votes
1 answer
758 views

Read nested array item from PROGMEM

I have a 2D array of uint16_t arrays (IR Remote Codes). Due to the size of this data in RAM I'm having all kinds of trouble when my array is larger than one code. Thus, I have been trying to move this ...
Aaron Ciuffo's user avatar
0 votes
3 answers
354 views

How to store IR data needed for AC controll in less space?

I'm trying to controll an AC unit but the issue is space - right now, I store the data like this: consts PROGMEM unsigned int Signal_Heat_Fan0_Temp30[] = {233,636,17884,3032,8944,500,496,492,1496,524,...
vlad b.'s user avatar
  • 719
0 votes
1 answer
2k views

Arduino IDE: How to get PROGMEM const length?

I have defined a byte array as a constant in the Atmel's flash memory: const uint8_t eye [] PROGMEM = { 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff, 0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff }; How ...
needfulthing's user avatar
0 votes
3 answers
5k views

Storing array in PROGMEM

I have an array of a lot of numbers (1 and 0) but i can't store them since arduino does not have enough space. How can i save an array of example 00110 in PROGMEM, then read from PROGMEM and set x to ...
Arduino's user avatar
  • 11
0 votes
1 answer
322 views

Unusual behaviour when moving data to PROGMEM

I've got some working code with a definition that looks like this: const unsigned char DynTextPositions[10][4][4] = { ... }; Which is defined / referenced via a header: #include <avr/...
Polynomial's user avatar
0 votes
1 answer
106 views

strcpy_P increases IROM usage by 400%

Using ESP8266 (NodeMcu 1) in Arduino IDE: I can't upload my sketch because a single call to strcpy_P seems to increase the IROM usage by about 400%: 25% total usage without the call, 100+% with the ...
user187's user avatar
  • 13
0 votes
1 answer
880 views

How to create large progmem arrays and not annoy the linker

I have a rather complex project (PlatformIO, but I've also had this happen in the vanilla IDE) with several nested includes. Let's say that there are three files and a main sketch. The main sketch ...
user avatar
0 votes
1 answer
2k views

Use of progmem in ESP8266 vs AVR and also how to handle large dynamic strings

This is a somewhat tricky question dealing with implementation and best-practices of the ESP8266. I'd ideally hope that it's answered by people with in-depth knowledge on the problem. As you are ...
user avatar
0 votes
2 answers
119 views

ATmega328, arduino nano v3 code error saying insufficient ram memory [closed]

the code error says this and im not sure what to do please i need urgent help :(` // Easy bluetooth controlled scrolling text // by Yoruk for Instructable // 26 02 15 : first code // 03 03 15 : ...
Sam's user avatar
  • 1
0 votes
2 answers
2k views

PCM audio, PROGMEM sounds through speaker, multiple clips (using speaker_pcm)

I downloaded the PCM Audio speaker_pcm (see link below) and it worked easily with the supplied Mac startup chime. I also got my own sounds parsed properly via a combination of sox and wav2c ...
Pete Zelchenko's user avatar
0 votes
1 answer
216 views

question about progmem

I have a problem understanding the following code: PROGMEM prog_uint16_t x={1232,3232,43343}; rawlen = pgm_read_word_near(x); memcpy_P(uSendBuff, pfSendBuff+1, rawlen * sizeof(uint16_t)); Why do we ...
john's user avatar
  • 1
0 votes
1 answer
81 views

Send a 2d PROGMEM array over SoftwareSerial

I have a 2d array: const byte messages_for_measurement[2][8] PROGMEM = { { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08 }, { 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10 }, }; I want to send ...
user1584421's user avatar
  • 1,405