Book Image

Arduino Data Communications

By : Robert Thas John
5 (1)
Book Image

Arduino Data Communications

5 (1)
By: Robert Thas John

Overview of this book

In our modern, internet-connected world, where billions of devices constantly collect and send data to systems to be stored and processed, it’s surprising how the intricacies of data transmission and storage are often overlooked in the IoT domain. With Arduino Data Communications, you'll bridge the knowledge gap and become an expert in collecting data from IoT sensors, transmitting data, and configuring your own databases. This book is an exploration of IoT’s inner workings, guiding you through the process of setting up an end-to-end system that you can employ to prototype your own IoT solutions, using easy-to-follow examples. It begins with a general overview of the Arduino ecosystem, acquainting you with various sensors and shields and unveiling the art of data collection. You’ll then explore data formats and methods to store data, both locally and on database servers. As you progress through the chapters, you’ll learn how to set up REST and MQTT infrastructure to communicate with databases and get hands-on with LoRaWAN, Ethernet, cellular, HC-12, and RS-485. The final chapters are your training ground for real-world projects, imparting the essential knowledge you need to tackle complex challenges with confidence. By the end of this Arduino book, you'll have seamlessly configured an end-to-end system, all while immersing yourself in practical scenarios that bring the world of IoT to life.
Table of Contents (20 chapters)
1
Part 1:Introduction to Arduino and Sensor Data
7
Part 2:Sending Data
14
Part 3: Miscellaneous Topics

Learning about Arduino – The hardware

Arduino provides various microcontroller unit (MCU) development boards. When Arduino is mentioned, a lot of users think of the Arduino Uno, which is arguably the most popular board from Arduino, as well as the most popular one manufactured by other companies based on the reference designs available from Arduino. These clones aren’t called Arduino, but something similar, such as the SparkFun RedBoard manufactured by SparkFun Electronics. The following photo shows various Arduino MCUs.

Figure 1.1 – Various Arduino MCUs

Figure 1.1 – Various Arduino MCUs

We will be using official Arduino boards in this book. By using an official Arduino board, you will be helping to support the company and its open source efforts.

You might start a conversation about boards with the question, “What is the best board for…?”. The answer, as to most questions, is, “It depends!

In the world of microcontrollers, the best board is the one that gets the job done while consuming the least amount of resources (power, memory, etc.). Power consumption ties right back to the chip. The greater the capability of a chip, the more complex it is, and the greater the power consumption, normally.

During development, it is normal to pick a board at random, complete the setup, ensure it is working, and then try to downsize the board. What this means is that, at first, you might not know how large your firmware will be, or what code will need to run on it. As a result, you could pick any medium-range board.

After you are done with development, you will know the exact size of your firmware, as well as the number of pins you have utilized and the communication protocols. Then, you can pick a smaller board that supports everything you need and deploy it for production. Or, even better, you could pick the chip and sensors that you need and design a new PCB!

The first place to find Arduino hardware is on the website: https://www.arduino.cc/en/hardware. You can find the complete list of boards, and, as of this writing, attempts to classify them into three categories:

  • Nano Family: Boards with a small footprint, some embedded sensors, and support for machine learning (ML).
  • MKR Family: Boards equipped with a low-power chip, a communication chip, a cryptographic chip, and support for various shields that make it possible to prototype without additional circuit work. These boards feature a 32-bit SAMD21 (ARM Cortex-M0+) chip from Microchip Technologies (https://ww1.microchip.com/downloads/en/DeviceDoc/SAM_D21_DA1_Family_DataSheet_DS40001882F.pdf).
  • Classic Family: The older, more popular boards and their shields.

The second place to find Arduino hardware is on the Pro website: https://www.arduino.cc/pro. This website exists because Arduino wants to be reclassified from just something that is meant for learning to something that can be put to industrial use. Prior to this time, people would learn on an Arduino board but use a board from a competitor for the final product. The Pro website lists hardware in six categories (https://www.arduino.cc/pro/hardware):

  • Portenta Family: Boards with the highest-rated chips for their generation, with carriers and shields that make edge deployments possible. Connectivity is provided via shields. The chip on these is a 32-bit dual-core STM32H747 (ARM Cortex-M7 and ARM Cortex-M4) from STMicroelectronics (https://www.st.com/en/microcontrollers-microprocessors/stm32h747-757.html).
  • Edge Control: Remote monitoring and control carrier boards, optimized for outdoor environments. These boards feature a 32-bit nRF52840 (ARM Cortex-M4) chip from Nordic Semiconductors (https://www.nordicsemi.com/Products/nRF52840). Edge control boards come with two additional slots for MKR boards that let you extend functionality.
  • Nicla Family: Thumb-sized boards with industrial-grade sensors and battery connectors. These are the smallest boards available from Arduino.
  • MKR Family: The same as the MKR family from the main website.
  • Nano Family: The same as the Nano family from the main website.
  • Gateways: Devices for LoRaWAN connectivity. We will discuss these in more detail in Chapter 7, Communicating with LoRaWAN.

Let’s proceed to consider how to pick a board for the projects you will be tackling in this book.

Choosing your board – The Arduino MKR family

The board of choice for this book will be the Arduino MKR family, an example of which is the Arduino MKR WiFi 1010 (https://docs.arduino.cc/hardware/mkr-wifi-1010). The MKR family of boards is targeted at makers or tinkerers, has a popular form factor that is forward compatible with the newer and more powerful Arduino Portenta family of Pro boards, and has a number of shields that minimize the need for solderless breadboards and soldering.

Rather than picking up this board alone, I would recommend purchasing a kit that comes with other components that you can utilize for projects in this book. This kit is the Arduino Oplà IoT Kit, which you can find at this URL: https://store.arduino.cc/products/arduino-opla-iot-kit.

You will get to work with other boards as the need for different communication methods arises. All MKR family boards utilize the same chip: the SAMD21 chip from Microchip Technologies running a 32-bit ARM Cortex-M0+.

The MKR family is made up of various boards with different capabilities, some of which are listed here:

  • Arduino MKR WiFi 1010: This board provides WiFi and Bluetooth connectivity
  • Arduino MKR FOX 1200: This board provides SigFox connectivity
  • Arduino MKR WAN 1310: This board provides LoRaWAN connectivity
  • Arduino MKR GSM 1400: This board provides GSM connectivity

Don’t worry if one or more of the communication options aren’t familiar right now, as we will cover them in a later chapter.

The boards have the following general features:

  • 8 digital I/O pins
  • 13 PWM pins
  • 7 analog input pins
  • 1 analog output pin
  • 1 each of UART, SPI, and I2C
  • 256 KB of CPU internal memory
  • 32 KB of SRAM
  • Onboard WiFi and Bluetooth connectivity
  • Onboard RGB LED

Make sure you refer to the documentation for any board that you are working with, from the manufacturer’s website. This will save you a lot of stress and time.

Every board has a pinout diagram. This document provides information on what capabilities each pin on the board has. You can find the pinout diagram for the MKR WiFi 1010 here: https://content.arduino.cc/assets/Pinout-MKRwifi1010_latest.pdf.

Next, let’s discuss the IDE, which provides assistance when you write your code.