© The Author(s), under exclusive license to APress Media, LLC, part of Springer Nature 2022
C. BellBeginning MicroPython with the Raspberry Pi Picohttps://doi.org/10.1007/978-1-4842-8135-2_9

9. Introducing Grove

Charles Bell1  
(1)
Warsaw, VA, USA
 

Thus far in the book, we have learned how to use two discrete components to build electronics projects on a breadboard without a lot of soldering. We saw several examples and three projects that demonstrated how to build electronic solutions with discrete components and modules.

While we can continue to build our electronics projects with breadboards and jumper wires, there are better alternatives available to us. There are component systems designed to unify wiring by providing a modular cabling system to connect modules. One such component system that has been around for a while and is available for use with the Pico is called Grove.

The Grove component system has a rich host of modules we can use to build our projects simply by connecting the hardware together using polarized connectors (you can’t plug them in incorrectly). Grove expands your opportunities for building more complex projects, freeing you to concentrate on the code for your project.

In this chapter and the next three chapters, we will explore the third component system named Grove from Seeed Studio (https://wiki.seeedstudio.com/Grove/).

Overview

In this section, we will discover the Grove component system. We will learn about the capabilities and limitations of the systems as well as examples of the components available. The chapter also includes details on how to start using the components in projects.

Grove is designed to make building projects faster using pluggable modules containing sensors, input, output, and other functions. Unlike other component systems, the Grove component system supports a variety of protocols1 that operate over the same set of wires!

Grove supports the analog, digital, I2C, SPI, and universal asynchronous receiver-transmitter (UART2) protocols. Furthermore, Grove supports all of these protocols using the same wiring and connectors, so there’s no need to remember what cables go with what protocols. Cool!

Now that we know what protocols Grove supports and how the cables are wired, let’s see how easy the Grove component system makes using the modules.

The Grove Component System

Grove was created and released in 2010 by Seeed Studio (seeedstudio.com). They wanted to create an open source, modular component system to simplify rapid prototyping. But they didn’t stop there. They continued to refine and develop more modules to include an impressive array of modules that contain small circuits that include sensors, input devices, output devices, and more. They also produce host adapters for many platforms.

Note

Seeed Studio also uses the term breakout board for host adapters.

Each host adapter supports many Grove connectors that match the capabilities of the host board. If the host board supports all of the protocols that Grove supports, the host adapter will have several connectors for each of the protocols.

These host adapters simply connect to your host board enabling the use of Grove modules without the need for additional electronics such as breadboards and discrete components without soldering.

The Grove cabling system is not designed for daisy chaining. Rather, Grove modules are connected to the host adapter directly. So, connections form a “star” layout where the modules plug into one of the connectors on the host adapter. That’s why most host adapters have so many Grove connectors. We will see some examples of host adapters in a later section.

Each Grove module is self-contained; all of the supporting electrical components are on the module mounted on a small PCB (most come in a pretty blue color in fact) of various sizes. All you need to do is connect the modules to your host adapter using a Grove cable, and your hardware is done.

Capabilities

The capabilities of the Grove system include the following:
  • Modularized cabling supporting four protocols (I2C, digital, analog, and UART)

  • Easy, polarized connectors (no incorrect or reversed connections3)

  • No soldering required!

How Does It Work?

Grove wiring is polarized – you can only connect the cable to the device one way, so you always know the connections are correct. Grove uses a four-wire cable of various lengths with a larger keyed connector. So, you can’t misconnect a Grove cable. Nice. Figure 9-1 shows a typical Grove cable and connectors.
Figure 9-1

Grove connectors (courtesy of seeedstudio.com)

Figure 9-2 shows a close-up of the Grove connector.
Figure 9-2

Comparing Qwiic and Grove connectors (courtesy of sparkfun.com)

We will discuss how the cables are used for each of the protocols; let’s discuss each of these in more detail.

I2C
Recall from Chapter 4, I2C is a fast digital protocol that uses two wires (plus power and ground) to read data from circuits (or devices). I2C over the Grove cabling system uses all four wires as shown in Table 9-1.
Table 9-1

Grove Cable (I2C)

Pin

Color

Description

1

Yellow

SCL

2

White

SDA

3

Red

VCC (power)

4

Black

GND (ground)

Digital
The digital protocol is used for modules that produce a digital value, typically a positive integer in the range 0–1024 or larger. Digital wiring uses three wires: ground (GND), power (VCC of 3.3V or 5V), and signal. The digital protocol for Grove allows for up to two signal lines (named D0 and D1) using two of the four wires as shown in Table 9-2. Some modules may be labeled in such a way to indicate three signal lines (D0/D1 and D1/D2), but the interface supports only two signal lines. Signal lines can be used for input or output.
Table 9-2

Grove Cable (Digital)

Pin

Color

Description

1

Yellow

D0 – primary signal line

2

White

D1 – secondary signal line

3

Red

VCC (power)

4

Black

GND (ground)

Analog
The analog protocol supports communicating with modules using voltage. Like the digital protocol, the analog protocol supports up to two analog lines as well as the ground (GND) and power (VCC). The first analog line is named A0 and the second A1. Similar to the digital protocol, some modules may label the analog lines A0/A1 and A1/A2. Table 9-3 shows the layout of the analog protocol over the Grove cabling.
Table 9-3

Grove Cable (Analog)

Pin

Color

Description

1

Yellow

A0 – primary analog line

2

White

A1 – secondary analog line

3

Red

VCC (power)

4

Black

GND (ground)

UART
The UART protocol is a special serial protocol that uses two lines for transmit (TX) and receive (RX). Pins 1 and 2 are used for these lines, and the other two are the common ground and power lines as shown in Table 9-4.
Table 9-4

Grove Cable (UART)

Pin

Color

Description

1

Yellow

RX – serial receive

2

White

TX – serial transmit

3

Red

VCC (power)

4

Black

GND (ground)

Having all of the cables wired the same means you don’t need to have any special cables for each of the four protocols, but there are some cases where we may need a slightly different cable. We will discuss the available Grove cables in a later section.

Grove modules come in a variety of sizes, and most have only a single Grove connector but may host a number of other connectors depending on the features supported. Grove modules are designed to support a single function using a dedicated circuit.

While Grove modules are not uniform in size, they do conform to one of several formats as shown in Table 9-5. Most of the formats support a Grove connector in either a vertical (cable plugs in at a right angle to the board) or horizontal orientation.
Table 9-5

Grove Module Sizes (Courtesy of seeedstudio.com)

Format

Size

Example

1x1

20x20mm

1x2

20x40mm

1x3

20x60mm

2x2

40x40mm

2x3

40x60mm

The host adapter has multiple Grove connectors that you can use to connect modules (depending on the protocol as their dedicated connectors for each protocol). There are a variety of host adapters available for a growing list of host boards. This includes several for the Arduino, NodeMCU, Raspberry Pi Pico, and many more. You can discover the latest offerings by visiting https://wiki.seeedstudio.com/Grove_System/#how-to-connect-grove-to-your-board.

Now that we know what the Grove system is and how it works, let’s examine some of the limitations.

Limitations

Like most systems, there are some limitations. Fortunately, there are few and only the largest or most complex projects may need to heed. The limitation you may encounter for larger projects is that the maximum number of modules that can be supported is limited to the number of connections available on the host adapter, which is often limited by the host device or by the size of the host adapter.

For example, if you want to use the Grove Pico host adapter, it has only two Grove I2C connectors and thus can use only two I2C modules. Similarly, most Grove host adapters have limited numbers of digital and analog connectors. However, there are some things you can do to mitigate some of these limitations. Seeed Studio offers a number of modules that can help out (called interfaces).

Tip

You can discover the latest interface boards available for a variety of uses at https://www.seeedstudio.com/category/Grove-c-1003.html.

For example, if you want to use more I2C connections than what are available on the host adapter, you can use the Grove 8-Channel I2C Hub (www.seeedstudio.com/Grove-8-Channel-I2C-Hub-TCA9548A-p-4398.html) to extend the number of I2C connections. With this module, you can use one I2C connector on your host adapter and connect up to eight I2C modules to the hub. Figure 9-3 shows the Grove 8-Channel I2C Hub.
Figure 9-3

Grove 8-Channel I2C Hub (courtesy of seeedstudio.com)

To increase the number of connections for analog sensors, you can take a different route and use an analog-to-digital (ADC) module. The Grove ADS1115 16-bit ADC module (www.seeedstudio.com/Grove-ADS1115-16-bit-ADC-p-4599.html) allows you to connect up to four analog sensors connected via the onboard screw terminals. Figure 9-4 shows the Grove ADS1115 16-bit ADC module.
Figure 9-4

Grove ADS1115 16-bit ADC module (courtesy of seeedstudio.com)

Another limitation is the length of the Grove cables. Currently, the longest Grove cable from Seeed Studio is 50cm. If you need to use a longer cable, you can use two Grove Screw Terminal modules and a set of twisted pair wires (such as an Ethernet cable) to create your own longer cable. Figure 9-5 shows the Grove Screw Terminal module.
Figure 9-5

Screw Terminal module (courtesy of seeedstudio.com)

Now that we know more about Grove, let’s see what components (host adapters and modules) are available.

Components Available

There are a lot of components available for the Grove system. This section highlights some of the categories of modules available. We won’t see everything that is available because the catalog is quite large. Since the product has been around for some time, there are several versions of some of the modules. Rather than attempt to view all of the latest modules, we will see the more popular host adapters and modules as well as those we will use in upcoming chapters. Figure 9-6 shows a snapshot of the top-level index from the Seeed Studio Grove online store. As you can see, there are a lot of categories!
Figure 9-6

Seeed Studio Grove online store index

Note

While you may encounter older versions of some Grove components, the older versions are still usable and can sometimes be found used for a discount.

Host Adapters

Aside from the impressive list of modules, the list of host adapters available from Seeed Studio is very impressive. Since we are working with Arduino and Raspberry Pi in this book, let’s look at versions of each for these platforms.

The host adapter most will want to use for the Raspberry Pi Pico is named Grove Shield for Pico (www.seeedstudio.com/Grove-Shield-for-Pi-Pico-v1-0-p-4846.html). We saw this host adapter in Chapter 1. It provides ten Grove connectors as well as GPIO headers that can be accessed with the Pico installed. Figure 9-7 shows the Grove Shield for the Raspberry Pico.
Figure 9-7

Grove Shield for Raspberry Pi Pico (courtesy of seeedstudio.com)

Notice the most commonly used GPIO pins are exposed on the upper-left corner. This allows you to use the header for additional connections. Another cool feature!

There are other Grove host adapters for the Pico. One of the most popular is the Maker Pi Pico Base, which we saw in Chapter 1. The Maker Pi Pico Base (without Pico) is available from Cytron (https://thepihut.com/products/maker-pi-pico-base-without-pico). You can get this board with the Pico already soldered in place or with a header ready for you to plug in your Pico with male headers soldered on. Figure 9-8 shows the Maker Pi Pico Base.
Figure 9-8

Maker Pi Pico Base (without Pico) (courtesy of thepihut.com)

Modules

Seeed Studio offers a wide variety of modules that contain sensors, input, output, and display capabilities similar to those available for Qwiic. However, the categories and number of modules available are several times that of the other systems. So many that it is not possible to list them all here. Table 9-6 lists the categories of modules available with a link to each category for further reading. You will find most have subcategories that you can explore to find more about the modules in the category. All URLs (links) begin with www.seeedstudio.com/category/.
Table 9-6

Categories of Grove Modules

Category

Description

Category Link

Sensors

Modules that allow you to sample the world around us

Sensor-for-Grove-c-24.html

LEDs

Modules that contain various forms of LEDs

leds-c-891.html

Input

Modules that contain devices that permit input of data or input actions like buttons

Input-c-21.html

Wireless

Modules that support wireless technologies

wireless-c-899.html

Displays

Modules with output devices

displays-c-929.html

Actuators

Modules with devices that produce movement, drive motors, or produce sound

actuators-c-940.html

Accessories

Grove accessories such as cables, headers, and more

accessories-c-945.html

So, what are the modules available in these categories? We will use the same list of subcategories we used for the other component systems. You will find the Seeed Studio website organized a bit different, but all of these subcategories are present:
  • Sensors: Typically contain a single sensor that produces output (readings or values) on the I2C bus. Examples include temperature, humidity, pressure, distance, magnometer, light, and environmental (gases) sensors.

  • Displays: Modules that contain an output device for displaying data. Examples include OLED and LED displays.

  • Relays: Modules that contain relays that permit you to switch higher power devices on or off.

  • Motors: Modules that permit you to control small electric motors.

  • Input: Modules that contain one or more buttons, potentiometers, keypads, or switches.

  • ADC/DAC: Modules that provide analog-to-digital conversion (ADC) or digital-to-analog conversion (DAC) that permit incorporation of other circuits into your project.

  • Accessory: Various modules that provide handy operations such as data loggers, cryptographic operations, and more.

Now, let’s look at a sample of the Grove modules we will be using in the upcoming chapters as we explore how to write the code for IoT projects using the Grove system beginning with an output device.

We will make use of several Grove LED modules. These modules contain one LED of a particular color. Figure 9-9 shows a Grove LED module. You can discover all of the Grove LED modules at https://www.seeedstudio.com/category/Grove-c-1003/leds-c-891/single-color-leds-c-914.html.
Figure 9-9

Grove Red LED module (courtesy of seeedstudio.com)

We will also use an LCD screen in some of the projects. The Grove – OLED Display 0.96" (www.seeedstudio.com/Grove-OLED-Display-0-96-SSD1315-p-4294.html) is a nifty, small OLED similar to the one we used in the Qwiic projects. Figure 9-10 shows the OLED display.
Figure 9-10

Grove – OLED Display 0.96" (SSD1315) (courtesy of seeedstudio.com)

The Grove Sound Sensor module (https://www.seeedstudio.com/Grove-Sound-Sensor-Based-on-LM358-amplifier-Arduino-Compatible.html?queryID=4e7fe5323cfe7b455a38a1b11c3889c0&objectID=1820&indexName=bazaar_retailer_products) provides the ability to detect sound or noise as an analog value similar to a microphone. Figure 9-11 shows the module with the sensor-facing side.
Figure 9-11

Grove Sound Sensor (courtesy of seeedstudio.com)

We will also use input devices such as the Grove Dual Button module that has two buttons mounted (www.seeedstudio.com/Grove-Dual-Button-p-4529.html). The module comes with a variety of colored caps permitting you to match the color of the cap to your project features. Figure 9-12 shows the module with caps on the buttons. You can also use them without the caps. Note that the Grove connector is located on the bottom of the board.
Figure 9-12

Grove Dual Button module (courtesy of seeedstudio.com)

The Grove – AHT20 I2C Temperature and Humidity Sensor module can measure both temperature and humidity (www.seeedstudio.com/Grove-AHT20-I2C-Industrial-grade-temperature-and-humidity-sensor-p-4497.html). Figure 9-13 shows the module with the sensor-facing side.
Figure 9-13

Grove – AHT20 I2C Temperature and Humidity Sensor (courtesy of seeedstudio.com)

Notice this module has additional pins for advanced users. In this case, we see the I2C pins broken out on the right side of the module. Modules with these features typically come without headers mounted.

Once again, there are many modules available. These are just a sampling of the modules available from Seeed Studio. A compact list of all Grove devices and modules is available at www.seeedstudio.com/category/Grove-c-1003.html.

Cabling and Connectors

The Grove system includes cables of various lengths including 5, 20, 30, 40, and 50cm. Most modules produced by Seeed Studio include a 20cm cable or longer. The 5cm cables are great for projects that include modules mounted in close proximity or inside an enclosure.

There are also special cables available for a variety of uses such as a branch or “Y” cable that lets you connect two modules to a single source, a Grove to servo cable for using servos connected directly to a host, and even cables for connecting directly to your host board with a Grove connector on one side and the other side broken out with individual male or female pins.

See www.seeedstudio.com/cables-c-949.html for a list of cables and connectors to support the Grove system.

Where to Buy Grove Components

You can purchase Qwiic components directly from Seeed Studio (seeedstudio.com), which is based in China. They often ship products quickly, but shipping may take longer than expected. Fortunately, you can often find Grove modules on popular online retail sites such as amazon.com and online auction sites. In fact, I have seen select starter kits in brick-and-mortar stores that sell electronic components. If you live in the United States, check out the online retail stores first or buy in bulk to save on shipping from Seeed Studio.

Now, let’s discuss how to use these systems in your projects.

Using the Components with Your Pico

Plugging your choice of Grove host adapter onto your host board and plugging the modules together with the cables is pretty easy. Recall, the connectors only go one way, so you can’t cross-connect anything.

However, Grove modules are not designed to be hot pluggable. You should not connect and disconnect modules while your board is powered on. This could lead to damaging the module(s) or your host board.

Caution

Do not plug or unplug Grove modules while your board is powered on.

Once the hardware is plugged together, the next step is to start working on the code to enable your modules and complete your project. To do so, you are likely required to load one or more software libraries.

Like the vast array of modules, the software libraries required for the Grove modules vary and depend on the module itself. Fortunately, Seeed Studio is very good about providing samples for use of each of their hundreds of modules.

The following summarizes the steps necessary for the Pico. The following does not include all of the steps needed for all of the projects in the book; rather, the section is an overview of what you can expect to configure your PC to implement the projects. Specific details for each example are included in each chapter.

Fortunately, most Grove modules have examples on how to use them that include, at a minimum, sample code for the Arduino. For example, there is a Wiki page for the OLED Display 0.96 module that shows you how to get started using it (https://wiki.seeedstudio.com/Grove-OLED_Display_0.96inch/).

Software libraries for the Pico are available for download to your PC, but some Python libraries are designed for use with the Raspberry Pi, not the Pico. So, you may need to copy/download one or more additional code modules to the Pico to get them to work. Be aware that some libraries may require changes in order to work with the Pico.

Most often, this is changing the use of I2C to SoftI2C, but sometimes you may need to change additional things in the code modules (library) to accommodate the Pico hardware. This makes using the Grove system a bit more of a challenge, but not burdensome once you experience how to make a few work as we will see in the next three chapters. Most can be used with little or no changes.

If you encounter a Grove module where there isn’t a Python library, do not despair. Again, most Grove modules have a Wiki page that will show you how to get started. But if there isn’t a specific Python library, you most likely can find a similar one from the Internet that you can use. All it takes is a bit of exploring, and you can find Python libraries for what you need.

Summary

Grove provides a simple, no-error connector that you can use to connect a variety of components together using several protocols – all from the same board.

Now that the hardware challenges have been nearly eliminated, we can turn our attention back to learning how to write the code for our projects. As you saw in this chapter, this may require installing software libraries to support the modules you are using or adapting existing libraries to suit your needs.

The next chapter begins a series of projects that use Grove components to teach you how to work with the systems for the Pico. As you will see, except for the hardware itself, the pattern of building the projects is the same as the previous project chapters.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.236.100.210