Appendix W: The Raspberry Pi

Signal processing does not necessarily require expensive computer systems. The Raspberry Pi is a remarkably tiny and inexpensive
computer board that is about the size of a deck of playing cards and costs as little as $38! Version 3 B+ in early 2018 has a 1.4GHz 64-bit quad-core ARMv8 CPU with 1GB RAM, 4 USB ports, 40 general-purpose input-output pins, HDMI port, 300 mbps Ethernet port, audio jack and composite video, video camera and display interfaces, micro SD card slot for mass storage, VideoCore IV 3D graphics core, 802.11ac Wireless LAN, and Bluetooth 4.2. You can get it with a bunch of installed software, including a version of the Linux operating system, a simple but effective graphical desktop modeled on Windows, a Web browser, the complete LibreOffice suite, Wolfram's Mathematica (screen shot), several programming languages, a bunch of games (including Minecraft), and various utilities. All of these are installed by default on the Raspberry Pi's operating system installer. (There is even a smaller and cheaper model called the Zero that costs just $5 for the card itself or $10 with memory card and power supply; it has less memory and smaller connectors that the other models, but because of its low cost and small size, this model is ideal in situations where it might be damaged or lost, as in rocket or balloon borne experiments).

All that you additionally need for a complete computer is a 5 volt, 2 amp power supply, a USB keyboard and mouse (which you can probably pick up at a junk shop), a TV/monitor with an HDMI input, and a mini SD card (8 to 16 Gbytes) for mass storage (you can buy this card with all the software already installed or a blank one to which you can download the software yourself). In fact, if you already have a Wi-Fi network and an Internet-connected computer, tablet, or smartphone, you don't need a separate monitor, keyboard and mouse: once it is set up, you can log onto your Raspberry Pi via your Wi-Fi network or over the Internet, using Putty (for command-line UNIX-style access) or a graphical desktop sharing system such as RealVNC (free for Windows, Mac, IOS, and Android), which reproduces the entire graphical desktop on your local device, complete with a pop-up virtual keyboard. It can also share files with Windows. The Pi has been used as a low-cost alternative for school computer labs, using its included software for both Office-type applications (Writer word processor, Calc spreadsheet, etc), and for programming instruction (Python, C, C++, Java, Scratch, and Ruby). It's also ideal for "headless" applications (i.e. without a monitor or keyboard), where it is only accessed remotely via WiFi or Bluetooth, in such applications as a network file server, weather station, media center or as a networked security camera.

For scientific data acquisition and signal processing applications, the Pi version of Linux has all the "usual" UNIX terminal commands for data gathering, searching, cleaning and summarizing. In addition, there are many add-on libraries for Python, including SciPi, NumPy, and Matplotlib, all of which are free downloads. Allen B. Downey's 164-page PDF book "Think DSP" has many examples of Python code in traditional engineering applications. There are many add-on hardware devices available at low cost, including video cameras and a piggyback sensor board that reads and displays sensor data from several built-in sensors: gyroscope, accelerometer, magnetometer, barometer, temperature, relative humidity. (It's based on the same hardware that is currently in orbit on the International Space Station).

My signal processing spreadsheets run just fine on the version of
Calc that comes with the Pi, as do the Calibration worksheets and my analytical method models (screen shot).
 For school applications, Element14 markets a Learn to Program Pack Starter Kit that includes a license for student version of Matlab for Windows or Macintosh and a Raspberry Pi 3 with MicroSD card, power supply, and enclosure (Matlab does not currently run directly on the Pi but can communicate with it). Even cheaper, Octave 3.6 can run directly on a Raspberry Pi; the screen below shows Octave 3.6 running within the Pi's built-in graphical user interface (showing off the 3D graphic functions "mesh" and "surf").

There are many laboratory and field applications, especially in combination with an Arduino micro-controller. However, the slowness of Octave (compared to Matlab), combined with the modest speed of the Raspberry Pi 3 may be limiting in some applications. (Altogether it's about 50 - 1000 times slower than Matlab on a contemporary desktop computer). Python, with comes with the Pi, is faster than Octave. Alternatively, it's possible to communicate with Raspberry Pi hardware remotely from a faster computer running MATLAB using the MATLAB Support Package for Raspberry Pi Hardware for Matlab R2016b or later, using one or more remotely accessed Raspberry Pi's for experiment control and data acquisition and local storage and doing the heavy-duty number crunching on the main computer. Or you could simply have the Pi save data or results in a shared folder that is accessed via WiFi from another computer.

Python is the primary programming language that comes with the Raspberry Pi. (This language is quite different than the older languages traditionally used by scientists, such as Fortran or Pascal, and it might be confusing for people without a computer-science background). See this comparison of Matlab and Python for signal processing applications. Here's a simple example of real-time data acquisition and plotting on a Raspberry Pi, using the commercially available add-on Sense Hat board with a program written in Python, measuring temperature as a function of time (real-time animation). If you don't have a Sense Hat, here's a version of the same Python program that plots the running average of a random number between 0 and 200 using the same autoscaling graphic technique, displaying a result that gradually settles down closer and closer to the average of 100 the longer you let it run. (This one will also run in WinPyton on a plain Windows PC). Compare this to the Matlab/Octave script that does the same thing. The execution time of the WinPython and Matlab versions is essentially the same, but in this particular case the Matlab/Octave script is shorter.

Other competing systems include the BeagleBoard and the LattePanda, a tiny Windows-10 computer board with 2 Gbytes RAM and 32 Gbytes flash storage. Many similar products are available.

This page is part of "A Pragmatic Introduction to Signal Processing", created and maintained by Prof. Tom O'Haver , Department of Chemistry and Biochemistry, The University of Maryland at College Park. Comments, suggestions and questions should be directed to Prof. O'Haver at Updated July, 2022.