Skip to content

hklchung/GettingStartedWithRaspberryPi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 

Repository files navigation

Contributors Forks Stargazers Issues


Getting Started with Raspberry Pi

A comprehensive guide on setting up your Raspberry Pi model 4B+ for beginners.
Explore the docs »

Report Error · Request Feature

Table of Contents

About Raspberry Pi

Raspberry Pi is a small single-board computer that is commonly used for rapid prototyping, IoT smart home devices and even as a regular computer. The Raspberry Pi model 4B+ was released in 2019 and is the latest, most advanced model as of writing of this guide.

Raspberry Pi model 4B+ comes with a 1.5 GHz 64-bit quad core ARM Cortex-A72 processor, on-board 802.11ac Wi-Fi, Bluetooth 5.0, full gigabit Ethernet, two USB 2.0 ports, two USB 3.0 ports, and dual-monitor support via a pair of micro HDMI (HDMI Type D) ports for up to 4K resolution . The Pi 4 is also powered via a USB-C port, enabling additional power to be provided to downstream peripherals, when used with an appropriate PSU. A labelled diagram of the described model is available below. Please note that the MicroSD card insertion slot is on the underside of the board.

Raspberry Pi supports both text-based interface (console) and a graphical user interface (GUI) which makes it easy for users to navigate and control functionalities in the system. User can also choose the Operating System (OS) on the Raspberry Pi, although Raspbian is strongly recommended for new users.

There are 40 GPIO pins on the Raspberry Pi model 4B+ with some doubling as multi-function pins that support UART, I2C and SPI communication protocols. You do not need to worry about the pins if you are simply using the board as a regular computer.

Getting Started

Parts

The easiest way to get started is to purchase a Raspberry Pi starter kit and these can be found on Amazon, eBay, or your local electronics store. However, these typically come with parts that are not needed for regular usage or that you may already have some of these parts and you do not want to purchase them again. Therefore below is a list of required components which you can indivdually source via the most convenient channel of your own choosing.

Essential

  • Raspberry Pi 4 Model B 2GB/4GB
    • 4GB is preferred as 2GB can be a bit slow if you want to control your Raspberry Pi via the GUI
  • Official Raspberry Pi 4 Power Supply
  • HDMI cable
  • MicroSD Card with NOOBS for all Raspberry Pi Boards (example)
    • preferrably at least 16GB
    • get the ones with NOOBS pre-loaded, these allow you to directly boot up your machine without further fuss when you do it for the first time
  • Mouse and keyboard
    • you cannot control the board if you do not have a mouse and a keyboard
    • ones with cable connection would be preferable

Optional

For Developers

  • Female/Female jumper wires
  • Regular jumper wires
  • Resistor 10k, 1K, 330 Ohm 1/4 Watt PTH
  • Breadboard
  • Extension board + colour ribbon cable (example)
  • Push buttons, potentiometers, photoresistors, LED 5mm (and whatever sensors/actuators you think you will need)

Booting it up

Now assuming you have purchased the aforementioned components, you can go ahead and follow the below steps to boot up your Raspberry Pi for the first time!

  1. Do not plug in your power!
  2. Plug in your mouse and keyboard into the USB2.0 ports (black)
  3. Plug in your HDMI cable to a TV or monitor, connect it to the HDMI0 port
  4. Slot in your MicroSD card with NOOBS into the MicroSD card insertion slot
  5. Ensure all the above have been connected to the board tightly and securely, then plug in the power
  6. You should be able to see rainbow gradient background on your screen followed by prompt asking for username and password
  • you may have to wait up to 1-2 minutes to see something on the screen
  • if you do not see anything after 3 minutes, this is likely due to poor connection of the HDMI cable
  • there are known issues with video outputs from the Raspberry Pi, see the guide here for solution
  1. Enter username "pi" and password "raspberry" and go through the OS update and installation process. This may take up to 20 minutes depending on internet speed.
  2. Once the Raspberry Pi has been updated, your set up is complete
  3. It is important to note that you should always shutdown your Raspberry Pi before removing power supply as this may corrupt your MicroSD card. To shutdown, simply select shutdown from the start up menu or enter the below code in the terminal.
sudo shutdown now

Usage

Install Software

You can use the Raspberry Pi as you would with any other computer. To download softwares onto your Raspberry Pi, open up Terminal from the start up menu and run the following command. (Scrot is a screen capturing application)

sudo apt-get install scrot

To see a list of softwares installed, run:

apt list --installed

Remote Access to Raspberry Pi GUI

  1. Boot up Raspberry Pi
  2. Connect the Raspberry Pi to your WiFi network
  3. Open Termianl and run the below
sudo raspi-config
  1. A window will pop up, go to Interfacing Options -> VNC -> enable VNC
  2. Download VNCViewer from here
  3. Install VNC under standard configurations
  4. While VNC is being installed, check the network IP of your WiFi by following this guide
  5. Once VNCViewer has installed successfully, open VNCViewer and paste your WiFi IP into the search bar
  6. You should now be able to remote access your Raspberry Pi GUI

Remote Access to Raspberry Pi via SSH

  1. Boot up Raspberry Pi
  2. Connect the Raspberry Pi to your WiFi network
  3. Open Termianl and run the below
sudo raspi-config
  1. A window will pop up, go to Interfacing Options -> SSH -> enable SSH
  2. Download PuTTY from here
  3. Install PuTTY under standard configurations
  4. While PuTTY is being installed, check the network IP of your WiFi by following this guide or run the command below if you have a screen and keyboard connected to your Raspberry Pi
ifconfig
  • The number under wlan0
  1. Once PuTTY has installed successfully, open PuTTY, paste your WiFi IP into the Host Name box and click Open
  2. Enter your username (pi) and password
  3. You should now be able to remote access your Raspberry Pi via SSH

Building Your First Prototype

Note: The below steps assume you have set up remote access to your RPi

  1. Boot up Raspberry Pi
  2. SSH into your RPi via PuTTY
  3. Install Cyberduck on your PC and use it to transfer PWM.py from the /Python/ folder into your RPi. To transfer file, click on Open Connection -> select SFTP (SSH File Transfer Protocol) -> enter server, port, username and password details as per PuTTY login into RPi, then transfer the selected file.
  4. Set up your pins and wires as per below
  • GPIO018 (pin 12) <=====> one regular jumper wire <=====> F1 on breadboard
  • G1 on breadboard <=====> LED anode (+)/LED cathode (-) <=====> F4 on breadboard
  • G4 on breadboard <=====> 330 Ohm resistor <=====> G10 on breadboard
  • H10 on breadboard <=====> on regular jumper wire <=====> GND (pin 6)
  1. Go back to PuTTY and execute the following command from the directory where the PWM.py file is located.
python3 PWM.py
  1. You should be able to see brightness on the LED changes continuously. To end the program, simply press control + c on the PuTTY interface.

This repo also provides 2 other python scripts that have been tested to function correctly given the right set up on your hardware.

  • BlinkLED.py allows user to control blinking of an LED through a pushbutton
  • LiveServer.py allows user to set the RPi as a server and returns the message "Got a request!" upon receving any commands from a client.

To create and edit a Python script directly in RPi, you can:

  1. Install vim (this helps your visualise your Python commands)
sudo apt-get install vim
  1. Create your Python script
touch test.py
  1. Edit your Python script
vi test.py
  1. Run your Python script
python3 test.py

Raspberry Pi 4B+ does not make it easy for the user to distinguish the pins from one another. Therefore it is highly recommended to purchase an extension board to assist with wiring. A side benefit of the extension board is that you will then not require any female jumper wires to connect your RPi. Nonetheless, below is a labelled layout of the pins on your RPi 4B+.

Contributing

I welcome anyone to contribute to this guide so if you are interested, feel free to make updates. Alternatively, if you are following this guide and found an error or missing information to assist your setup, please provide your feedback by clicking on the Report Error or Request Feature buttons at the top of the page.

Contact

Known Issues

  • If you are booting up the RPi with an HDMI connection to a monitor, the RPi may not boot up correctly with the GUI as the HDMI connection tends to be loose and the HDMI output on the RPi is known to be weak.
  • Please refrain from turning off your RPi by pulling out the power as this will lead to corruption of the SD card. You should always shutdown your RPi by clicking on shutdown if in GUI or by the command sudo shutdown -h now.

Releases

No releases published

Packages

No packages published

Languages