10 Things to Know Before Starting a Raspberry Pi Project

Contributed By Digi-Key's North American Editors

2017-02-22

The Raspberry Pi is at the center of a revolution that has put the power of a PC in the hands of the masses, providing an easy-to-use platform with a wide ecosystem of support. As intuitive and easy to use as the platform may be, both engineers and beginners can benefit from a few tips from those who have already used the Pi.

These “10 Things to Know” are not intended to be comprehensive as there is continuous online community support for that. They are some nuggets that may not be found in any one guidebook or tutorial, but have been acquired through hard-won experience. It includes advice and tips from choosing and formatting SD cards, selecting power supplies for the Raspberry Pi, choosing the right Wi-Fi dongle, programming tips, what to do when the system freezes, and how to avoid destroying the board by powering it correctly.

A quick scan through these quick tips will go a long way toward making the first encounter with a Raspberry Pi, and the power of single board computing platforms in general, an enjoyable one.

1: Where and when to use the Raspberry Pi

The price, performance, and support community behind the Raspberry Pi makes it really hard to not use it for every conceivable task. It’s essentially a personal computer. For example, take the Raspberry Pi Foundation'sRaspberry Pi 3 Model B. It is based on an ARM® Cortex®-A53 running at up to 1.2 GHz. This is supported by 1 Gigabyte of RAM, 802.11n wireless LAN, Bluetooth 4.1 and Bluetooth low energy, 4 USB ports, 40 GPIO pins, full HDMI port, Ethernet, 3.5 mm audio jack and camera and display interfaces.

Figure 1: The Raspberry Pi Foundation's Raspberry Pi 3 Model B is based on an ARM Cortex-A53 running at up to 1.2 GHz and with 1 Gigabyte of memory and 802.11n wireless LAN connectivity. (Image Source: Raspberry Pi Foundation)

While it can do almost anything from reading a temperature sensor and controlling a mechatronic system of motors and pistons, all the way to a full-scale PC, some interesting and fun projects include video manipulation, robotics, and remote 3D printer control.

2: Getting up and running with a Raspberry Pi

The Raspberry Pi is intended to run an operating system rather than just code on bare-metal. The most common OS is a purpose-built flavor of Linux called Raspbian (a portmanteau of Raspberry and Debian). It can definitely run other operating systems, but for starters stick with Raspbian.

Used as a standalone computer, the Raspberry Pi will need all of the traditional peripherals, including a mouse, keyboard, SD card (Class 10, at least 8 Gigabytes, such as Apacer Memory America’s AP8GMCSH10U1-B), and a monitor.

An external SD card reader is needed to first put a Pi image on an SD card from a separate computer. Once the image is copied over to the SD card, everything else can be done from the Pi. A good option for an SD card reader is Assmann WSW Components’DA-70310-2 USB 2.0 reader that accommodates almost all popular memory-card formats.

To format the SD card, follow the link on the Raspberry Pi webpage to get the SD Association SD Card Formatter software. Use only proven software to ensure success when installing NOOBS onto an SD card. Alternatively, purchase an SD card with NOOBS pre-installed, such as the Raspberry Pi NOOBS 16 Gigabyte card.

A user can forgo the mouse, keyboard and monitor if the intention is to SSH into the Pi, or if it is being used with a touchscreen (see tip #9).

Also, unless the monitor has an HDMI input, it will need an adapter to go from the HDMI port on the Pi to the input on that monitor. For example, to bridge from HDMI to a monitor with DVI-D, use CnC Tech's741-20010-00300 (Figure 2).

Later, when embedding the Pi into a system or project, these peripherals will likely be set aside.

3: Get a proper power supply

Don’t power the Raspberry Pi from a computer’s USB port as they just don’t have the power surplus needed to prevent power related issues such as SD card corruption, Raspberry Pi freezing, and other sporadic issues. A 2 amp supply is usually sufficient, but a 2.5 amp supply is recommended for the Raspberry Pi 3.

Many of the higher-current power supplies will have a male barrel output connector. Use Adafruit’s 2727 jack-to-Micro USB A plug cable adapter with any 5 V, center-positive 5.5 x 2.1 mm barrel power supply to adapt it to the Raspberry Pi 3 (Figure 3).

The Raspberry Pi doesn’t need all that current itself. The objective is to use a supply with enough overhead so that the input voltage does not sag as other electronics and accessories are connected to the board. With that in mind, here’s a look at the general power requirements.

Depending on the model, Raspberry Pi’s draw around 100 mA to 300 mA in idle mode, with each successive iteration of the Pi drawing more current (Figure 4). If the application demands ultra-low power, factor that into the Raspberry Pi selection process.

If the Pi is going mobile, note that it may not draw enough current to allow most USB portable power banks to turn on due to the way their internal circuitry is set up. Get either the 4000 mAh model 1565 or the 10,000 mAh model 1566 battery packs from Adafruit as they have already been confirmed to work with the Pi.

4: Get or make a USB cable with an inline on/off button

Raspberry Pi’s don’t come with a reset button or power switch onboard. To avoid unplugging and re-plugging the USB cable every time the board freezes and needs to be reset, get a USB cable with an inline on/off button such as the 2379 from Adafruit. This need is a consequence of experimentation and learning. It’s inevitable that beginners will lock up the system as they progress up the learning curve. It’s much easier to have a button to press rather than a cord and connector to deal with, reducing aggravation, as well as unnecessary USB connector wear.

However, a note of caution: Under normal circumstances, don’t default to using the on/off button to turn the Raspberry Pi off. Simply killing the power can corrupt the SD card, so always follow the proper shutdown procedure (see “Where is the on/off switch”).

5: Keys to success: the Raspberry Pi accessory boards

The Raspberry Pi is a powerful SBC, but no single board computer will have everything. Fortunately, there is an abundance of readily available accessory boards for the Pi to augment its capabilities.

For instance, the Raspberry Pi has no onboard analog-to-digital converters (ADCs) for data acquisition, but there are several converter solutions. One good solution is the purpose-built 103990060 ADC and digital-to-analog converter (DAC) board from Seeed Technology (Figure 5).

More directly, there are Arduino boards that are custom made to work with the Raspberry Pi, such as Seeed’s AlaMode and DFRobot’s DFR0327 expansion shields.

Tasks that require real-time execution will definitely need an accessory board as Raspian does not do so. Raspbian/Linux divides CPU time and allocates it as needed to the applications, the Python code, and Raspbian itself. The unpredictability of this resource shuffling makes real-time execution impossible.

6: Wi-Fi dongles

The easiest way to install updates and apps onto a Pi is with an Internet connection over Wi-Fi, which the Raspberry Pi 3 has conveniently built in (802.11n). However, other versions of the Raspberry Pi do not have Wi-Fi, so it may be necessary to purchase a Wi-Fi dongle. If so, do the necessary research to be sure it is recognized by the Raspbian OS. One known good dongle for the Raspberry Pi is Adafruit’s miniature 814 802.11/b/g/n module (Figure 6).

Figure 6: If the Raspberry Pi board at hand doesn’t have built-in Wi-Fi, do the research and find a dongle like the 814 USB adapter from Adafruit that is known to work with Raspbian. (Image source: Adafruit)

7: Pay attention to output logic levels and drive capabilities

The Raspberry Pi uses 3.3 V logic levels. It’s a small but important detail that is often overlooked. The 3.3 V logic levels mean that the Pi may not work with the many devices and accessories available that require 5 volt logic. Also, its drive current is 16 mA on each pin, provided the total current doesn’t exceed approximately 50 mA. This problem is very easy to overcome with a logic level converter like the BOB-12009 bi-directional converter from SparkFun.

8: The Python programming language

Python is the default programming language for Raspbian. In fact, the Raspbian image comes pre-loaded with the Python development environment, IDLE (Integrated Development and Learning Environment). Working with Python is going to be essential for most Pi projects.

Within Raspbian, there is the option of using either IDLE 2 for running Python 2 or IDLE 3 for running Python 3. Go with IDLE 3/Python 3 to stay current and get the latest documentation.

Note that Python 2 and 3 code are not directly interchangeable. There is a lot of Python 2 code out there, so it may be tempting to go back to it from Python 3, but there areseveral differences in syntax and naming conventions that make the two versions directly incompatible. However, if the decision is made to change, it is possible to sift through code and make the changes needed to convert Python 2 code to Python 3 and vice-versa.

The fastest way to start building personalized GUIs for Python programs is with a set of tools called TkInter, which is already bundled with Raspbian. There are a lot of short tutorials online for TkInter to help a user get started quickly.

For those new to programming in general, it’s advisable to break the project down into basic building blocks. For example, take a project that involves outputting to an LCD, reading from an SPI-connected sensor and getting user inputs from three buttons. Write a separate piece of code for each task. Writing it all at once may lead to errors and make debugging harder.

9: Screen size

When programming, use a large display instead of a tiny 3 inch display that sits on top of the Pi as they are difficult to read. While good for a final custom interface for a project, it’s better to have a full-sized monitor or even a 7 inch touchscreen display like the 8997466 LCD from the Raspberry Pi Foundation (Figure 8). Depending on which Raspberry Pi is being used, this display may not be auto-detected through the DSI connector. If the Pi model requires the screen to be manually enabled, Github documents this procedure.

Don’t power the Raspberry Pi through the GPIO pins. It can be done, but it means bypassing the on-board fuse. The fuse is self-resetting and can be replaced if necessary. If power is routed through the GPIO and something pops, it will in all likelihood have destroyed the Pi.

Figure 10: The Raspberry Pi 3 on-board, self-resetting fuse (red arrow) will be bypassed if the user opts to route power through the GPIO. This puts the board at risk. (Image source: Digi-Key Electronics)

If using a Raspberry Pi for development, backup all files. It is likely that at some point the image on the SD card will get corrupted, making the data unrecoverable. Sidestep the risk altogether by using a USB jump drive such as Apacer’sAPHA016G2BACG-DTM 16-Gigabyte USB drive as the file repository.

Figure 11: Saving files to a USB drive will protect them in case of corruption of the Raspberry Pi’s file system. (Image source: Apacer Memory America)

Conclusion

The Raspberry Pi is famously powerful, easy to use and well supported. It is an excellent foundation upon which to build a professional application or a fun project. Regardless of background and skill level, these tips will shorten the learning curve, accelerate time to market, and make the whole process more productive.

Disclaimer: The opinions, beliefs, and viewpoints expressed by the various authors and/or forum participants on this website do not necessarily reflect the opinions, beliefs, and viewpoints of Digi-Key Electronics or official policies of Digi-Key Electronics.