Raspberry Pi, Camera, and SPI Screen

838

14

Introduction: Raspberry Pi, Camera, and SPI Screen

HDMI driver screen or SPI driver screen more suitable to work with Raspberry Pi?

Raspberry Pi 3B, 4B and zero serials provide the HDMI interface that can connect an HDMI driver screen directly. The screen would show the Raspbian desktop directly, does not require programming. Although it is like the computer display to use, the HDMI screen is difficult to deeply develop for the amateur. There are lots of sizes for the screen: 3.5inch, 7inch, 12inch and more. For the portability, the size of 3.5inch is the best choice that it can be carried easily working with Pi outdoor. However, it has a hard problem that it would display all the OS desktop that the icon and word shown on the display is small and unclean to check. The HDMI screen with a small size would cause the touch mistake when touching the small icon by finger. The small words and the touch mistake are terrible and hard to use.

For the SPI driver screen, different from the HDMI driver one, it connects with the Pi by the GPIO, that the Pi outputs the data of the picture through GPIO(SPI). Although it can’t show the OS desktop directly, it is open for customers and suitable for programming that screen can display anything that you developed on the code. The SPI-driver Screen also has lots of sizes that contain 2.8inch, 3.2inch, 3.5inch and more, and the 3.5inch or 3.2inch one is sufficient to show the picture and comfortable for holding. Besides, the screen has more portability to work with PI and is cheaper than the HDMI screen.

In a word, HDMI display is suitable for applications that run on OS, while the SPI display can be more convenient for light applications such as IoT/Smart-home…
There is a combination version of Pi and the SPI driver screen developed by Makerfabs. I will use it to make a camera and show the effect which the SPI screen works with the Pi.

Step 1: HDMI Driver Screen Works With PI

Step 2: PI and SPI Driver Screen

Raspberry Pi Embedded System Development is based on Raspberry Pi Zero W. It has a 3.2inch SPI driver display with the resolution of ILI9341 and features the touch diver—XPT2046 for touch ability.

Besides, there are 2 pcs of mic array and WM8960 for audio recording& coding and a speaker for the audio output, which makes the system ready for applications that need audio recording/ outputs. It also has many GPIO ports, which can connect more than 200 kinds of sensors/actors, to create projects based on PI in few minutes.

Step 3: Camera

I purchased a camera module for Raspberry Pi online to try to take some photos. The camera module is an OV5647 one with 5 megapixels. Plugged it into the interface of Pi, I could take photos easily with it, and program the Pi to show the photo on the screen.

Step 4: Program

Expect the sketch for the camera, it has to program the Pi for the display and touch. For display, the size of the screen is 320*240 that it requires the photo must be 320*240, so you can take the photo directly with the 320*240 size, or take the high-quality photo and process it to the size.

All the sketches I used are available on Github.

1. For the camera, it has to set the config of the PI to enable the camera interface, and use the Python library (PiCamera) to drive the camera. The PiCamera library is pre-installed on Raspbian that it does not need to be installed again. There is a demo code that drives the camera to take a photo with 320*240:

from time import sleep
from picamera import PiCamera  

camera = PiCamera()
camera.resolution = (240, 320)  

camera.capture("camera.bmp")
camera.close()

2. For the display, refer to the library and demo of the Waveshare team to drive the ILI9341 screen working. Thanks to the Waveshare team again. There is a demo used in this project for showing the photo on the display:

GUI_ReadBmp("./camera.bmp");
//LCD_2IN4_Display((UBYTE *)BlackImage);

Paint_DrawRectangle(190, 280, 230, 310, BLACK, DOT_PIXEL_1X1, DRAW_FILL_FULL);
Paint_DrawString_EN(195, 285, "EXIT", &Font8, BLACK, WHITE);
LCD_2IN4_Display((UBYTE *)BlackImage);

3. What the time to take a photo, it can be decided by touching the screen. As the picture shown, the touch IC(XPT2046) connects with PI through SPI, it can be used the library which comes from here to check the screen whether and where is pressed. When touching the center of the screen, the PI will execute the camera code mentioned above to take a photo and then display the photo on the screen.

Step 5: Take Photo

I prepared a light lithium battery for Pi, that can carry outdoor and take photos everywhere. Press the screen center, it will take a photo and show it on the screen.

Step 6:

Besides, the SPI screen and HDMI screen works with PI in different ways, so actually, if you need, you can use the SPI screen& normal HDMI screen simultaneously in your projects.

Be the First to Share

    Recommendations

    • Robots Contest

      Robots Contest
    • 3D Printed Student Design Challenge

      3D Printed Student Design Challenge
    • Audio Challenge

      Audio Challenge

    Comments