Smart Home IoT Project using Arduino Cloud & ESP32 Alexa
In this smart home IoT project, I have explained how to make an Arduino Cloud ESP32 Alexa home automation system to control appliances with the internet from anywhere in the world. With this internet of things project, you can control 4 relays from Arduino IoT Cloud dashboard, Alexa, IR remote, and manual switches. You can also monitor the real-time room temperature in the Arduino cloud dashboard and Amazon Alexa app. If there is no internet available still, you can control the appliances from the IR remote and switches.
I have used all the FREE tools and you don’t need any Alexa devices or Amazon Echo Dot for this voice control smart home IoT project.
So if you follow all the steps, you can easily make this Home Automation System with Arduino IoT Cloud and ESP32 for your home.
Table of Contents
Required Components for the ESP32 IoT projects
Circuit of the Arduino Cloud ESP32 projects
The circuit is very simple, I have used D23, D22, D21 & D19 GPIO to control the 4-channel relay module.
And the GPIO D13, D12, D14 & D27 connected with pushbuttons to control the relay module manually.
I have used the INPUT_PULLUP function in Arduino IDE instead of using the pull-up resistors with each push button.
As per the source code, when the control pins of the relay module receive a LOW signal the relay will turn on and the relay will turn off for the HIGH signal in the control pin.
IR remote receiver (TSOP1838) connected with D35. And the DHT11 sensor connected with RX2 (GPIO16).
If you want to use the latched switches instead of pushbuttons, then just connect the switches instead of the pushbuttons across GPIO pins and GND.
I have used a 5V 5Amp mobile charger to supply the circuit.
Please take proper safety precautions while connecting the AC appliances.
Tutorial video on Arduino Cloud ESP32 IoT project
In the Arduino Cloud tutorial video, I have covered the following steps in detail.
- Create new things in Arduino IoT Cloud.
- How to set up Arduino IoT Cloud Dashboard.
- How to set up Arduino IoT Cloud for ESP32.
- Programming the ESP32 with Arduino IDE
- Connect Arduino IoT Cloud with Amazon Alexa App.
- Control relays with IR remote
Arduino IoT Cloud FREE account setup
For this IoT project, I have used the Arduino Cloud Free plan.
First, you have to add ESP32 devices in Arduino IoT Cloud.
Then you have to add 4 Alexa Compatible Switch variables and 1 Temperature sensor variable to the Arduino Cloud Thing.
Please click on the following link for more details on Arduino IoT Cloud setup.
Important points for the ESP32 internet of things project:
- You can control maximum 5 relays or sensors with the Arduino IoT cloud FREE plan.
- The IR receiver sensor must have a metallic casing. Otherwise, you may face issues while trying to get the Hex code.
- You don’t need an Amazon Echo Dot or any other Alexa devices for this project. But if you have you can use it.
- After compiling the code, you have to press and hold the BOOT button of ESP32 until the code starts uploading.
- You can also use Arduino Web Editor to program the ESP32.
- You will get real-time feedback if the ESP32 connected to the internet.
- Use a stable 5V 5A DC power supply.
Program ESP32 with Arduino IDE
In the Tutorial video, I have explained all the steps to program the NodeMCU using Arduino IDE.
- Update the Preferences –> Aditional boards Manager URLs: https://dl.espressif.com/dl/package_esp32_index.json, http://arduino.esp8266.com/stable/package_esp8266com_index.json
- Then install the ESP32 board from the Board manager or Click Here to download the ESP32 board.
- Download the required libraries from the following links:
- ArduinoIoTCloud version 1.0.2 by Arduino and all the dependencies.
- IRremote Library version 3.3.0 by Shirriff.
Go to Sketch -> Include Libraries -> Manage Libraries in Arduino IDE.
When you try to install the ArduinoIoTCloud library, it will ask you to install all the dependencies. Then Click on Install All.
Code for Arduino IoT Cloud ESP32 home automation
After uploading the code to ESP32, please refer to the following articles for connecting the Arduino IoT Cloud Account with Amazon Alexa App.
After doing all these steps, now you control the appliances with Alexa.
ESP32 Alexa control Relay using Arduino Cloud
If the ESP32 is connected with WiFi, then you can ask Alexa, to turn on the light [“Alexa, Turn ON Room Light”]. Thus, you can control the appliances like lights, fans, etc with voice commands using Amazon Alexa App from anywhere in the world.
You can also monitor the real-time feedbacks and room temperature in the Alexa app.
Control Relays with Arduino IoT Cloud Remote App
You can also control the relays and monitor the room temperature from Arduino IoT Cloud Remote App.
Just download and install the Arduino IoT Cloud Remote app from Google Play Store or App Store, then log in to your Arduino Cloud account and select the dashboard.
Sometimes you have to refresh the dashboard multiple times if you face any issue.
Control Relays manually with Push Buttons
No Wi-Fi Manual Control
Control relays with Push Buttons
You can always control the appliances manually with push buttons. and if the ESP32 is not connected with the Wi-Fi, still you can control the appliances with push buttons.
IR Remote control relays with ESP32
You can also control the appliances with any IR remote.
First, you have to get the HEX codes of the remote buttons, then update the HEX code in the code. That’s it. Now you can control the appliances with the IR remote.
PCB for the ESP32 IoT Projects
You can also use this PCB for this ESP32 IoT project. Just download the Gerber file and order the PCB from any PCB manufacturer.
Control relays from Alexa App
Control relays with IR remote
I hope you like this Smart house IoT projects idea with the Arduino Cloud ESP32.
Please do share your feedback on this IoT project. Thank you for your time.
Arduino iot cloud remote
The three pillars of the Arduino CLI
Add Arduino to your resume – the Arduino Certification Program is now available in Bengali
Control your Internet of Things projects from anywhere with the new Arduino IoT Cloud Remote app
UPDATE: Both the iOS and Android versions are available and can be downloaded for free from the App Store and Google Play, respectively.
The perfect companion to the Arduino IoT Cloud! Develop your IoT solution online via a desktop, then monitor and control your dashboards on your mobile with the new Arduino IoT Cloud Remote app.
Initially available for free for iPhone on the App Store (and Android to follow in the next few weeks now on Google Play), the Arduino IoT Cloud Remote app gives you with the ability to access, monitor or control your IoT projects regardless of the time or place:
- In the field: you can read the data from your soil sensors or start your irrigation system directly from anywhere.
- In the factory: constant visibility of the state of your manufacturing process status, with the ability to control your automation remotely.
- In the home: monitor your home automation systems, check your previous or actual energy consumption from the convenience of your sofa.
The latest dashboard for the Arduino IoT Cloud comes with a host of enhanced features. Creating your dashboard via a desktop or tablet is quick and easy. The tool automatically configures your devices (including the secure crypto element) and automatically generates the main code for your project, making setup as straightforward as possible. A broad set of simple widgets to connect to the properties provides maximum versatility and enables you to set up a new dashboard in minutes.
Your dashboards, how you like them — all dashboards are fully customizable, it’s possible to group devices and organize them in any sequence — just drag and drop to arrange the layout, and select from multiple options including graphs to visualize the data. You can gather and display data from multiple IoT devices in one dashboard, and control those devices as required through your dashboard to fully integrate your solution.
The addition of the Arduino IoT Cloud Remote app to access, monitor, and control dashboards on the go via your phone is the final piece of the jigsaw.
Getting Started With the Arduino IoT Cloud
AUTHOR: Karl SГ¶derby
LAST REVISION: 10/05/2022, 01:00 PM
Introduction
Connected devices around the world are increasing by billions every year. The Arduino IoT Cloud is a platform that allows anyone to create IoT projects, with a user friendly interface, and an all in one solution for configuration, writing code, uploading and visualization.
In this article, we will take a look at some different components of the Arduino IoT Cloud, and provide a general overview.
But if you’re itching to get started and explore the Arduino IoT Cloud yourself, that is also perfectly fine! You can always come back here for more information!
IoT Cloud Documentation
The Arduino IoT Cloud has several pages of documentation available. Below you will find a list of some popular pages:
To find all tutorials & articles, visit the Arduino IoT Cloud Documentation page.
For a technical overview, list of features, and API guide, visit the Arduino IoT Cloud Cheat Sheet.
For API & SDK Documentation, visit the developer reference at Arduino IoT Cloud API.
Features
Below is a list of Arduino IoT Cloud features.
- Data Monitoring — learn how to easily monitor your Arduino’s sensor values through a dashboard.
- Variable Synchronisation — variable synchronisation allows you to sync variables across devices, enabling communication between devices with minimal coding.
- Scheduler — schedule jobs to go on/off for a specific amount of time (seconds, minutes, hours).
- Over-The-Air (OTA) Uploads — upload code to devices not connected to your computer.
- Webhooks — integrate your project with another service, such as IFTTT.
- Amazon Alexa Support — make your project voice controlled with the Amazon Alexa integration.
- Dashboard Sharing — share your data with other people around the world.
Compatible Hardware
To use the Arduino IoT Cloud, a cloud compatible board is required. You can choose between using an official Arduino board, or a board based on the ESP32 / ESP8266 microcontroller. The Arduino IoT Cloud currently supports connection via Wi-Fi, LoRaWANВ® (via The Things Network) and mobile networks.
All cloud-compatible Arduino boards come with a hardware secure element (such as the ECC508 cryptochip), where you can store your security keys.
Official Arduino boards only supports the 2.4GHz frequency band for transmitting data.
The following boards connect to the Arduino IoT Cloud via Wi-Fi.
Connection via Wi-Fi is an easy alternative, and your credentials can safely be entered during the configuration of a project. This type of connection is most suitable for low-range projects, where you connect your board to the cloud via your home/work/school router.
LoRaWANВ®
The following boards connect to the Arduino IoT Cloud via The Things Stack, a LoRaWANВ® Network Server connected to thousands of public LoRaВ® gateways.
Connection via LoRaWANВ® is recommended for low-power projects in both remote and urban areas, where Wi-Fi or other popular connectivity types are not available. The MKR WAN 1300/1310 boards are equipped with a LoRa radio module and has a slot for an antenna. With the right low-power configuration, the board can send data to the cloud for months on a single battery.
To learn more about setting up LoRaWANВ® devices, visit the Configuring LoRaWANВ® devices in the Arduino Cloud guide.
GSM / NB-IoT Boards
The MKR GSM 1400 and MKR NB 1500 require a SIM card to connect to the cloud, as they communicate over the mobile networks.
Connection through mobile networks can be considered in remote areas where there’s no Wi-Fi, or in mobile projects (such as cargo tracking).
For more information, visit the Arduino SIM page.
Note that a secured connection is a memory intense operation, so there’s not a lot of memory for the user application (e.g. around 2.6 kB on the MKR GSM 1400). Using a lot of IoT Cloud variables may cause the sketch to run out of memory on boards which don’t offload the SSL stack and make it crash.
ESP32 / ESP8266
The Arduino IoT Cloud supports a wide range of third party boards based on the ESP32 and ESP8266 microcontrollers with support for Wi-Fi. To set them up, simply choose the third party option in the device setup.
Configuring third party boards.
To learn more about ESP32/ESP8266 support and how to set it up, visit the Connecting ESP32 & ESP8266 to Arduino Cloud IoT guide.
Support
If you have any problems with the Arduino IoT Cloud, you can browse through common troubleshooting issues and find information on different features in the Arduino Help Center. If you don’t find the answer you are looking for, we are always happy to help you with any question regarding our products!
A Walk Through the Configuration
Setting up the Arduino IoT Cloud.
Setting up the Arduino IoT Cloud and accessing the different features available involves a few simple steps. So let’s take a look at how to go from start to finish!
1. Creating an Arduino Account
To starting using the Arduino IoT cloud, we first need to log in or sign up to Arduino.
2. Go to the Arduino IoT Cloud
After we have signed up, you can access the Arduino IoT Cloud from any page on arduino.cc by clicking on the four dots menu in the top right corner. You can also go directly to the Arduino IoT Cloud.
Navigating to the cloud.
3. Creating a Thing
The journey always begin by creating a new Thing. In the Thing overview, we can choose what device to use, what Wi-Fi network we want to connect to, and create variables that we can monitor and control. This is the main configuration space, where all changes we make are automatically generated into a special sketch file.
The Thing overview.
4. Configuring a Device
Devices can easily be added and linked to a Thing. The Arduino IoT Cloud requires your computer to have the Arduino Agent installed. The configuration process is quick and easy, and can be done by clicking on the “Select device” button in the Thing overview. Here, we can choose from any board that has been configured, or select the “Configure new device” option.
Configuring a device.
We can also get a complete overview of our devices by clicking the “Devices» tab at the top of the Arduino IoT Cloud interface. Here we can manage and add new devices.
The device tab.
5. Creating Variables
The variables we create are automatically generated into a sketch file. There are several data types we can choose from, such as int, float, boolean, long, char. There’s also special variables, such as Temperature, Velocity, Luminance that can be used. When clicking on the “Add variable” button, we can choose name, data type, update setting and interaction mode.
Creating variables.
6. Connecting to a Network
To connect to a Wi-Fi network, simply click the “Configure” button in the network section. Enter the credentials and click “Save”. This information is also generated into your sketch file!
Entering network credentials.
7. Editing the Sketch
Now that we have configured variables, devices and network settings, we can get to programming our devices!
An automatically generated sketch file can be found in the “Sketch” tab. It has the same structure as a typical file, but with some additional code to make the connection to your network and to the cloud.
A sketch that, for example, reads an analog sensor, and use the cloud variable to store it. When the sketch has been uploaded, it will work as a regular sketch, but it will also update the cloud variables that we use!
Additionally, each time we create a variable that has the Read & Write permission enabled, a function is also generated, at the bottom of your sketch file. Each time this variable changes, it will execute the code within this function! This means that we can leave most of the code out of the loop() and only run code when needed.
To upload the program to our board, simply click the «Upload» button.
Editing a sketch in the cloud editor.
The editor also has a Serial Monitor Tool, which can be opened by clicking the magnifying glass in the toolbar. Here you can view information regarding your connection, or commands printed via .
The Serial Monitor Tool.
After we have successfully uploaded the code, we can open the “Serial Monitor” tab to view information regarding our connection. If it is successful, it will print “connected to network_name” and “connected to cloud”. If it fails to connect, it will print the errors here as well.
The cloud editor is a mirrored «minimal» version of the Web Editor. Any changes you make will also be reflected in the Web Editor, which is more suitable for developing more advanced sketches.
8. Creating a Dashboard
Now that we have configured the device & network, created variables, completed the sketch and successfully uploaded the code, we can move on to the fun part: creating dashboards!
Visualize your data.
Dashboards are visual user interface for interacting with your boards over the cloud, and we can setup many different setups depending on what your IoT project needs. We can access our dashboards by clicking on the “Dashboards” tab at the top of the Arduino IoT Cloud interface, where we can create new dashboards, and see a list of dashboards created for other Things.
Navigating to dashboards.
If we click on “Create new dashboard”, we enter a dashboard editor. Here, we can create something called widgets. Widgets are the visual representation of our variables we create, and there are many different to choose from. Below is an example using several types of widgets.
The different widgets available.
When we create widgets, we also need to link them to our variables. This is done by clicking on a widget we create, select a Thing, and select a variable that we want to link. Once it is linked, we can either interact with it, for example a button, or we can monitor a value from a sensor. As long as our board is connected to the cloud, the values will update!
Let’s say we have a temperature widget that we want to link to the temperature variable inside the Cloud project thing.
Linking a variable to a widget.
Note that not all widgets and variables are compatible. A switch and an integer can for example not be linked, and will not be an option while setting up your dashboard.
We can also have several things running at once, depending on your Arduino IoT Cloud plan, which we can include in the same dashboard. This is a great feature for tracking multiple boards in for example a larger sensor network, where boards can be connected to different networks around the world, but be monitored from the same dashboard.
Congratulations
What will you build?
You are just a few easy steps from deploying your very own IoT project. Having a project connected to the Arduino IoT Cloud opens up many possibilities, such as tracking data in real time, triggering remote devices and building wireless systems.
What will you create?
More tutorials
You can find more tutorials in the Arduino IoT Cloud documentation page.