Making Your Raspberry Pi Display More Eye-Catching with a 3.5 Inch LCD Screen

A step by step guide on how to install a 3.5 inch lcd screen on your Raspberry Pi, making it more functional and visually appealing. …


Updated August 6, 2023

Need help with your Raspberry Pi?
Contact Me!

Do you love silly Raspberry Pi Projects?
Check out my this YouTube Channel!


A step by step guide on how to install a 3.5 inch lcd screen on your Raspberry Pi, making it more functional and visually appealing.

Prerequisites

Before you start, make sure you have the following items:

  1. A Raspberry Pi (any model)
  2. A 3.5 inch LCD screen compatible with the Raspberry Pi (with touch functionality if desired)
  3. Micro SD card (at least 8GB) with Raspbian OS installed on it
  4. Micro USB power supply or USB-C power supply for the Raspberry Pi
  5. HDMI cable or adapter for video output
  6. USB keyboard and mouse
  7. Monitor, TV, or projector with HDMI input (for temporary display while setting up the LCD)
  8. Screwdrivers, soldering iron, and solder (if your LCD screen requires soldering)

Step 1: Prepare the LCD Screen

First, prepare your LCD screen by following the manufacturer’s instructions for connections and soldering (if necessary). Some screens may come pre-soldered, while others require you to do it yourself. Make sure all the pins are securely attached and the screen is working as expected before moving on to the next step.

Step 2: Connect the LCD Screen to the Raspberry Pi

Now that your LCD screen is ready, connect it to your Raspberry Pi using the provided ribbon cable or flex cable. Make sure all the pins are securely in place and the connections are tight. The LCD should be connected as follows:

  • VCC to 5V power pin on the Pi
  • GND to ground pin on the Pi
  • DC to GPIO 24 (pin 18)
  • RESET to GPIO 25 (pin 22)
  • MOSI to GPIO 10 (pin 19)
  • SCLK to GPIO 11 (pin 23)
  • CS to GPIO 8 (pin 24)
  • D/C to GPIO 23 (pin 16)

Step 3: Install the necessary drivers

Next, you’ll need to install the required drivers for your LCD screen. Open a terminal window and run the following commands to update your Raspberry Pi and install the necessary packages:

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install raspberrypi-kernel-headers

Now download the Adafruit 3.5 inch LCD library from GitHub:

git clone https://github.com/adafruit/Adafruit_Raspberry_Pi_Python_Code.git

Navigate to the Adafruit_Raspberry_Pi_Python_Code folder and run the following command:

sudo python3 setup.py install

This will install the necessary drivers for your LCD screen.

Step 4: Enable SPI interface

To use the LCD, you’ll need to enable the SPI (Serial Peripheral Interface) on your Raspberry Pi. Run the following command in the terminal:

sudo raspi-config

Navigate to Interfacing Options and select SPI. Enable SPI and reboot your Raspberry Pi when prompted.

Step 5: Test your LCD screen

Now you can test your LCD screen using the following Python code:

import Adafruit_SSD1306
from PIL import Image, ImageDraw, ImageFont

disp = Adafruit_SSD1306.SSD1306_128_64(rst=None)
disp.begin()
image = Image.new('1', (disp.width, disp.height))
draw = ImageDraw.Draw(image)
font = ImageFont.truetype('/usr/share/fonts/truetype/freefont/FreeSansBold.ttf', 20)
draw.text((5, 10), 'Hello World!', font=font, fill=255)
disp.image(image)
disp.display()

Save this code in a file named lcd_test.py and run it with the command:

sudo python3 lcd_test.py

You should see the text “Hello World!” displayed on your LCD screen. If everything is working correctly, you can now use this display for various applications like a clock, media player, or custom dashboard.

Conclusion

Congratulations! You have successfully installed a 3.5 inch LCD screen on your Raspberry Pi and tested it with the provided Python code. This new addition will enhance the functionality and appearance of your Raspberry Pi projects, making them more visually appealing and user-friendly. With the right software and scripts, you can create all sorts of interactive displays for your home automation or other applications. The possibilities are endless, so get creative and have fun with your new LCD screen!