Save ESP8266 RAM with PROGMEM

When [sticilface] started using the Arduino IDE to program an ESP8266, he found he was running out of RAM quickly. The culprit? Strings. That’s not surprising. Strings can be long and many strings like prompts and the like don’t ever change. There is a way to tell the compiler you’d like to store data that won’t change in program storage instead of RAM. They still eat up memory, of course, but you have a lot more program storage than you do RAM on a typical device. He posted his results on a Gist.

On the face of it, it is simple enough to define a memory allocation with the PROGMEM keyword. There’s also macros that make things easier and a host of functions for dealing with strings in program space (basically, the standard C library calls with a _P suffix).

Continue reading “Save ESP8266 RAM with PROGMEM”

What’s in a Name?

Take thirty seconds out of your day and try to make fun of the last name of the person who wrote this post. Go ahead, it’s okay. You probably won’t need more than ten seconds to come up with something that uses the same first, middle, and last letter. While nothing can be done to prevent last name-based harassment in the schoolyard, first names are another matter. [Ranthalion] recently dined with friends who are expecting twins and have yet to decide on names for them. It’s difficult enough to name one child, and we can imagine ourselves spending an entire day or two getting funny name pairs for twins out of our systems (Flora and Fauna, Scylla and Charybdis, &c). With the baby shower two weeks away, [Ranthalion] had to act fast in creating his Baby Namer.

It needed to be something he could make relatively cheaply with parts on hand. Although he made a prototype with an Arduino, he wasn’t about to just give one away. [Ranthalion]’s Baby Namer uses two arrays, one with awesome names like, well, Sharktooth Chompenstein, and one with regular names from census data such as Bob, Carol, Ted, and Alice. Things got a bit hairy with the volume of names he got from census data and he learned the value of PROGMEM for storing things.

On startup, it displays four names from the Awesome pile as a gag and then pulls from the Ho-Hum group. However, each time it pulls a regular name, there’s a 25% chance that part of an Awesome name will be included. Get thee to the gits and have a laugh at other names on the Awesome list.