One of the world’s most popular single-board computer (SBC) platforms is the Raspberry Pi. It’s not just a popular platform in industry, it’s also a low-cost, highly versatile computer that sometimes appears in commercial and industrial settings. It continues to be one of the most successful SBCs, with several forums and peer support resources available to aid designers.
In its early phases, Raspberry PI was mostly used for hobby projects, but its role has expanded into a range of activities, such as prototyping and development before developing a new system on a custom PCB. In this article, we’ll look at some of the essential steps needed to start working with a Raspberry Pi. We’ll take users up to the point of setup and deployment of a first application on a Raspberry Pi, and we’ll discuss some of the big advantages of this platform.
Booting and Configuring a Raspberry Pi
The Raspberry Pi is an SBC, so it needs to be set up and configured just like any other computer. Note that there is also a Raspberry Pi microcontroller, but we won’t get into that board in this article and instead we’ll focus on the main steps needed for standard Raspberry Pi deployments.
First, we have a short list of required equipment:
- Raspberry Pi board
- Keyboard and mouse
- 1x micro SD card (min. 8 GB)
- USB power adapter + micro USB cable
- Monitor and cable
- Ethernet cable (if WiFi is unavailable)
Simply hook up the Raspberry Pi like you would any other computer. The Raspberry Pi also requires some power supply, although this can be provided through the micro USB port on the side of the board. There may be other hardware involved (such as a camera module), depending on your specific application.
Note that the connection to the monitor depends on the specific Raspberry Pi model you’re using. Some boards (Raspberry Pi 4 B and Pi 400) have micro HDMI output ports, so they require a micro HDMI to HDMI cable or adapter to connect to a standard monitor. Other models, like the Raspberry Pi 3B has a standard HDMI port and does not require an adapter.
Older Raspberry Pi 3 model with an HDMI port.
Embedded OS Installation
Installation of the embedded OS involves formatting the SD card with the OS image before booting the Raspberry Pi.
Raspberry Pi is compatible with a variety of operating systems, including Raspbian, Ubuntu, and others. You could also use Yocto to build your own Linux distribution. Raspbian is the official operating system for Raspberry Pi and it is an excellent option for newbies. A microSD card is required to store the operating system and any user files. The size of the card depends on the Raspberry Pi model being used, although the minimum recommended storage is 8 GB.
There are two options for installing an operating system on a Raspberry Pi:
- The official Raspberry Pi Imager, which can be downloaded from GitHub
- The Etcher application, produced by Balena Inc. and available from the company’s GitHub
The Raspberry Pi Imager will write the official OS to the SD card, while Etcher is used to write a custom image. An image for the Raspbian OS can be downloaded from the official Raspberry Pi website.
A short list of OS images available through Raspberry Pi Imager.
When configuring the OS, there are some important settings you should select that will allow the device to gain internet access, connect to another device over your local network, and maintain basic security. It is recommended to:
- Create a hostname for your board
- Set a username and password
- Setup wireless LAN settings (select the WiFI network SSID and password)
- Enable SSH connections
- Create an SSH login
The last point is very important as it allows remote management of an embedded device, including file access for data in the embedded device’s storage. You’ll then need a terminal with SSH tunneling included in order to access the deployed board. PuTTY is probably the most popular terminal application for SSH operations. However, WinSCP is very useful as it offers a graphical UI for interacting with the deployed Raspberry Pi.
After the configuration is complete, write the OS to your SD card. Once the write process completes, you can insert the card into your Raspberry Pi and power up the board.
Once the device is powered on, you now have a small form factor SBC that you can configure just like any other computer. After the Pi is up and running, it can be accessed directly, or you can open an SSH tunnel to the Pi and begin on-device configuration.
The configuration utility can be accessed from the terminal using the command:
$ sudo raspi-config
From here, you can change a range of features, such as network settings, boot options (to desktop or command line), and time zone. You can also enable the camera peripheral from this menu. Finally, you will need to use raspi-config to enable the following interfaces:
- Serial I/O
Raspberry Pi configuration utility.
Programming Languages Used in Raspberry Pi
Raspberry Pi operating systems are built on Linux. Python is the most common language used to write applications and scripts for a Raspberry Pi, although users can work with programming languages such as C++, Java, etc.
Programming Directly on the Raspberry Pi
If you want to write code on the Raspberry Pi, then installing a text editor on your Raspberry PI will ease your programming journey. A text editor is a piece of software that allows you to write and edit code, and there are many text editors available for the Raspberry Pi, such as Sublime Text, Atom, etc. The following command can be used to install a text editor:
$ sudo apt-get install <text_editor_name>
Replace <text_editor_name> with the name of the editor you want to install.
Python is arguably the preferred language to use for programming an embedded application on the Raspberry Pi. Also, Python is pre-installed with Raspbian, and you can start using it right away.
First, Python is installed on your system with the following command:
$ python --version
If Python is not installed, the command will return a “Python was not found” error. Note that, even if Python is present, there may not be an environment variable linked to the “python” command. Therefore, you should also try this command to check for a Python Version 3.x installation:
$ python3 --version
In some cases, both will be present, in which case you likely have Python 2.7 and Python 3.x installed with the same distribution. You can use either version of Python to build embedded applications on Raspberry Pi, but it is recommended to migrate to Python 3.4 or later as newer versions of common libraries are only supported with Python 3 syntax.
In either case, if Python is not installed, it can be installed using the following command from the terminal:
$ sudo apt-get update
$ sudo apt-get install python3.x
Note that you will need to replace “3.x” with your desired version number.
How to Install Python Libraries
Next, Python libraries can be installed using pip install <library_name>, which is the preferred installed program for libraries (replace “<library_name> with the package you want to download and install). If you are specifically using Python 3, you may need to use pip3 instead of pip to install packages.
Finally, some knowledge of built-in libraries and frameworks is also needed to successfully program your Raspberry Pi board to use the features built into the PCB. The Raspberry Pi has a library called RPi.GPIO that allows you to control the GPIO pins on the Raspberry Pi. This is the primary library needed to build an application that can receive signals from external devices. Make sure to install this library and include it in your embedded Python projects when accessing GPIO pins.
Expanding on the Raspberry Pi
Once the Raspberry Pi is configured, and you’ve written your first embedded application, how can you interface the board with other systems in a production environment? The simplest method is with a network connection, but this overlooks some of the core capabilities of the Raspberry Pi: exposure of digital interfaces on the PCB.
To access external components or systems, a design team can build on top of a Raspberry Pi in two ways:
- Adding a shield board (sometimes called at “hat” board)
- Mounting the Raspberry Pi on a baseboard
The baseboard method has become so popular that the newest version of the system, Raspberry Pi 4, comes in a compute module form factor. This system can mount to a baseboard and it gives designers a modular approach to building a new production-grade system. Hats are also very popular as they are interchangeable through the standard pinout on the Raspberry Pi. Either method can be used to produce a new production-grade product that runs on a proven computing platform.
When you’re ready to get started designing hardware that uses Raspberry Pi in a PCB, use the CAD tools in OrCAD from Cadence. OrCAD is the industry’s best PCB design and analysis software with utilities covering schematic capture, PCB layout and routing, and manufacturing. OrCAD users can access a complete set of schematic capture features, mixed-signal simulations in PSpice, and powerful CAD features, and much more.
Subscribe to our newsletter for the latest updates. If you’re looking to learn more about how Cadence has the solution for you, talk to our team of experts.
About the AuthorFollow on Linkedin Visit Website More Content by Cadence PCB Solutions