Customer:
I’m trying to use the downloadFile routine to download BMP files from a URL and store them on an SD card. I’ve looked through the Inkplate documentation and tried writing code but can’t get it to work. I learn best from practical examples - could you point me to one that shows how to set up WiFi, initialize the SD card, download a BMP file from a URL, and write it to the card?
Attachment omitted in migration: image.png
Originally submitted via email support on 18 April 2025. Migrated to the forum for community visibility.
Soldered Support:
A colleague tested this and produced a working example for downloading files on Inkplate to an SD card:
/*
This example will show you how you can download a .jpg file (picture) from the web and save it to the SD card.
Want to learn more about Inkplate? Visit www.inkplate.io
Looking to get support? Write on our forums: https://forum.soldered.com/
24 April 2024 by Soldered
*/
#include "Inkplate.h" //Include Inkplate library to the sketch
Inkplate display(INKPLATE_1BIT); // Create an object on Inkplate library and also set library into 1 Bit mode (BW)
const char ssid[] = ""; // Your WiFi SSID
const char *password = ""; // Your WiFi password
const char *url="https://i.imgur.com/IQyUqZ8.jpeg"; //Random meme found on imgur for example
SdFile file; //Create an instance of the sdfile object
void setup()
{
Serial.begin(115200);
display.begin(); // Init Inkplate library (you should call this function ONLY ONCE)
display.clearDisplay(); // Clear frame buffer of display
display.display(); // Put clear image on display
display.print("Connecting to WiFi...");
display.partialUpdate();
display.connectWiFi(ssid, password);
while (!display.isConnected())
{
delay(500);
display.print(".");
display.partialUpdate();
}
display.println("\nWiFi OK! Downloading...");
display.partialUpdate();
if(!display.sdCardInit()) //Check if sd card was successfully initialized
{
Serial.println("SD card init failed!");
while(1){}
}
int32_t size=0; //This variable will hold the size of the downloaded file
//The memory at which the file was downloaded
uint8_t *buffer_ptr=display.downloadFile(url, &size);
//Create the file and open it in write-only mode
if(!file.open("dog.jpg",O_CREAT | O_WRONLY))
{
Serial.println("Failed to open file!");
while(1){}
}
//Write the downloaded data from the buffer in memory
file.write(buffer_ptr,size);
file.close();
display.disconnect();//Disconnect the WiFi
}
void loop()
{
// Nothing...
}
This worked on Inkplate 10.