This appendix contains the consolidated shopping list for all components required for building all the projects in this book. We will also cover three optional component connector systems that you may find helpful in developing your own sensor networks.
Alternative Connection Systems
If you’ve been working with microcontrollers and discrete components for some time, chances are you’re an expert at wiring components to a breadboard and connecting them together. However, if working with electronics is new to you or you find wiring things together tedious, you’ve probably wondered if there is a better way. It turns out there are better ways!
As we saw in Chapter , there are connection systems designed to allow you to connect sensors and other components together using one set of wiring and connectors that connect to a platform-specific host board (shield, hat). These systems typically support a specific communication protocol such as I2C, SPI, and so on. Even so, manufacturers offer the components as modules that “speak” the same protocol. For example, you can get sensors and displays that can be connected together. These connection systems cost a little more, but the cost is easily offset by ease of use and keyed connectors that prevent cross or simply incorrect hookups.
In the following sections, we will see a short overview of three of the most popular connection systems you may want to consider using in your own projects. The examples are presented without detailed explanations for the reader to explore. That is, they represent a small glimpse into what is possible.
Grove
We first introduce the Grove system from Seeed Studio in Chapter . Grove is open source that utilizes a four-wire keyed connector that makes assembling electronic components easy and fast while also simplifying the learning process. The Grove system consists of a host board (shield/hat) with each module having a single, dedicated connector using one of several protocols. Connections are made in a star pattern where each component requiring a connection on the host or multiplex boards. Each Grove module addresses a single function such as a sensor, button, or display. With over 200 modules available, you are sure to find the modules you need for your project.
Since we have already discussed a sample Raspberry Pi Grove project in Chapter
, Listing
A-1 shows another example of a Grove project using the Arduino. In this case, we use a Grove Arduino base shield, DHT11 sensor, and a 16x2 LCD to display the data. All of the code is taken from the excellent example
sketches
.
/**
Beginning Sensor Networks Second Edition
Sensor Networks Example Grove Temperature Node
This project demonstrates how to use a Grove DHT11 sensor and
LCD display. It shows how easy it is to use the Grove family
of sensors as an alternative to hard wiring.
*/
#include "DHT.h"
#include "rgb_lcd.h"
const int colorR = 255;
const int colorG = 0;
const int colorB = 0;
#define DHTPIN A2
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);
rgb_lcd lcd;
void setup()
{
Serial.begin(115200);
while(!Serial);
Serial.println("Welcome to the Grove DHT11 example!");
Wire.begin();
dht.begin();
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
lcd.setRGB(colorR, colorG, colorB);
}
void loop()
{
float temp_hum_val[2] = {0};
if(!dht.readTempAndHumidity(temp_hum_val)){
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Humidity: ");
lcd.print(temp_hum_val[0]);
lcd.print("%");
lcd.setCursor(0, 1);
lcd.print("Temp: ");
lcd.print(temp_hum_val[1]);
lcd.print("C");
}
else{
Serial.println("Failed to get temperature and humidity value.");
}
Listing A-1Grove Arduino Example Sketch
To run this sketch, you must install the following libraries using the library
manager
:
Figure
A-1 shows the
hardware
for the project including an Arduino Uno, Grove Arduino Base Shield, DHT11 humidity/temperature sensor, and a 2x16 LCD module.
See www.seeedstudio.com/category/Grove-c-1003.html
for more information about the Grove family of products.
Qwiic
SparkFun's Qwiic connect system uses a smaller four-pin cable with JST connectors to quickly interface host and development boards with sensors, LCDs, and more. In fact, SparkFun has introduced many of its development boards with Qwiic connectors to make experiments and projects easier.
With the Qwiic system, there is no soldering and modules just plug together. No searching for the “right” connector; just plug it in and go. You can’t cross-connect since the connectors are polarized and keyed to plug in only on way. Better still, unlike the Grove system, Qwiic modules have two connectors permitting you to daisy-chain modules together, thereby saving space on the host board.
Qwiic host boards connect the I2C bus (GND, 3.3V, SDA, and SCL) on your Arduino, Raspberry Pi, Photon, and so on to a series of SparkFun Qwiic connectors
. Some host boards have circuitry to convert the 5V given to the 3.3V required by I2C boards in the Qwiic system.
One nice feature of the Arduino host shield also is the ability to mount Qwiic boards on top using two through holes that line up with the modules. This permits you to securely stack the modules on top. Nice.
The list of sensors along with supported host platforms and accessories for the Qwiic system from SparkFun is quite impressive. You are sure to find all manner of ideas just by browsing the catalog. In fact, if you own multiple microcontroller boards like I do, you’ll be extra pleased to know you need only change the host board and you can reuse your Qwiic modules across your fleet of microcontroller boards.
To show how easy the Qwiic system is to use, Listing
A-2 shows an example of a Qwiic project using the Arduino. In this case, we use a Qwiic Arduino shield, environmental sensor, and a tiny OLED to display the data. All of the code is taken from the excellent example
sketches
.
/**
Beginning Sensor Networks Second Edition
Sensor Networks Example Qwiic Temperature Node
This project demonstrates how to use a Qwiic BME280 sensor and
OLED display. It shows how easy it is to use the Qwiic family
of sensors as an alternative to hard wiring.
*/
#include <Wire.h>
#include <SFE_MicroOLED.h>
#include "SparkFunBME280.h"
// MicroOLED Definition
#define PIN_RESET 9
#define DC_JUMPER 1
// MicroOLED Object Declaration
MicroOLED oled(PIN_RESET, DC_JUMPER);
// BME280 Sensor
BME280 mySensor;
void setup() {
Serial.begin(115200);
while(!Serial);
Serial.println("Reading basic values from BME280 and display on OLED.");
Wire.begin();
if (mySensor.beginI2C() == false) {
Serial.println("The sensor did not respond. Please check wiring.");
while(1); //Freeze
}
oled.begin(); // Initialize the OLED
oled.clear(ALL); // Clear the display's internal memory
oled.display(); // Display what's in the buffer (splashscreen)
delay(1000); // Delay 1000 ms
oled.clear(PAGE); // Clear the buffer.
}
void loop() {
float temp_c = 0.0;
float temp_f = 0.0;
delay(1000);
temp_c = mySensor.readTempC();
temp_f = mySensor.readTempF();
oled.clear(PAGE);
oled.setCursor(0, 0);
oled.setFontType(1);
oled.print(temp_c);
oled.print("C");
oled.setCursor(0, 16);
oled.print(temp_f);
oled.print("F");
oled.display();
}
Listing A-2Qwiic Arduino Example Sketch
To run this sketch, you must install the following libraries using the library
manager
:
Figure
A-2 shows the
hardware
for the project including an Arduino Uno, Qwiic Arduino shield, BME280 environment sensor, and an OLED module.
There are two things I like about the Qwiic system: (1) the wide variety of platforms supported and (2) the ability to incorporate I2C devices that aren’t in the SparkFun catalog. Figure
A-3 shows an excerpt of the Qwiic
host boards
available including a nifty, tiny Raspberry Pi board.
While you can add devices to the Grove system, SparkFun makes it easier with the
SparkFun Qwiic Adapter
, a tiny board that has the I2C pins broken out in breadboard-friendly pins along with the customary two connectors. This permits you to create your own Qwiic modules from older I2C devices. Very cool. Figure
A-4 shows the SparkFun Qwiic Adapter from SparkFun.
Finally, SparkFun offers a number of Qwiic starter kits
for most platforms. These kits are often cheaper than buying the components separately and come ready to use in example projects.
See www.sparkfun.com/qwiic?_ga=2.26742462.2046856991.1585058029-656283068.1580489631
for more information about the Qwiic family of products.
STEMMA QT
The STEMMA/QT system
is another modular connection system from Adafruit. It supports both three- and four-pin JST connectors. Like Grove and Qwiic, it is Adafruit’s way of making it easy to plug and play various sensors and devices without a lot of wiring.
While it isn’t an original idea, Adafruit wanted to create something that could work within an ecosystem of other plug-and-play systems originally intended to be compatible with Grove, but when Qwiic was introduced, Adafruit added a smaller connector so it could work with both systems. However, there are a few exceptions.
STEMMA four-pin cables are cross-compatible with Grove modules, and Adafruit provides an optional cable for connecting Grove modules. STEMMA uses the same voltage as Grove—power is 3–5VDC and data is 3–5VDC with level shifting/regulators on devices. However, Qwiic only has level shifting and voltage regulation on the controller, not on the modules. Thus, while you can use STEMMA modules with any Qwiic controller, you can use Qwiic devices on a STEMMA controller only if you set the voltage jumper from 5V to 3V.
While these differences
are subtle, you can acquire any of the STEMMA devices and modules and mix them with your Grove and Qwiic systems. Just be careful about how you connect them and how the devices are powered.
For more information about STEMMA and especially compatibility with other systems, see https://learn.adafruit.com/introducing-adafruit-stemma-qt/what-is-stemma
.
Summary
There is a great sense of accomplishment when wiring up your projects and seeing them record sensor data. However, for some the task of wiring various components together can be tedious and sometimes error prone. Fortunately, the nice folks at Seeed Studio, SparkFun, and Adafruit feel your pain and have delivered excellent easy connect solutions.
While either system will work well, choosing one over another may come down to which system has the modules you need most. For example, the Qwiic system from SparkFun has an impressive and growing list of modules to choose from. However, it only supports the I2C protocol. If you need to use modules requiring other protocols, the Grove system may be a slightly better choice. Regardless of which you choose, these optional connector systems will make your projects assemble faster with fewer errors, and that’s always a good thing.