Reader small image

You're reading from  Arduino IoT Cloud for Developers

Product typeBook
Published inNov 2023
PublisherPackt
ISBN-139781837637171
Edition1st Edition
Right arrow
Author (1)
Muhammad Afzal
Muhammad Afzal
author image
Muhammad Afzal

Muhammad Afzal is a senior software engineer, with more than 14 years of experience working on web-based and IoT systems in multinational organizations. He always enjoys working and solving real-world business problems with technology. He provides freelance services to IoT-based product companies to write technical reviews and projects, and he also provides consultancy to organizations. In his free time, Muhammad creates videos and courses for YouTube and Udemy. He also runs a maker movement in his region for young students to boost their interest in adopting the latest technologies.
Read more about Muhammad Afzal

Right arrow

Project #6 – Making Your Home Smarter with a Voice Assistant

This chapter is dedicated to smart homes. Smart homes is a wide field that aims to automate everything in your home to make your life experience better and more comfortable, for example, smart light systems, smart air conditioning, smart TVs, and so on. But in this chapter, we will explore how we can build a multi-color smart bulb that is controlled by the Arduino IoT Cloud web and mobile dashboard. We’ll also add the Amazon Alexa voice assistant to control the smart bulb using voice commands.

Here, we will practically explore smart homes, picking up the WS2812 RGB LED ring and Seeed Studio’s newest, and very small, development board in the XIAO series, which is based on ESP32 with a lot of features. With the help of the light module, development board, and the Arduino IoT Cloud, we will build a smart light system.

By the end of this chapter, you will have the confidence to build smart home solutions...

Technical requirements

The following hardware components are required to complete this chapter’s exercise:

  • Seeed Studio XIAO ESP32C3
  • USB type-C cable for XIAO ESP32C3
  • WS2812 RGB LED ring
  • Male headers, female headers, and a veroboard
  • Jumper cables
  • Soldering iron
  • Amazon Echo Dot and the Amazon Alexa mobile app

For coding, we will use the Arduino Web Editor, which includes a large collection of development boards and sensor libraries, and the Arduino IoT Cloud for the Thing and dashboard setup. To develop hardware and sensor designs, we need the Fritzing desktop software and the Arduino IDE for testing the WS2812 ring.

Here, we will use the Amazon Echo Dot as a voice assistant for voice commands to control the smart bulb. If you don’t have an Echo Dot, then you can use the Amazon Alexa app for Android/iOS. The chapter’s code is available in the official GitHub repository for the book by following this link: https://github...

Creating smarter homes with IoT

Internet of Things (IoT) technology plays a crucial role in the development of smart homes. It enables various devices and appliances within a home to connect, communicate, and automate tasks for the convenience, comfort, and efficiency of homeowners. Here are some key aspects of IoT for smart homes:

  • Connectivity: IoT devices in a smart home are connected to the internet, allowing them to communicate with each other, as well as with the homeowner, remotely. This connectivity facilitates the control, monitoring, and automation of devices from anywhere, using smartphones, tablets, or computers.
  • Home automation: IoT enables the automation of various tasks within a smart home. For example, lights can automatically turn on or off based on occupancy or the time of day. Thermostats can adjust temperature settings based on the homeowner’s preferences or presence in the house. IoT-powered automation helps optimize energy usage, enhance security...

Essential components – sensors and development boards

In the ESP32 series, we have a wide collection of development boards, which vary in size and pins. In this chapter, we are using Seeed Studio’s latest development board, the XIAO ESP32C3, as it’s very compact and smaller in size than other boards, and of course, cheaper and is suitable for 5V as well as 3.3V. The following figure is the pin layout diagram of XIAO ESP32C3.

Figure 10.1 – XIAO ESP32C pinout diagram

Figure 10.1 – XIAO ESP32C pinout diagram

XIAO ESP32C provides multiple pins for digital input/output. In the previous ESP series board, we found only one analog pin, but on this development board, we have four analog pins, which removes the biggest hurdle while developing a solution that uses multiple analog pins. With previous ESP series boards, we used ADS1115/ADS1015 for extra analog pins, so this development board will save us some bucks as we will get four analog pins by default on the development board...

Blueprint for your smart home IoT project

In the preceding sections, we discussed the sensors and development board in detail. Now, it’s time to cook the recipe. In hardware development, before starting to work with sensors and development boards, we need to develop the design concepts to get a better understanding of how things will be connected. There is a lot of software available to design and develop design concepts regarding electronics projects, but we are going to use Fritzing.

In the following two subsections, first, we will talk about the schematics and design of a project and explain how to connect the pins of the development board with soldering. Next, we will do some testing of the WS2812 to check all the colors and pixels are working.

Schematic design and assembly

The purpose of the design is to clearly understand how sensors will connect with the development board. It helps engineers to develop a prototype on a breadboard or on a veroboard by using these...

Initial setup – Thing, network credentials, cloud variables, and code

After setting up the hardware, it’s time to set up Thing in the Arduino IoT Cloud. For this project, we need one cloud variable to control the LED brightness and color, and turn on/off the WS2812 ring, but I am using three different cloud variables so you will get an idea of when and why we need to use these cloud variables, and every variable connects with a specific widget. The network settings will be different from Arduino development boards due to using ESP series board.

Figure 10.8 – Air quality monitoring system Thing setup

Figure 10.8 – Air quality monitoring system Thing setup

Set up a new Thing with the name Voice Controlled Smart Lamp and follow these steps to create variables, associate a device and network configuration, and finally, write the code:

  1. Firstly, we need to set up three cloud variables for the WS2812. Complete details regarding cloud variables are available in the following section.
  2. ...

User-friendly controls – building web and mobile dashboards

After uploading the code to the device, it’s time to set up a dashboard for web and mobile to visualize the data with different widgets. The following screenshot shows a visualization of light controls with different widgets.

Figure 10.11 – Thing dashboard

Figure 10.11 – Thing dashboard

We have three core functionalities of WS2812, which include RGB color, brightness, and the on/off switch. In the previous section, we created three different cloud variables, which provide different functionalities. That’s why here we have three different widget controls, which only work with these cloud variables. The first widget is Colored Light, which is linked to the tableLight cloud variable and capable of performing all of the operations on the WS2812, such as color change, brightness control, and switching it on and off.

Next, we have two more controls with limited functionalities. The second widget is...

Enhancing controls – integrating the Arduino IoT Cloud with Amazon Alexa

After testing everything on the device using the Arduino IoT Cloud dashboard, it’s time to link Amazon Alexa with our thing for the voice control system. We have a physical hardware device for Alexa as well mobile apps for Android/iOS. Please visit https://alexa.amazon.com/ to set up this project. I am using Amazon Echo Dot second generation, but if you don’t have access to an Alexa hardware device, then you can simply use the mobile app.

Figure 10.12 – Arduino Skill for Amazon Alexa

Figure 10.12 – Arduino Skill for Amazon Alexa

The Arduino IoT Cloud natively developed a skill for Amazon Alexa, which can be found at https://www.amazon.com/Arduino-LLC/dp/B07ZT2PK2H. Set up your Amazon Alexa and navigate to the preceding URL to enable a skill, which is shown in the preceding figure. When you link the account, it will automatically link the Arduino IoT cloud account that is already logged in with this...

What next?

We still have lots of options available to explore, but now your assignment is to use different relays, sensors, and development boards to do some more experiments and learn from them. In the current chapter, we have only used one WS2812 module for light control, but you can use temperature sensors, relays, and motion sensors to automate your devices in your home, such as automating room switches to control fans, exhaust fans, lights, and air conditioning systems according to room temperature.

Important note

Be careful when playing with high-voltage power cables when patching the cables to relays.

Summary

In this chapter, we have explored how to develop a low-cost, multi-color smart table lamp for our room using the XIAO ESP32C3 and WS2812. We have set up the Thing, which included cloud variable creation, device association, network configuration, and coding of the development board. Later, we created a dashboard using different widgets to control the WS2812 RGB ring. Finally, we used the Amazon Alexa voice assistant to turn our table lamp on/off and control its color and brightness with voice commands.

This chapter will give you the confidence to build more interesting stuff to make your home and office smarter. In the next chapter, we will talk about Cloud Scheduler and over-the-air update’ features. Both features are interesting and specially designed to carry out operations on IoT nodes.

lock icon
The rest of the chapter is locked
You have been reading a chapter from
Arduino IoT Cloud for Developers
Published in: Nov 2023Publisher: PacktISBN-13: 9781837637171
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
Muhammad Afzal

Muhammad Afzal is a senior software engineer, with more than 14 years of experience working on web-based and IoT systems in multinational organizations. He always enjoys working and solving real-world business problems with technology. He provides freelance services to IoT-based product companies to write technical reviews and projects, and he also provides consultancy to organizations. In his free time, Muhammad creates videos and courses for YouTube and Udemy. He also runs a maker movement in his region for young students to boost their interest in adopting the latest technologies.
Read more about Muhammad Afzal