Reader small image

You're reading from  Developing IoT Projects with ESP32 - Second Edition

Product typeBook
Published inNov 2023
Reading LevelIntermediate
PublisherPackt
ISBN-139781803237688
Edition2nd Edition
Languages
Tools
Right arrow
Author (1)
Vedat Ozan Oner
Vedat Ozan Oner
author image
Vedat Ozan Oner

Vedat Ozan Oner is an IoT product developer and software architect, with an excellent blend of technical knowledge and experience. During his career, he has contributed to several IoT projects in different roles, which allowed him to discover all key aspects of developing successful IoT products in highly competitive markets. Vedat has a bachelor's degree in METU/computer engineering and holds several industry-recognized credentials and qualifications, including PMP®, ITIL®, and AWS Certified Developer. Vedat started his limited company, Mevoo Ltd, in London in 2018 to provide consultancy services to his clients as well as develop his own IoT products. He still lives in London with his family.
Read more about Vedat Ozan Oner

Right arrow

Connecting to Cloud Platforms and Using Services

One of the enablers of the Internet of Things (IoT) is cloud computing. We can do all kinds of magic with ESP32 on a local network. We can collect data, share it between nodes, interact with users via the physical switches and displays of the devices, and add more interesting features based on collective sensor data from the local device network. However, the missing part here is cloud connectivity. We should be able to access our devices remotely from anywhere in the world and analyze device data to gain insights into our product more fruitfully. As a matter of fact, in some cases, the analysis of IoT data and any insight resulting from this analysis can provide more benefits than the direct use of the devices themselves. Cloud technologies make all these benefits available in IoT products.

This chapter explains how to integrate ESP32 into AWS IoT Core to benefit from cloud connectivity. After having IoT data on the AWS cloud,...

Technical requirements

The hardware requirements of the chapter are:

  • ESP32-C3 DevkitM-1
  • A Light-Dependent Resistor (LDR), or photo sensor
  • A pull-up resistor (10K)
  • ESP32-S3 Box Lite
  • A DS18B20 temperature sensor (breakout board)
  • Jumper wires

On the software side, we will use the AWS IoT Device SDK library. The book repository contains it as a sub-module, but you can find it here too: https://github.com/espressif/esp-aws-iot

We will also need some other software tools in the examples. They are:

  • ESP SoftAP Provisioning: The mobile application by Espressif Systems to provision ESP32 in a WiFi network. It is available for both Android and iOS.
  • curl: A command-line utility to interact with TCP/IP applications: https://curl.se/
  • Eclipse Mosquitto client tools: They are useful to test connections to an MQTT broker. The binaries are available here: https://mosquitto.org/download/
  • Amazon Alexa: The mobile application...

Developing on AWS IoT

We have many options on the market for cloud connectivity. How to choose the right IoT platform for a project mostly depends on the specific technology requirements, such as how easy it is to develop on the platform, deployment capabilities, operations after deployment, and the ecosystem to extend the product beyond the platform functionality. Based on these criteria, Amazon Web Services provides one of the most prominent IoT platforms with an entire set of products and services. Here is a basic overview of the AWS services and products related to IoT:

  • AWS IoT Device SDK to connect an IoT device to the AWS cloud: The SDK supports C/C++, Python, Java, and JavaScript. Espressif has forked its version for ESP32 devices. The SDK contains the libraries for the common standards and protocols, such as coreMQTT, coreJSON, and coreHTTP. It also contains other libraries, allowing developers to easily connect their devices to AWS and manage them, such as AWS...

Visualizing with Grafana

Grafana is a powerful tool for IoT data visualization. It is an open-source project available to everyone, but we also have a cloud option with AWS Managed Grafana, which frees us from any server management overhead. Some key features of Grafana are:

  • Workspaces for developers to design dashboards for end users
  • Easy integration with multiple data sources with plugins
  • Easy manipulation and transformation of data with SQL
  • A wide variety of customizable graph types for different needs

In this example, we will utilize AWS Managed Grafana to visualize the light data of the previous example. Here is an overview of what we will do in this example:

  • We will create an Amazon Timestream database and a table in it for the light data. Amazon Timestream is a managed time-series database that comes with all the advantages of using the AWS cloud, such as no server to manage, auto-scaling, auto-encryption, etc.
  • We will...

Integrating an ESP32 device with Amazon Alexa

Voice assistants provide another type of user interface in human-machine interaction, which is called a Voice User Interface (VUI). A user gives a voice command and a machine replies with a spoken response, in addition to any associated action if configured. Although there are many other enabling technologies, modern voice assistant systems basically make use of speech recognition, Natural Language Processing (NLP), and speech synthesis.

Amazon’s voice assistant solution is Alexa Voice Service (AVS), and in this example, we will integrate ESP32 with AVS in a smart home skill. An Alexa skill is basically a voice application. The Amazon Alexa mobile application is the platform to enable skills and use Alexa-enabled devices in our Alexa accounts. If you don’t already have this application on your mobile device, it is time to install it for this example.

The blueprint architecture for a smart home skill looks like this...

Summary

It is almost impossible to think of IoT without cloud platforms. In this chapter, we talked about Amazon Web Services as an example and learned how to integrate ESP32 with the AWS cloud. The first example in the chapter was an AWS-connected light sensor. We created an IoT thing on AWS IoT Core, and we configured the ESP32 application with its credentials. The light sensor sent light readings from an LDR to IoT Core over MQTT. IoT visualization was another subject of the chapter. We created an IoT rule on AWS IoT Core to forward light readings to a managed Timestream database. Grafana was the tool to visualize time-series light data. We configured a Grafana panel to read from the Timestream table and show the light values, with associated timestamps.

Voice assistants are also popular in the IoT world. Consumer products usually come with voice service integrations as an alternative method of user interface. In the last example, we discussed how to integrate an IoT sensor...

Questions

Try to answer these questions as an overview of the chapter:

  1. Which of the following is used as the SDK to connect ESP32 to the AWS cloud?
    1. AWS IoT Core SDK
    2. AWS IoT Device SDK
    3. AWS IoT Device Defender
    4. AWS IoT Greengrass
  2. Which is not required when we develop an ESP32 application to publish MQTT messages on AWS IoT Core?
    1. Creating an IoT thing
    2. Embedding the credentials in the application
    3. Defining an IoT rule to pass messages
    4. Defining the right policies to publish messages
  3. Which one is not correct about Grafana?
    1. It is a tool for IoT visualization.
    2. It can integrate data from different sources on the same panel.
    3. You need to manage an EC2 instance to have Grafana
    4. It has the ability to generate alerts over data
  4. Assume that you are integrating an ESP32 device with AVS. You see that the device...

Further reading

Learn more on Discord

To join...

lock icon
The rest of the chapter is locked
You have been reading a chapter from
Developing IoT Projects with ESP32 - Second Edition
Published in: Nov 2023Publisher: PacktISBN-13: 9781803237688
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 €14.99/month. Cancel anytime

Author (1)

author image
Vedat Ozan Oner

Vedat Ozan Oner is an IoT product developer and software architect, with an excellent blend of technical knowledge and experience. During his career, he has contributed to several IoT projects in different roles, which allowed him to discover all key aspects of developing successful IoT products in highly competitive markets. Vedat has a bachelor's degree in METU/computer engineering and holds several industry-recognized credentials and qualifications, including PMP®, ITIL®, and AWS Certified Developer. Vedat started his limited company, Mevoo Ltd, in London in 2018 to provide consultancy services to his clients as well as develop his own IoT products. He still lives in London with his family.
Read more about Vedat Ozan Oner