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

Leveraging Various Sensors for Data Acquisition

In the previous chapter, you learned how to blink an LED. Doing that lets the microcontroller interact with its environment. You were using the LED as an actuator to control the environment. With Arduino, you can also read the environment using sensors. Sensors convert the state of the environment into an electrical signal. You can read these signals using input and output pins.

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

  • Learning about microcontroller input and output pins
  • Discovering sensors

By the end of this chapter, you will have learned about various sensors and the various ways in which you can collect data. You will find this knowledge to be useful when you encounter new sensors as you go about your daily activities. The knowledge you will acquire in this chapter will come in handy for collecting data in future projects.

Technical requirements

All the code examples for this chapter can be found on GitHub at https://github.com/PacktPublishing/Getting-Started-with-TensorFlow. You will also need the following:

  • Arduino MKR WiFi 1010
  • Micro-USB cable
  • LCD 1602
  • Arduino Sensor Kit
  • Arduino IDE

Learning about input and output pins

The first time we looked at the pinout diagram of the MKR WiFi 1010, we only discussed the digital and analog pins. Let’s revisit that diagram so that we can consider the other communication technologies that are available on the MKR board:

Figure 2.1 – Arduino MKR WiFi 1010 pinout diagram (source: https://docs.arduino.cc/static/9d6534bb9783a42e3527a8c03472ad10/ABX00023-full-pinout.pdf)

Figure 2.1 – Arduino MKR WiFi 1010 pinout diagram (source: https://docs.arduino.cc/static/9d6534bb9783a42e3527a8c03472ad10/ABX00023-full-pinout.pdf)

The preceding figure has some pins labeled in dark green. Take a look at the pins on the right-hand side of the board; you will see that they are grouped into three. These are communication protocols that are supported by the pins. We’ll discuss them next.

UART

Digital pins 13 and 14 work together in tandem to support a protocol that is commonly called Serial. In Serial communications, data is transmitted one bit at a time. UART is short for Universal Asynchronous Receiver/Transmitter. The “Asynchronous...

Discovering sensors

Sensors convert external readings into electrical signals. There are so many sensors that it would be impossible to list them all here. You can find sensors in three different implementations:

  • On-board sensors: These come integrated with the microcontroller development board. MKR boards don’t come with those, but other Arduino Pro boards do.
  • Breakout boards: These provide an interface such as a single pin, UART, SPI, or I2C for connecting to and communicating with a microcontroller.
  • Shields: These are boards that are meant to attach to the top or bottom of a microcontroller and either integrate sensors or provide interfaces for connecting breakouts. We will discuss shields in the next chapter.

Let’s discuss some sensor categories.

Motion sensors

Motion sensors try to answer one or more of the following questions:

  • Is this item in motion?
  • What direction is this item headed in?
  • Is this item being held upward...

Summary

In this chapter, you learned some more about the capabilities of the I/O pins on the MKR board and wrote code to interact using Serial and I2C. You also interacted with an IMU sensor and observed the output using both the Serial terminal and the plotter.

In Chapter 3, you will learn about shields, which let you create prototypes without having to use a breadboard and wires while still giving you access to some common sensors.

Further reading

To learn more about the topics that were covered in this chapter, take a look at the following resources:

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