How to bundle image files in sketch without separate flash card

I know the compiled arduino sketch gets uploaded to the device's flash memory. Is there any way to include image files from the source (ie: add it to the sketch) and have them also included and referenceable in the runtime? Consider pushing an image to a display or serving images and javascript files via an embedded config web server page. I don't want to encode them in long strings and I don't want to have to include a separate flash card - I want it included in my compiled sketch. This would be similar to an embedded resource in a c++ project on Windows.

Image data can be included in any program, for example as a initialized byte array.

I don't want to encode them in long strings

That is what an initialized array accomplishes. There are website calculators that create the code for you.

For more relevant information, identify the Arduino.

I wish this MKR wifi 1010 board had SPIFFS support. I could then treat it like a file system. It would be easier to upload more complex files - say jquery or many standard libraries. I am surprised none of the web server libraries cover a file system. Here is what I see for the ESP8266 implementations.

Switch to the ESP32, for which there are two file systems.

The Arduino IDE has no mechanism for including image files in code.

1 Like

Would having raw data created from the image file as an #include satisfy?

I have taken your recommendation and have delved into ESP32 world. I now see why you recommend this. Thank you for that helpful suggestion. I believe this is the microcontroller I will be more successful on. There are a lot more web server and iot projects based on that controller.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.