Sitemap

Getting started with Raspberry pi

13 min readOct 23, 2023

--

Press enter or click to view image in full size

Introduction

Raspberry Pi is a credit-card-sized single-board computer designed for educational and DIY purposes.

The Raspberry Pi is distinguished by its minimalistic design, which features a compact form factor with a CPU, RAM, storage, and several communication connectors. Although it commonly runs on a Linux-based operating system like Raspberry Pi OS (formerly known as Raspbian), it can also support other operating systems, improving its usefulness.

The accessibility of the Raspberry Pi is one of its main draws. It is an ideal platform for learning programming and electronics, making it an excellent choice for educators teaching computer science and robotics concepts. DIY projects ranging from media centers and retro gaming consoles to home automation and IoT (Internet of Things) applications are perfect for hobbyists and tinkerers.

Are you interested in building your own server?

Raspberry Pi can be configured as a server for tasks like hosting websites, running game servers, or managing files! Its GPIO pins allow hardware interaction, enabling robotics and home automation projects. It supports various operating systems, like Raspberry Pi OS, and offers a range of models with differing capabilities. Whether you’re a beginner or an experienced tinkerer, Raspberry Pi provides a versatile and affordable tool for various creative projects.

Would you be intrigued by creating your own personal AI assistant like Jarvis?

Raspberry Pi can be a crucial component in bringing this concept to life. You can develop a basic AI assistant by combining Raspberry Pi’s computing power with voice recognition software and natural language processing libraries. Additionally, integrating sensors, cameras, and speakers can enhance its capabilities, enabling features like home automation, voice-controlled devices, and facial recognition. With the Raspberry Pi’s versatility and the open-source community’s support, building your very own Jarvis-like AI assistant becomes an exciting and achievable project.

A device 2,000 times more potent than the Apollo 11 moon mission, the power of Raspberry Pi is literally in your hands. All you have to do is learn how to use it efficiently.

Features

The Raspberry Pi offers several features and advantages, making it a compelling choice over other computing platforms for various applications. Here are some key features and reasons to use a Raspberry Pi:

  1. Compact Size: The small form factor of the Raspberry Pi makes it easy to integrate into projects with limited space requirements.
  2. Low Power Consumption: Raspberry Pi consumes very little power, making it energy-efficient and suitable for battery-powered and low-cost projects.
  3. Broad Hardware Compatibility: Raspberry Pi supports various hardware peripherals and accessories, including cameras, displays, sensors, and HATs (Hardware Attached on Top) for additional functionality.
  4. GPIO Pins: Raspberry Pi boards come with GPIO (General-Purpose Input/Output) pins, allowing easy interfacing with external electronic components and sensors, making it ideal for prototyping and DIY electronics projects.
  5. Multiple Models: Raspberry Pi offers various models with different specifications to suit different needs, from basic computing tasks to more demanding applications.
  6. Operating System Choices: Raspberry Pi supports multiple operating systems, including Raspberry Pi OS (based on Debian), Ubuntu, and various other Linux distributions, allowing users to choose the one that best fits their project requirements.
  7. Educational Tool: Raspberry Pi was initially designed to promote computer science education, making it an excellent tool for teaching programming, electronics, and robotics concepts in schools and other educational settings.
  8. Upgradability: While Raspberry Pi models evolve, they typically maintain backward compatibility with accessories and software, ensuring that your investment remains relevant for years.
  9. Open Source: Raspberry Pi is built on open-source principles, which means the hardware and software are available for inspection and modification, fostering innovation and customization.
  10. Versatility: Raspberry Pi can be used for a wide variety of applications, including but not limited to:
  11. Media centers (using software like Kodi or Plex).
  12. Retro gaming consoles (with emulators).
  13. Home automation and IoT projects.
  14. Network-attached storage (NAS) solutions.
  15. Robotics and automation projects.
  16. Web servers and programming experiments.
  17. Community and Support: The Raspberry Pi community is vibrant and extensive, providing many resources, tutorials, forums, and community-driven software and hardware projects. This support network is invaluable for beginners and experienced users alike.

Getting Started with Raspberry Pi

The Raspberry Pi, as a device, comes with nothing( literally nothing!!) other than a board. So, you need to order or ensure you have these necessary items:

1. Power Adapter: A 5V 3A or higher-rated power adapter with a USB-C output is essential, especially if you plan to use a display.

2. SD Card: Your SD card should have ample storage capacity and be Class 10. Remember that this card will be your primary storage, housing the operating system and loading data into RAM. Choosing a lower-class card may lead to regrets due to slower performance.

3. Heat Sinks and Cooling Fan: Investing in heat sinks and a case with a cooling fan is highly recommended. Raspberry Pi tends to get hot during operation, and these accessories can help keep it running smoothly(something similar, as shown in the figure).

4. Necessary Cables and Adapters: You’ll need a micro HDMI to HDMI adapter and a standard HDMI cable. Additionally, consider a micro HDMI to HDMI cable for convenience.

5. Mouse and Keyboard: Don’t forget to have a USB mouse and keyboard on hand.

Now, let’s dive into the process of setting up your Raspberry Pi:

Even if you don’t have a monitor, keyboard, or mouse and want to access pi remotely, don’t worry. We’ve got you covered.

Unboxing your Raspberry Pi is exciting, but it won’t power on like a smartphone or laptop with just a button press. There’s some extra work involved, but fear not; we’ll guide you through the entire process. Get ready to roll up your sleeves, get your hands dirty, and embark on this fun and educational journey.

INSTALLING THE OS

(here, we are using the official Raspbian OS only)

Flashing OS to your SD card.

Flashing an SD card means writing an image file of an operating system to the card. It differs from copying and pasting data because flashing creates a bootable partition on the card that the Raspberry Pi can read. Flashing also erases any existing data on the card, so you need to format it before flashing.

To flash an SD card for Raspberry Pi, you can use a software tool like Raspberry Pi Imager(in this session, we are using only Raspberry Pi Imager) or Etcher2 or a command line tool like dd3. You need to download the image file of the operating system you want to use, such as Raspberry Pi OS, and select the SD card as the target device. Then, you must click the flash button and wait for the process to finish. After flashing, you can insert the SD card into your Raspberry Pi and power it on.

We will take the example of Raspberry Pi Imagerthe following will be your steps

1.

Press enter or click to view image in full size

Visit the official Raspberry Pi website and navigate to the ‘Software’ section. On this page, you can download the software that matches your operating system requirements.

2. After a successful installation, launch the application. In the ‘Operating System’ option, select your desired OS. In this guide, we will install the Raspberry Pi OS 64-bit with a desktop for simplicity. Also, choose your storage device, which, in this case, is your SD card.

If you plan to proceed with headless or remote login, it’s essential to focus on enabling SSH and automatic Wi-Fi login (if you’re not using an Ethernet cable). Alternatively, you can allow SSH through USB-C. Please note that we won’t cover these steps in detail here, but if you require more information, you can refer to this article.

Press enter or click to view image in full size

Before clicking on write, click the settings button in the bottom right corner. This will open a page where you can customize advanced options for your Raspberry Pi image. Select the following checkboxes and enter the required information:

-Set hostname: This will let you choose a name for your Raspberry Pi that will appear on your network. Enter a name that is easy to remember and unique.

Get Elektronica IITH’s stories in your inbox

Join Medium for free to get updates from this writer.

-Enable SSH: This will allow you to access and control your Raspberry Pi using SSH remotely. SSH is a secure protocol that lets you run commands, transfer files, and configure settings on your Raspberry Pi from another device. To use SSH, you will need an SSH client on your device and the IP address or hostname of your Raspberry Pi.

-Set username and password: This will let you create a user account for logging in to your Raspberry Pi via SSH or other methods. Enter a username and password that are strong and secure. The default username is pi, and the default password is raspberry, but you should change them for security reasons.

-Configure wireless LAN: This will let you connect your Raspberry Pi to a Wi-Fi network without a cable. Enter the SSID (name) and password of your Wi-Fi network. Please make sure they are correct and match the case.

-Set locale settings: This will let you configure the keyboard layout and timezone of your Raspberry Pi. Select the wireless LAN country that matches your Wi-Fi network, then choose the time zone and keyboard layout that suit your location and preference.

Click on SAVE when you are done. This will create a configuration file in the boot partition of your SD card that will apply these settings when you boot up your Raspberry Pi for the first time.

“Hurray! You’ve completed the initial steps. You can use your Raspberry Pi directly if you have a monitor, keyboard, and mouse.”

WHAT IS SSH AND WHY SSH

SSH stands for Secure Shell and is a protocol allowing you to remotely access and control your Raspberry Pi from another device, such as a computer or a smartphone. SSH is useful because it lets you run commands, transfer files, and configure settings on your Raspberry Pi without using a monitor, keyboard, or mouse.

To enable SSH on your Raspberry Pi, you need to create an empty file named SSH in the boot partition of your SD card. You can do this using your computer before inserting the SD card into your Raspberry Pi. This file signals the Raspberry Pi to turn on the SSH service when it boots up.

Alternatively, you can use the Raspberry Pi Imager tool to enable SSH and other advanced options before flashing the SD card.

Okay, we are done setting up the Raspberry side (server host) of SSH. The next step will be towards the client side so there you can have multiple scenarios, namely if you want to access in

  1. Windows machine
  2. Linux or Mac machine
  3. Android device

We will be looking for windows first. The later cases are much easier than this, as the communication between two Linux-based operating systems is relatively simple.

Many SSH clients are available for Windows, but two of the most popular ones are PuTTY and MobaXterm.

PuTTY is a free and open-source SSH client that lets you connect to your Raspberry Pi using its IP address, hostname, username, and password. You can also use PuTTY to transfer files using SCP or SFTP protocols.

MobaXterm is a more advanced SSH client that offers many features, such as a graphical user interface, a built-in file explorer, a terminal emulator, and support for X11 forwarding. You can also use MobaXterm to connect to multiple servers simultaneously and save your sessions for later use.

Now, let’s dive into the next step. We’ll begin with PuTTY.

To install the software, visit the official website at putty.org. There, you will find the following page.

Press enter or click to view image in full size

“Choose the appropriate version based on your device. Most modern PCs or laptops use the 64-bit x86 version, except for Macs and Chromebooks. Please verify your device’s architecture.

After installation, launch the application here. You will get the configuration window as shown in the picture below. There, you need to configure the hostname or IP address to continue.

Do you remember setting the hostname in the Raspberry Pi Imager? You must enter that hostname in the ‘Host Name’ field. For the ‘Connection Type,’ select ‘SSH’ and leave the rest at their default settings. Now, click ‘Open.’

You will see something like this:

Press enter or click to view image in full size

“Ignore the warning (Although it’s essential to mention that warnings are typically issued for significant reasons. It’s advisable to delve into the details to understand why this warning appears. However, for now, let’s proceed and ignore it). After this step, you will be prompted to a login page that looks like…”

Press enter or click to view image in full size

Log in with the previously provided credentials, and you will gain access to your host server’s shell, which will be your Raspberry Pi.

Setting up a server with Raspberry Pi

We are now all set to start a project on the Raspberry Pi. In this project, we will create a simple server using Python. Yes, Python! You might wonder why we’re not using Nginx or Apache, which are more powerful web servers. The reason is simple — Python is known for its user-friendliness and is an excellent choice for learning, especially for beginners.

Before we dive into Python, let’s ensure you have it installed. Raspberry Pi OS typically comes with Python pre-installed. However, in case it’s not available, don’t worry. Since the OS is Linux-based, we can use APT (Advanced Package Tool), a collection of tools used to install, update, remove, and manage software packages on Debian and its derivatives, including Raspberry Pi OS, Ubuntu, and Linux Mint. Think of it as a kind of app store for Linux.

To install Python 3, open your terminal and run the following commands:

$ sudo apt-get update
$ sudo apt-get install python3

These commands will install Python 3 on your Raspberry Pi. To check if Python is installed successfully, type ‘python3’ in the terminal. You will enter the Python interpreter, which can run short scripts without saving files. It should look something like this (press ‘ctrl+D’ to exit):

Press enter or click to view image in full size
Python interpreter prompt
Python interpreter prompt

Now that we have Python ready let’s build our basic server. We’ll use modules from the `http.server` library, specifically `HTTPServer` and `BaseHTTPRequestHandler`. These modules are crucial in providing the necessary actions for handling client requests.

When you open a link in your web browser, the client sends HTTP requests to the server. Our server, powered by Python, should be able to handle these requests and respond with appropriate data.

Below is the Python code to set up a simple server:

Press enter or click to view image in full size

We understand this may seem overwhelming, but don’t worry. You don’t need to grasp every detail at the beginning. What’s important to know is that when you load a link in your browser, the client (browser) sends requests, and the server decides which files or data to send in response. In the code provided, we’re creating a basic HTML file within the code itself. The line `self.wfile.write(lines.encode(‘utf-8’))` does this job. The Simple Handler we’re using determines the behavior of your server, and you can integrate various functionalities like GPIO for home appliances, files, media, or anything you can imagine.

To run this Python script, open your terminal and type `python3 projectname.py`. Your server will be hosted on your designated port. But how can you access this webpage? You don’t have a link or web address. Instead, you’ll use your IP address, followed by the port number. In real life, any link or web address corresponds to an IP address, which is the job of DNS servers. However, you’ll use your IP and the port number to access your site here.

To find your IP address, type the following command on your Raspberry Pi:

hostname -I

(Note: The ‘I’ in ‘hostname -I’ is uppercase, and there is a space between ‘hostname’ and ‘-I’.)

Once you have your IP address and port number, open a web browser on any device connected to the same LAN (router). In the URL field, type your IP address followed by the port number. For example, if your IP is 192.168.0.165 and the port number is 8000, your URL will be:

```
192.168.0.165:8000
```
Press enter or click to view image in full size
You should then see your webpage, somewhat like this

Vola, you successfully created a server…

End of the Road, Start of a Journey. As you embark on your Raspberry Pi journey, you’ll discover endless possibilities. Whether you’re building a home automation system, a retro gaming console, or a DIY weather station, this versatile little computer can bring your ideas to life. Remember, the only limits are the ones you set for yourself. So, dive in, explore, and don’t be afraid to experiment. Happy tinkering!

This article is designed by the core members of Elektronica, The Electronics and Signal Processing Club of the Indian Institute of Technology, Hyderabad.

Authors: Nanjundaradhya H Y, Gunethra Bommineni, Manan Mittal, Yogitha Reddy.

Disclaimer: The information provided in this article is for educational and informational purposes only. No data or software mentioned or used in this article is owned by the authors or Club Elektronica. All copyrights and trademarks mentioned are the property of their respective owners.

--

--

Elektronica IITH
Elektronica IITH

Written by Elektronica IITH

Electronics and Signal Processing Club of IIT Hyderabad