I have a text file with hex values formatted in the following style:

A0 3F 55 01 00 C7 55 01 00 C7 AA 29 71 11 00 0B
00 C7 AA 29 71 1F AA 29 71 11 55 01 A0 3F 55 DC

How can I save this data into my Arduino's Flash (to save RAM)? What libraries are needed? Is there any tool that can automatically create code for this purpose?

After I save this data into the Arduino's Flash, I want to send the data via Serial. I have to send it as binary.

A solution without saving it into the Flash would be also OK.

I am using an Arduino Due.

  • Flash program memory or flash EEPROM?
    – Nick Gammon
    Jan 3, 2017 at 9:43
  • Flash program memory. Jan 3, 2017 at 9:51
  • Use objcopy to turn it into a .o file, fabricate an appropriate .h file containing the symbols in the .o file, and then compile against the .h and link against the .o. Jan 3, 2017 at 10:28
  • 2
    Replace the spaces with ,, prepend 0x to the start of each pair, so you get 0xA0, 0x3F, 0x55, ..., then wrap it in const byte myData[] PROGMEM = { ... your data ... }; - Personally I would write a small script to do it in Perl or PHP (I loathe Python with a passion).
    – Majenko
    Jan 3, 2017 at 11:27

1 Answer 1


If I understand your question correctly, you need to integrate this data into a .ino script. Probably as a byte array. Then the script can read the array and Serial.write its content.

You could write a small tool in Python or else on your computer, that takes the text file and converts it into a .h header. Include that into your .ino script. Or use your favorite text editor to format the data into C++ code, and copy/paste that into your script.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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