Home Automation with Arduino and ESP8266 using Tuya IoT Platform

Updated: May 27

Hello everyone, welcome to the article. We have already progressed and are still progressing towards becoming a complete digitally connected society. Humans are now connected better than ever before wherever they go, whatever they do. It is indeed important to constantly keep improving the standards and methods of this worldwide connectivity through the Internet of Things (or) IoT.

Today we are exploring something really really exciting. Today we will explore a lot of what Tuya IoT has to offer in the space of IoT as its name suggests and smart connectivity in general. We will not beat around the bush at any part of the article and will quickly go over what a Tuya Sandwich Evaluation Kit is and what it has to offer in itself and how it can easily be used by anyone. Then we will also use Tuya's IoT platform to showcase some real and practical solutions that it provides. Let's dive right in without further ado.

Bonus Fun Fact: Now, you can be a part of the Arduino Beta Test Program with Tuya and win some really really exciting gifts worth $7.5 and even more if you provide your valuable feedback!

1. About Tuya IoT and Tuya Sandwich Evaluation Kit

Tuya IoT Platform is a powerful platform to help brands, developers, retailers, and manufacturers get into the IoT/Smart Home space and quickly grow their products and businesses. Some many products and appliances can be customized on Tuya IoT. There are some pre-built products as well which are based on the Tuya Platform and can prove to be very useful in our daily life.

Now, let's dive into all there's to the Tuya Sandwich Evaluation Kit. This is Tuya's wonderful development platform which is heavily compatible with the Arduino ecosystem. Tuya Sandwich Evaluation Kit as its name suggests is like a sandwich, assembled layer by layer, which allows you to quickly implement a complete IoT based environment in a very hassle-free manner. Any Arduino Ecosystem-based device can be integrated through the Tuya cloud modules of various communication protocols such as Zigbee, BLE, Wi-Fi, and NB-IoT. To sum it all in a single line, Tuya Sandwich Evaluation Kit is going to make your IoT life easier than ever before. Let's have a closer look into the various components involved to get a better picture out of it, shall we?

Tuya Developers: Tuya for Developers

2. More About the Components

Let's go over the components of the Tuya Sandwich Evaluation Kit:

  • 2.1. Power Supply Board: The Power board provides stable and continuous electricity for the development kit to strengthen the power supply capability of the master control board. It can also output different electrical levels for device debugging.

  • 2.2. Microcontroller Board: The microcontroller board can input and output peripheral information and send out commands and is heavily compatible with the Arduino ecosystem.

  • 2.3. Communication board: The wireless communication board provides various networking capabilities to the master control board. The Wi-Fi communication board with voice capabilities supports local far-field voice wake-up, online speech recognition, and device control.

  • 2.4. Function Board: The function board provides substantial peripheral functions for the Evaluation Kit, such as sensors and actuators.

3. Real-Life Application - Home Automation Project Using ESP8266 & Arduino With Tuya IoT Platform

Now we will be building some real and practical stuff using the above knowledge. We will make a simple home automation project using an ES8266 module connected to an Arduino board along with the Tuya IoT Platform. We will get an ordinary bulb to turn on via WiFi through our setup using a mobile phone. So, let's get started.

3.1 Gather Required Stuff!

There's not much that would be needed in terms of hardware for this project as it is just a basic representation of the capabilities of the Tuya IoT Platform.

All components you will be needing are:

  • An Arduino Board

  • A Relay Module

  • A Power Supply Module

  • An ESP8266 Module

  • A Breadboard

  • A Few Jumper Wires

3.2 Wiring / Connections / Circuit Diagram

In technical terms, the wiring involved in any project is directly proportional to the number of components involved in it. In simple terms, the wiring or the connections for this project are very simple again as we earlier mentioned it is a very simple project. The software side of things is what will mostly matter to us here. Let's quickly get over to the circuit diagram. Have a look at the images below for a reference to the circuit diagram.

Detailed Connection Instructions:

3.2.1 Firstly connect the power supply board/module onto the breadboard as this will help eliminate any power-related issues in the circuit later on and will also make it easy to supply power to all components easily.

3.2.2 Then connect the ESP8266 module onto the breadboard for easy pin-access to the module. Also, connect the power pins of the module to the power supply module or the rails of the breadboard.

3.2.3 Then fix the Arduino board onto the breadboard so that it doesn't move much which will help you work easily with it. Then connect the ESP8266 according to the above diagram to the Arduino board.

3.2.4 Lastly connect the relay module to the breadboard as that is the main output of our circuit.

3.3 Setting up the Tuya IoT Platform

In the previous step, we did the hardware configuration part. Now, in this step, we will be setting up the Tuya IoT Platform for operating the smart bulb and after that, we will upload the code in the Arduino UNO board with the help of Arduino IDE which will complete the setup. We need to follow the steps given below.

3.3.1 Before using the Tuya IoT platform you need to make sure that you have an account on that platform. You have to register your details and create an account. As soon as the account is created, you will be able to access the Tuya IoT platform. Then you need to log in using your credentials and you are ready to go.

Now as you log in to the Tuya IoT Platform. On the left-hand side, you will see a Products button click on that and the products tab will open up. Under the products tab, there you need to click on the Development button.

When you will click the Development button you will see a "Create" button in the middle of the screen click on that and the new product development screen will open up in front of you.

3.3.2 Here we need to select the type of product that we are going to make. In our case, we are making a smart bulb, so we will quickly go to the Lighting section now we have to select the Category so here under General Lighting we will select Light Source.

After the Category has been selected, we will Select a Solution for our product as we are making a Custom Product so we need to select Custom Solution and then click on Light Source.

3.3.3 Now we have to enter the Product Information Details. Here we have to enter the Product Name. You can give any name you like.

We are using the ESP8266 WiFi module. Therefore under Protocol, we need to select Wifi and after that select Standard Power Consumption. When all these are done, click on the Create button.

3.3.4 As you click the Create button, the platform will ask you to add the standard functions that you want in your Product. Now we need to select the ON/OFF function from the list of functions present on the left-hand side which has a DP ID-20. When selected it will appear on the right-hand side under the selected functions list and after that click the OK button. We are only adding this function because we just need to switch the Relay ON or OFF.

3.3.5 Once all this Product Definition thing is done, we need to head over to the Hardware Development tab. Here we need to select the Integration method as Tuya Standard Module SDK. As we select the Integration method, a list of modules will open up. From this list, we need to select the module that we are using. In our case, we need to select the TYWE1S Wi-Fi Module/ESP8266 Module.

Copy the PID and send it to devops@tuya.com together with your Tuya IoT account name to get your Token ID. We will need it later on.

3.4 Integration of Tuya with ESP8266

GitHub Reference: Click Here to Go There

Sign up for the PMS System and login to the portal.