Skip to content

4 SD card stores images and displays them locally

Welcome to the application tutorial of Lesson 4. The effect to be achieved in this lesson is to store the images that need to be displayed on the SD card and display them on the CrowPanel ESP32 Advance HMI.

This lesson requires everyone to prepare an SD card to store pictures. And a card reader.

1 Select the photos you want to display on the browser and save them on the desktop (the save path can be customized)


1

2 Modify the resolution of the image based on the size of the product you are using.


This is the resolution size we accept for each size product.

2

Here, for large-sized products, I will take the 2.4-inch product as an example to introduce how to modify the resolution of images.

The resolution of the 2.4-inch product is 320x240.

(Note: The image resolution of 7.0-inch, 5.0-inch, and 4.3-inch products is consistent, and the code and image can be used interchangeably.)

Click on the link below to download the materials used in this lesson.

CrowPanel-Advance-7-HMI-ESP32-S3-AI-Powered-IPS-Touch-Screen-800x480/example at master · Elecrow-RD/CrowPanel-Advance-7-HMI-ESP32-S3-AI-Powered-IPS-Touch-Screen-800x480

image-20260601150615266

First, open the "paint" tool on the computer.

3

Drag and drop the image into the "paint" tool to readjust the pixels of the image

(Images can be uploaded to the browser and selected according to everyone's preferences)

4

5

Adjust the pixel to 2.4-inch screen resolution: 320x240

(If you are using a different size, please set the correct resolution)

Can be referred to:There are resolutions of different sizes as references above. (Second point)

6

Click confirm

7

Adjust the resolution of the image as shown in the picture

8

Save to a folder for easy use (folder path can be customized)

9

Save in BMP format (must have a 24 bit image depth)

10

Insert the SD card into the card reader

11

Open the SD drive, copy the modified image to the SD drive and save it

12

Exit the SD card and remove the SD card

3 Insert the SD card containing this saved image into your CrowPanel ESP32 Advance HMI


13

(2.4 inch, 2.8 inch, 3.5 inch products can be directly inserted for use)

14

(After inserting the SD card, turn the function switch to 1 1 mode (TF Card mode) for 4.3-inch, 5.0-inch and 7.0-inch.)

4 Open the code we provide, and you only need to modify the path and name of the image you saved


Click the link below to download the code for this lesson.

Code Link:

CrowPanel-Advance-7-HMI-ESP32-S3-AI-Powered-IPS-Touch-Screen-800x480/example at master · Elecrow-RD/CrowPanel-Advance-7-HMI-ESP32-S3-AI-Powered-IPS-Touch-Screen-800x480

image-20260601150741672

Modify the path of the image you saved

17

Here, my path is the five images in the current path on the SD card

So the path of my image is the current path "/" plus the image name (1. bmp)

18

Then display the image in the loop and set the resolution size

(different sizes have different resolutions)

19

5 Configure the runtime environment and burn code


(Before burning, please replace the relevant library files according to different sizes.

How to replace, details in Lesson 2)

20

21

6 Phenomenon display


22

23

24

25

26

The five photos I saved on the SD card will be displayed in a loop.

7 Code reference


7.0-inch、5.0-inch、4.3-inch

Click the link below to download the code for this lesson.

CrowPanel-Advance-7-HMI-ESP32-S3-AI-Powered-IPS-Touch-Screen-800x480/example at master · Elecrow-RD/CrowPanel-Advance-7-HMI-ESP32-S3-AI-Powered-IPS-Touch-Screen-800x480

If your code compiles incorrectly, you can check if the ESP32 version number is correct. The ESP32 version number we need for this lesson is 3.0.2.

new-1

Secondly, please pay attention to replacing the corresponding size library file.

Select the appropriate library file based on the product screen size

Click the link below to download the relevant library files.

Library file link:

https://drive.google.com/drive/folders/1npWkVzctd7e0Y6H5hahk8uxGhy9idxCz

new-2

I will use the Advance 7.0-inch product as an example for operation

Copy the Libraries Advanced 7.0 folder

Open Arduino IDE runtime library file path

Reference path: C:\Users\14175\Documents\Arduino

new-3

Delete the existing libraries folder

new-4

Paste the copied library Advanced 7.0 folder into this path

new-5

Change the folder name to the original libraries

new-6

Library update completed, restart Arduino IDE.

When using other sizes, changing the library file is the same operation

Kind Reminder:

You are currently viewing the 7-inch product of CrowPanel Advance HMI, and the version here is V1.2.

(The following precautions are also applicable to the 5.0-inch V1.1 version.)

In terms of hardware, we use a microcontroller (STC8H1K28) to control the screen backlight and the mute function of the speaker.

advance-1.2-new

(However, there are other function interfaces that need to be written in the specific code, and you can refer to the complete code provided later.)

Explanation:

  • 0x30 is the I2C address of the microcontroller (STC8H1K28).

  • 0x5D is the I2C address of the touch IC (GT911).

  • sendI2CCommand(0x10) means sending the 0x10 command to the microcontroller (0x30) to instruct the microcontroller to set the screen brightness to maximum.

(For 0x10 mentioned above, you can replace it with the following values:

  • 0x05: Turn off the screen

  • 0x06 to 0x10: The screen brightness will gradually increase to the maximum)

To set a different brightness level, you must first send 0x10 to turn on the screen, and then send another value to adjust the brightness.

Additional notes:

For the function interface sendI2CCommand(0x10), if 0x10 is replaced with the following values, the controlled functions will be different:

  • sendI2CCommand(0x15): It means sending the 0x15 command to the microcontroller (0x30) to instruct the activation of the buzzer.
  • sendI2CCommand(0x16): It means sending the 0x16 command to the microcontroller (0x30) to instruct the buzzer to be turned off.

  • sendI2CCommand(0x17): It means sending the 0x17 command to the microcontroller (0x30) to instruct the speaker to turn on.

  • sendI2CCommand(0x18): It means sending the 0x18 command to the microcontroller (0x30) to instruct the speaker to turn off.