Rapid Development Using Raspberry Pi 3 (Versus Scarce Raspberry Pi Zero)

Contributed By Digi-Key's North American Editors

Raspberry Pi boards in all their iterations have been a boon to developers, both professionals and hobbyists alike. While the Raspberry Pi Zero has garnered much attention, it has been difficult to obtain. Fortunately designers have many other boards within the Pi family that offer superior features to meet application demands.

With its quad-core processor, the Raspberry Pi 3 offers twice the memory of the single-core Pi Zero. For developers requiring a small design footprint but are disappointed in the Pi Zero's performance, the Raspberry Pi Compute Module 3 (CM3) matches both the high performance of the Pi 3 and the credit-card-size footprint of the Pi Zero. By leveraging an enormous array of add-on hardware boards and readily available software, developers are equipped to meet a wide range of application requirements with the Pi 3 and CM3.

Getting the Raspberry Pi up and running

Raspberry Pi systems provide a robust open-source foundation that enables vendors, third-party developers, and users themselves to both leverage and contribute to an increasingly rich ecosystem of software and hardware. Originally developed by the Raspberry Pi Foundation as a low-cost platform for teaching computing, Pi hardware has evolved into a powerful yet low-cost platform suitable for rapid prototyping and, increasingly, as an embeddable computing platform.

Pi software offers a similar level of performance and accessibility. Pi boards run Raspbian, a version of the GNU/Linux operating system (OS) optimized for the Raspberry Pi boards. Developers can insert an SD card containing the Raspbian installer, NOOBS, into a Pi board's SD interface and be up and running in seconds with a familiar Linux environment.

Thanks to a very active Raspberry Pi community, developers with specific requirements can select from alternative OSs including desktop Ubuntu, Ubuntu Core, Windows 10 IoT Core, Linux-based Open Source Media Center (OSMC), and RISC OS, among others. For those distributions, developers simply need to load the system with a downloaded image stored on an SD card. Finally, software engineers can take advantage of a rich set of available software libraries supporting development in a wide variety of programming languages.

Pi slices

At the hardware level, Pi hardware has evolved into three major branches that present some notable differences in performance, size, and functionality (Table 1). Noted for its small size, the recently introduced Pi Zero serves as an entry-level board, sacrificing some functional elements for lower cost and a smaller footprint. In contrast, the Pi 3 and its embedded variant, the CM3, feature a high-performance quad-core processor and large memory, providing the kind of robust hardware platform needed for embedded applications. Furthermore, the CM3 provides nearly the same footprint as the Pi Zero without sacrificing performance or functionality.

Pi Processor Memory Size IO
Pi 3 BCM2837 (1.2 GHz 64-bit quad-core ARM Cortex-A53 with dual core VideoCore IV GPU)


NVM: Micro SD card slot

85 mm x 56 mm

Pi 40-pin header


802.11n Wi-Fi

Bluetooth 4.1




AV port

Camera interface (CSI)

Display interface (DSI)

Pi CM3 Same as Pi 3


NVM: 4 GB eMMC Flash on board

67.6 mm x 31 mm

200-pin SODIMM


2x I2C

2x SPI






Pi Zero BCM2835 (1 GHz single-core ARM1176)

512 MB RAM

NVM: Micro SD card slot

65 mm x 30 mm

Pi 40-pin thru-hole



HAT-compatible header

Composite video and reset headers

CSI camera connector

Table 1: Comparison of Raspberry Pi 3, Compute Module 3 (CM3), and Pi Zero (Source: Digi-Key Electronics, compiled from Raspberry Pi Foundation data)

Standard hardware interfaces are a critical factor in the success of a platform such as the Raspberry Pi. Recent Pi boards, including the Pi 3 and Pi Zero, offer the same 40-pin interface, which brings out 28 GPIO pins, some of which double for I2C, SPI, and UART connections (Figure 1). Along with GPIO pins, this Pi-standard interface provides 3.3 V, 5 V, ground, and other lines such as EEPROM ID. Thanks to this common pin-out, Pi users can find a broad set of add-on boards from third-party vendors, all building to this standard interface.

Diagram of Pi boards, including the Pi 3 and Pi Zero

Figure 1: Common to Pi boards, including the Pi 3 and Pi Zero, a 40-pin interface brings out GPIO and other lines from the board host processor and associated components. (Image source: Raspberry Pi Foundation)

For Pi Zero users, however, this 40-pin interface is provided as plated through-holes on the PCB, requiring the user to press fit or solder on a through-hole connector header. For the Pi 3, the connector header itself is standard (Figure 2) – as are connectors for features such as Wi-Fi and Ethernet that are not available with Pi Zero, as described in the Table.

Image of Pi Zero and Pi 3 boards

Figure 2: In providing the Pi-standard 40-pin interface, the Pi Zero (a) only offers through-hole connections while the Pi 3 (b) includes a 40-pin connector ready to accept add-on boards, called HATs (Hardware Attached on Top). (Image source: Raspberry Pi Foundation)

Add-on hardware

Because the Pi interface supplies power, ground and GPIO, developers can wire their discrete circuits directly to the Pi 3 GPIO interface pins. Rather than wiring up circuits from scratch, however, the Pi platform offers a more effective way to expand functionality of a Pi 3 system. Here, the availability of the 40-pin header on the Pi 3 provides a standard interface for add-on boards configured as HATs (Hardware Attached on Top). Thanks to this simple electrical and mechanical interface, developers can quickly enhance the base Pi 3 board with application-specific functionality. Developers simply press a Pi-compatible add-on HAT down onto the 40-pin connector – and even create stacks of add-on boards all sharing this single interface.

Developers can draw on a considerable pool of add-on boards. For example, the Pi Sense HAT includes a full set of sensors required for orientation or environment-sensing applications. In addition, it provides an LED matrix and five-button joystick for user feedback and interaction (Figure 3).

Image of Pi Sense HAT

Figure 3: Developers add functionality to a Pi board simply by plugging in HATs such as this Pi Sense HAT, which provides multiple sensors along with an LED matrix and five-button joystick for user interaction. (Image source: Raspberry Pi Foundation)

The Sense HAT is a sophisticated subsystem in its own right: Along with its own Microchip Technology 8-bit ATtiny MCU (ATTINY88), this add-on board includes an STMicroelectronics LSM9DS1 inertial measurement unit (IMU), STMicroelectronics’ HTS221 humidity/temperature sensor, and an STMicroelectronics LPS25HBTR pressure sensor.

Simple deployment

As with other Pi-compatible add-on boards, developers connect the Sense HAT to their Pi 3 system simply by pushing the HAT board down on the 40-pin header on the Pi 3. The software interface is just as easy: The officially supported Python sense-hat library hides low-level hardware interactions behind simple, intuitive calls (Listing 1).

from sense_hat import SenseHat


sense = SenseHat()


temp = sense.get_temperature()

print("Temperature: %s C" % temp)


humidity = sense.get_humidity()

print("Humidity: %s %%rH" % humidity)


# get_orientation_degrees returns a Python dictionary

# with keys pitch, roll, and yaw

orientation = sense.get_orientation_degrees()

print("p: {pitch}, r: {roll}, y: {yaw}".format(**orientation))

Listing 1: The Raspberry Pi Sense HAT library lets software developers use a few intuitive calls to acquire data from the Sense HAT hardware. (Code source: Raspberry Pi Foundation)

Besides the Pi Sense HAT, developers can find third-party HATs that address most typical application requirements. For example, the Seeed Technology 114990831 provides a 2-channel 16-bit digital-to-analog converter (DAC) and a 24-bit analog-to-digital converter (ADC), with either 8 single-ended or 4 differential input channels. Developers can find add-ons ranging from a Seeed GPS, a DFRobot ultrasonic range finding sensor, and an Adafruit stepper motor, among many others.

For developers with requirements that cannot be met with existing add-on boards, Seeed Technology offers a breakout board HAT that includes a few built-in components including P-MOS, N-MOS, NPN, and PNP transistors.

In working with HATs, developers can take advantage of a number of software tools provided by the Raspberry Pi Foundation, vendors, and other Pi community members. For example, the Raspberry Pi raspi-gpio tool lets developers view the state and modify the behavior of a GPIO. Programmers can also use this tool's open-source C code as a model for building their own GPIO control software routines.

Developers can also find GPIO libraries for higher-level languages such as Python. The RPi.GPIO Python module allows developers to control every aspect of GPIO function at the pin level with calls such as GPIO.input(channel) to read the value of a GPIO pin and GPIO.output(channel, state) to set the specified GPIO pin to a specified state.

The gpiozero Python library elevates GPIO programming with higher-level abstractions such as MotionSensor, LightSensor, LED, Motor, and others. With this approach, programmers deal with the underlying hardware by reading its state or setting the desired state with more intuitive commands such as led.on() to turn on an LED, relying on the library to manage the underlying GPIO transactions.

Leveraging Grove

The Pi HAT interface standard provides an attractive foundation for third-party developers but nevertheless remains restricted to the Pi platform. In contrast, the Grove interface provides a single standard foundation that crosses hardware platforms, attracting even more add-on board developers. The Seeed Technology Grove starter kit provides a Pi-compatible HAT board with multiple Grove-compatible connectors. As with other HATs, the Grove HAT mounts on the Pi 3 40-pin connector (Figure 4).

Image of Seeed Technology Grove starter kit

Figure 4: The Seeed Technology Grove starter kit attaches to the Pi-standard 40-pin connector, enabling developers to enhance their Pi system using the extensive set of Grove-compatible peripherals. (Image source: Seeed Technology)

With the Grove HAT, developers retain the simplicity and performance of the Pi 3, while gaining access to a wide set of Grove-compatible add-ons including actuators, gas sensors, motor control devices, speakers, wireless transceivers, and much more. Instead of plugging add-on functionality directly into the Pi 3 40-pin connector, developers plug the Grove connector provided with these products into one of the Grove sockets mounted on the top of the Grove HAT (Figure 4 again).

Developers can find Grove software libraries for C, Java, Node.js, Python, and others that similarly allow them to plug the Grove functionality into their applications. Here, higher-level routines allow the developer to think in terms of collecting analog data (Listing 2), relying on low-level routines in the library to execute the corresponding bit-level transactions (Listing 3).

# Tweet the temperature, light, and sound levels with our Raspberry Pi



import twitter

import time

import grovepi

import math


# Connections

sound_sensor = 0        # port A0

light_sensor = 1        # port A1

temperature_sensor = 2  # port D2

led = 3                 # port D3


intro_str = "DI Lab's"


# Connect to Twitter

api = twitter.Api(








grovepi.analogWrite(led,255)  #turn led to max to show readiness


while True:

    # Error handling in case of problems communicating with the GrovePi


        # Get value from temperature sensor

        [t,h] = grovepi.dht(temperature_sensor,0)


        # Get value from light sensor

        light_intensity = grovepi.analogRead(light_sensor)


        # Give PWM output to LED



        # Get sound level

        sound_level = grovepi.analogRead(sound_sensor)


        # Post a tweet

        out_str ="%s Temp: %d C, Humidity: %d, Light: %d, Sound: %d" %(intro_str,t,h,light_intensity/10,sound_level)

        print (out_str)



    except IOError:


    except KeyboardInterrupt:



        print("Duplicate Tweet or Twitter Refusal")

Listing 2: Developers can use a Pi board, Grove add-ons and a Grove software library to rapidly implement sophisticated applications such as this example, which emulates an Internet-of-Things-like process of transmitting environmental data to a host service – Twitter, in this case. (Code source: Dexter Industries)

# Read analog value from Pin

def analogRead(pin):

      write_i2c_block(address, aRead_cmd + [pin, unused, unused])


      number = read_i2c_block(address)

      return number[1] * 256 + number[2]

Listing 3:  The Grove software library handles the bit-level operations required to access hardware peripherals, allowing developers to work instead with more intuitive calls such as analogRead(pin). (Code source: Dexter Industries)

Simplified configuration

In the past, adding new hardware to a system presented challenges on many levels. Hardware engineers needed to design suitable mechanical and electrical interfaces. Application developers needed to find suitable software libraries able to provide the kind of abstraction needed to maximize productivity. The Pi 3 and its ecosystem remove these challenges with the Pi-standard 40-pin connector and readily available software libraries described above. Going even further, the Pi architecture frees developers from an additional requirement ¾ that of finding and loading hardware-specific board-support packages (BSPs). BSPs typically provide the low-level code needed to complete the interface between the OS and add-on hardware.

The Pi architecture largely removes the need for Pi users to install and configure BSPs for different hardware devices. Instead, Pi systems use a device tree, which provides a mechanism to load modules and manage resource allocation to avoid conflicts between multiple software modules competing for the same resources. If a hardware device requires specialized software, the Pi user only needs to set a few configuration items. The OS kernel automatically finds and loads modules associated with the corresponding hardware devices. For example, I2C functionality in a Pi system is disabled by default. Developers need only edit the configuration file, config.txt, to uncomment one line:


The Pi platform simplifies even that step. When Raspbian first boots up, it runs a configuration tool that presents the user with a menu of configuration items, including the ability to enable various interfaces.

For applications that rely on I2C-based hardware, higher-level libraries, such as those mentioned earlier, remove the need for developers to code at the level of I2C transactions. When developers do need to develop code for specialized I2C operations, they can find software such as the I2C tools for Linux that can be used directly or used as examples for creating custom I2C software.

Embedded Pi

For designers looking to embed Pi systems into products, the recently announced CM3 offers a compact drop-in Pi solution (Figure 5). Based on the same quad-core processor as the Pi 3, the CM3 also provides the same features and functionality as the Pi 3. Further, the CM3 includes 4 Gbytes of eMMC flash on the board: other Pi boards provide a micro SD slot for adding external flash memory cards. (Raspberry Pi also offers the CM3L – a "Lite" version of the CM3 that includes everything on that product except for the on-board flash.)

Image of Raspberry Pi Compute Module 3 (CM3)

Figure 5: The Raspberry Pi Compute Module 3 (CM3) offers the small size of the Pi Zero and the performance of the Pi 3, while bringing out more pins than either. It also includes a 4-Gbyte flash module (on reverse side of the board). (Image source: Raspberry Pi Foundation)

The CM3 steps away from the 40-pin IO interface used in the Pi 3 and Pi Zero. Instead, the CM3 provides its expanded interface as a 200-pin SODIMM (small outline dual in-line memory module) connector on the edge of the board (Figure 6). In fact, the entire CM3 board is DDR2 SODIMM form-factor compatible, allowing developers to connect the CM3 to a target system through a standard DDR2 SODIMM connector.

Diagram of Raspberry Pi CM3

Figure 6: The Raspberry Pi CM3 goes beyond the 40-pin interface found on other Pi boards, offering instead a 200-pin breakout of processor pins and other board components. (Image source: Raspberry Pi Foundation)

To simplify development, engineers can take advantage of the Raspberry Pi CM3 development kit, which combines a CM3 module with the Raspberry Pi Compute Module IO board. The IO board is a simple open-source board with a DDR2 SODIMM connector for the CM3 and headers that break out the 200-pin CM3 interface (Figure 7). In addition, the IO board provides connectors for HDMI, USB, camera, and display ports provided on the Pi 3 board.

Image of Raspberry Pi Compute Module IO board

Figure 7: Included with the CM3 development kit, the Raspberry Pi Compute Module IO board provides a DR2 SODIMM connector for the CM3 as well as headers for the 200-pin CM3 interface and connectors for HDMI, USB, camera, and display ports. (Image source: Raspberry Pi Foundation)

Real-time applications

With its combination of high performance and small form factor, the CM3 is well suited for use as an embedded system in electronic products such as televisions, audio gear, and similar consumer products. For real-time applications, however, developers need to account for some limitations in the default Pi platform.

Most notably, Pi systems do not include a real-time clock (RTC). Furthermore, cores such as the Cortex-A53 used in the Pi 3 and CM3 (or the ARM1176 used in the Pi Zero) do not include features like SysTick system timers needed for real-time events such as timed sensor reads. SysTick timers are important features of cores such as the ARM Cortex-M series that are designed specifically for deterministic real-time applications.

Engineers can easily make up for this shortfall using a precision RTC IC such as the Maxim Integrated DS3231. Featuring ±2ppm accuracy over the consumer temperature range, the DS3231 RTC IC generates a square wave output that can be used to drive software system timers. In addition, it provides a simple I2C interface for reading real-time clock counts. Developers can integrate the RTC data into their real-time applications using C routines based on the I2C toolkit mentioned earlier.

Another limitation in using a standard Pi system for real-time applications lies in the OS itself. Intended for general-purpose applications, typical Linux distributions lack the deterministic response required for reliably monitoring and controlling real-time processes. In fact, in Linux's default operating mode, even a very high-priority thread may fail to preempt the kernel. Consequently, if a high-priority routine tries to read sensors, control motors, and the like, that "real-time" routine might need to wait for an indeterminate amount of time.

Fortunately, the Linux kernel includes a configuration option, called CONFIG_PREEMPT, which addresses this limitation. This option allows high-priority routines to preempt the kernel except for special circumstances such as if the kernel is executing kernel threads in spinlock (blocked waiting for a resource). In practice, ensuring that the kernel can be preempted involves additional steps beyond modifying this configuration item. The open-source community has formalized the process of converting Linux to a fully pre-emptible kernel with the release of the CONFIG_PREEMPT_RT patch set. Simple if not straightforward, this patch procedure has become relatively routine thanks to well-documented procedures provided by the Raspberry Pi Foundation and Pi community members.


Despite recent interest in the Raspberry Pi Zero board, which has proven hard to get hold of, the Raspberry Pi 3 and CM3 offer engineers a more attractive platform for creating high-performance systems. The Pi 3 and CM3 each feature a quad-core processor and twice the on-board RAM available in the single-core Pi Zero.

For its part, the Pi 3 provides a more powerful computing foundation for leveraging the broad array of available add-on boards built to conform to the Pi-standard 40-pin GPIO interface. With the CM3, developers find a computing foundation that matches both the small size of the Pi Zero and the performance advantages of the Pi 3. Using these latest Pi boards, hardware add-ons, and readily available software libraries, developers can rapidly implement customized systems able to meet diverse application requirements.

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.

About this publisher

Digi-Key's North American Editors