Raspberry Pi Pico ILI9341 display tutorial using CircuitPython

Dear friends, welcome back! In this video I am going to show you how to connect this 2.8” colour TFT display with a Raspberry Pi Pico board. I will also show you how to use it with CircuitPython and I will share with you 3 useful projects to help you get started and save you a lot of time. Let’s start.

Intro to the Project

This Colour TFT display is one of my favourite displays of all time. I have used it in many Arduino projects in the past and I really like it because it is big, inexpensive, it costs around $9, it is easy to use, it also has an SD card slot at the back, and it is a touch screen. I won’t show you how to use touch in this video, but I will create a detailed tutorial about it in the future.

The display has a resolution of 320×240 pixels and it uses the SPI interface to communicate with the microcontroller. The connection with the Raspberry Pi Pico board is very easy. All we have to do is to connect power and 6 more wires. Let’s see how to do it.

Where to get the parts

Connecting the Parts

The first pin is Vcc and we connect it to the 3.3V output of the Raspberry Pi Pico board which is here. The second pin is GND. We connect it to a GND pin of the board. The next pin is CS and we connect to the GP18 pin of the board. The next pin is Reset, so we connect it to pin GP17 of the board. Next is the DC pin. We connect it to the GP16 pin of the board. The next pin is SDI and we connect it to the pin GP11. The following pin is SCK and we connect it to pin GP10. The last pin we have to connect is the LED pin. We connect this pin to 3.3V, I connect it to the Vcc of the display like this.

Our connections are ready, let’s power up the board to see what happens. As you can see, the display works and it displays a demo script that I have already loaded in the Raspberry Pi Pico which displays and animates two gauges. As you can see, the Raspberry Pi Pico board manages to drive this big display with acceptable speed. It is not blazing fast, but it gets the job done. A faster board, like this ESP32 S2 board, will make the animations smoother. Let’s now see the software we need to use this display.

OK, as you can see the project is working fine and it displays the current date and time, the temperature right now and the min and max temperatures it recorded since powerup. If we compare the temperature readings of our project with a commercial device you can see the temperature readings are very accurate. I love this real time clock module!

Now let’s take a look at the software side of the project.

Software

In order to use the display with CircuitPython we need to download the adafruit_ili9341 library to drive the display and some other helper libraries. If you want to recreate all the projects I am going to show you need to install the following libraries and files. So you need the adafruit_ili9341, the adafruit_display_text, the adafruit_display_shapes. To install the libraries, we have to download the CircuitPython libraries bundle from this link and unzip it on our computer. Since I developed the project using CircuitPython 8 we need to download the bundle for CircuitPython 8. Now all we have to do is to locate the needed libraries and copy and paste them inside the lib folder in the CIRCUITPY drive, just like this.  Your CIRCUITPY drive should now look like this. 

We have a code.py file with the script to run on the board and a lib folder with all the libraries required. You can find links to all the files needed at the end of this article.

The first example program is a simple project which just displays a frame around the screen frame and a demo text. I am using Thonny as my editor. As you can see, the code also supports the Lilygo ESP32-S2 board or any other board that can run CircuitPython if you define the correct SPI pins here. Other than that the code is really simple, it just displays a frame and some text.

The second example is a script that displays two gauges at the screen and updates them. If you  want to run this script you are going to need this gauge library. All you have to do is to get the gauge file and copy it in your CIRCUITPY drive. Your CIRCUITPY drive should look like this. As you can see, the update speed is not the fastest but it is usable. With some optimization of the library code I believe we can achieve much better performance. Also, if we use an ESP32-S2 instead of a Raspberry Pi Pico, the update of the display is a lot faster. Cool. Let’s now see the last project I have prepared.  

The last project is a simple slideshow. The script just loads and displays 3 bitmap images which are stored in the CIRCUITPY drive. All you have to do to run this script is to copy the three bitmaps I will share with you in your CIRCUITPY drive and run this script. As you can see, the Raspberry Pi Pico struggles to display each bitmap. It takes around 5 seconds! So, probably we can’t build any games with this display, except if we do some clever coding. The cool thing though is that CircuitPython loads and displays the bitmaps in just a few lines of code. CircuitPython makes developing projects way faster and easier and that’s a huge advantage. 

Conclusion

Of course the code is simple if you know how to code in Python. If you don’t know how to code in Python or if you don’t know how to code at all, don’t worry. The fundamentals are very easy to learn. I have prepared a detailed course about Python programming for beginners on my second channel. It will teach you the basics in just a couple of hours. If you are interested in learning Python or CircuitPython check it out now, I think it will help you a lot.  Thanks for watching, I will see you next time.