Reader small image

You're reading from  Arduino Data Communications

Product typeBook
Published inNov 2023
PublisherPackt
ISBN-139781837632619
Edition1st Edition
Right arrow
Author (1)
Robert Thas John
Robert Thas John
author image
Robert Thas John

Robert Thas John is a data engineer with a career that spans two decades. He manages a team of data engineers, analysts, and machine learning engineers – roles that he has held in the past. He leads a number of efforts aimed at increasing the adoption of machine learning on embedded devices through various programs from Google Developers and ARM Ltd, which licenses the chips found in Arduinos and other microcontrollers. He started his career as a software engineer with work that has spanned various industries. His first experience with embedded systems was in programming payment terminals.
Read more about Robert Thas John

Right arrow

Prototyping with Shields

In this chapter, you will learn about the sensors that you can work with without having to use a solderless breadboard and cables. When working with breadboards and cables, you might find that something has stopped working because of a loose cable connection. You might also find that you have run out of space on a breadboard. This is where shields come in handy. You will create a project that works with one of these shields: the environment shield. You will also get an introduction to carrier boards and will build a project that makes use of the MKR IoT Carrier. The projects will help build your confidence in collecting data without using breadboards and give you a strong foundation for adding complexity to your setups without worrying about debugging faulty cable connections. By the end of this chapter, you will have written different projects that collect environment data for later use.

In this chapter, we are going to cover the following main topics:

...

Technical requirements

The code examples used in this chapter can be found at https://github.com/PacktPublishing/Arduino-Data-Communications/tree/main/chapter-3.

You will also require the following:

What is a shield?

A shield is a printed circuit board (PCB) that attaches to a microcontroller and gives it additional capabilities that it doesn’t natively ship with. Most shields are the same size as the microcontroller they are meant to work with. An example shield for the Arduino Portenta H7 microcontroller is shown in the following figure:

Figure 3.1 – Arduino Portenta Vision Shield – Ethernet

Figure 3.1 – Arduino Portenta Vision Shield – Ethernet

Shields are meant to be mounted on top of the microcontroller. They receive power from the microcontroller, so they don’t have a power connector. Most shields have stacking headers, so you can mount other shields on top of them.

There is another group of PCBs called carriers.

What are carriers?

Carriers are boards, but they do not mount onto a microcontroller. Instead, the microcontroller mounts onto the carrier. Carriers provide connectors for plugging other devices into the microcontroller. Arduino currently provides the...

Working with sensor shields

We will work on two projects that measure environmental data and motion data. We will do two new things in these projects:

  • Get time from an NTP server so that we have a sense of when exactly we are taking sensor readings. This is useful because it’s important to assign a date and time to any reading that we will be storing.
  • Learn to put readings into a format called JSON. JSON is short for JavaScript Object Notation and is a useful format for sending data over the internet.

Project 1 – Working with the MKR ENV Shield R2

In this project, you will learn to take sensor readings from the Arduino MKR ENV Shield R2. This shield has the following onboard sensors:

  • LPS22HP: Atmospheric pressure sensor from ST Microelectronics
  • HTS221: Temperature and humidity sensor from ST Microelectronics
  • TEMT6000: Light intensity sensor from Vishay

The code for this project is available in the following GitHub repository...

Discovering other types of shields

Arduino provides various shields. Let’s place some of these in categories.

Providing additional connectivity

MKR boards come in different variants, providing different connectivity options. One popular connectivity option is Wi-Fi. There are other connectivity options that you will not find as MKR boards, but you can get a shield for some of these:

  • The MKR ETH Shield will let you plug an Ethernet cable into your MKR board. This is useful for environments where wireless signals would interfere with the operation of other machinery, such as in a medical setting. This shield also provides an SD card slot for data logging purposes.
  • The MKR 485 Shield will let you connect to a legacy industrial system and communicate with it. This shield lets you implement communications using the serial protocol.

Communicating with automobiles

The MKR CAN Shield will let you connect to the brains of an automobile using something called...

Working with the MKR IoT Carrier

The MKR IoT Carrier is designed for the MKR board to be attached on top of it. It comes with the following sensors:

  • Five capacitive touch sensors
  • A temperature, humidity, and barometric pressure sensor
  • A six-axis inertial measurement unit
  • A color detection sensor
  • A gesture sensor

It also has an OLED display, two onboard relays, two analog Grove connectors, and one I2C Grove connector. You can see the MKR IoT Carrier in this video: https://packt.link/sfncm.

Let’s work with the MKR IoT Carrier to collect sensor data.

Project 2 – Collecting sensor data with the Arduino MKR IoT Carrier

In this project, we will use the MKR WiFi 1010 to connect to a wireless network and then fetch the time from an NTP server when the microcontroller starts up. Afterward, every minute, we will read the temperature, humidity, and pressure and display those on the OLED display. The code for this project is available on GitHub...

Summary

In this chapter, you learned about shields and carriers, and then worked on some projects using both a shield and a carrier. This was important because you got to focus on the code that you needed to write to collect data without having to fiddle with breakout boards, breadboards, and wires that could come loose and lead to a lot of time spent debugging your code. With the MKR IoT Carrier, you were also able to display the readings on the OLED screen. This is useful for communicating information to users without asking them to connect the device to a computer for serial output. We are collecting data but not storing it.

In the next chapter, we will discuss various strategies for storing this data locally, especially given that the MKR IoT Carrier and the MKR ENV Shield both come with SD card slots.

Further reading

To learn more about the topics covered in this chapter, you can visit the following links:

lock icon
The rest of the chapter is locked
You have been reading a chapter from
Arduino Data Communications
Published in: Nov 2023Publisher: PacktISBN-13: 9781837632619
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime

Author (1)

author image
Robert Thas John

Robert Thas John is a data engineer with a career that spans two decades. He manages a team of data engineers, analysts, and machine learning engineers – roles that he has held in the past. He leads a number of efforts aimed at increasing the adoption of machine learning on embedded devices through various programs from Google Developers and ARM Ltd, which licenses the chips found in Arduinos and other microcontrollers. He started his career as a software engineer with work that has spanned various industries. His first experience with embedded systems was in programming payment terminals.
Read more about Robert Thas John