I want to convert const char array in PROGMEM to String. How do I do this?

const char charArray[] PROGMEM = "Some text";
  • If you mean a C++ style string, I think you just need to do this - stackoverflow.com/questions/8960087/… – Tri Aug 14 '18 at 17:23
  • No, I want to convert this in Arduino-IDE. That is not work correctly! – Mohamad_Frm Aug 14 '18 at 17:26
  • I just saw the answer and I had no idea that was even possible. I think that is your answer. – Tri Aug 14 '18 at 17:38
  • Unfortunately that is not work. Thank you, however. – Mohamad_Frm Aug 14 '18 at 17:54
  • 1
    what does this mean? that is not work .... that statement provides no useful information .... describing the actual error would help – jsotola Aug 14 '18 at 19:51

you can use a cast to __FlashStringHelper to invoke the right constructor of the String class. It is the constructor which copies the char array from PROGMEM. __FlashStringHelper is intended as return type for the F() macro.

const char charArray[] PROGMEM = "Some text";

void setup() {


  String s((const __FlashStringHelper*) charArray);


void loop() {
  • That is right, but how do this in loop or another functions? – Mohamad_Frm Aug 14 '18 at 17:51
  • PROGMEM is always global. and setup() is a function like every other so same way – Juraj Aug 14 '18 at 17:54
  • Absolutely, but when I write this code in loop, the compiler will generate this error: conflicting declaration 'String s' – Mohamad_Frm Aug 14 '18 at 17:58
  • Thanks so much. The compiler error was due to another part of my sketch. – Mohamad_Frm Aug 14 '18 at 18:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.