A Smart Hvac Controller Using Tuya Cloud Platform

Photo of naumanshakir

Made by naumanshakir

About the project

This is a quick tutorial to make a Smart HVAC Controller using Tuya IoT Cloud Development Platform and SDK.

Project info

Items used in this project

Hardware components

Digilent 5V 4000mA Switching Power Supply Digilent 5V 4000mA Switching Power Supply x 1
DHT22 Temperature Sensor DHT22 Temperature Sensor x 1
ControlEverything.com 4-CHANNEL RELAY CONTROLLER FOR I2C ControlEverything.com 4-CHANNEL RELAY CONTROLLER FOR I2C x 1
Switch Actuator, APEM A01 series Illuminated Push-Button Switches Switch Actuator, APEM A01 series Illuminated Push-Button Switches x 1
Espressif Wemos D1 Mini Espressif Wemos D1 Mini x 1
Arduino Nano R3 Arduino Nano R3 x 1

Software apps and online services

Breadboard, 830 Tie Points Breadboard, 830 Tie Points

Story

Overview

This tutorial aims at making a Smart HVAC Controller using the Tuya Cloud Platform.

Introduction

There are a number of HVAC controllers available on the market, most of them are classic with knobs on them and use analog sensors. To increase the energy efficiency of any system, it must be coupled with sensor nodes that can take readings very fast and it should be connected with the actuators like mechanical knobs or communication protocols like SPI, I2C etc making a robust solution. So a smart system will change the temperature parameters of the air conditioner based on the real-time data feed coming from the sensors. It should not only act to temperature fluctuations but it should be smart enough to make the whole system energy efficient by setting optimum temperatures and turning on/off the air-conditioner based on the out-door temperature parameters and the time of the day.

This tutorial is a step-by-step instruction on how to build a prototype of such a smart system using Tuya platform and off-the-shelf hardware components.

Tutorial Parts

What is Tuya

  • What is Tuya

Why Tuya SDK?

  • Why Tuya SDK?

Components Used

  • Components Used

Circuit Diagram

  • Circuit Diagram

Firmware and Configurations

  • Firmware and Configurations

What is Tuya?

Tuya is an international company that provides IoT and AI solutions along with compatible hardware so that the developers don’t have to spend much time sourcing, testing, and debugging a lot of components before reaching a final BOM. While end-users can instantly get their new Tuya device ready and running in a matter of minutes. Tuya Sandwich Evaluation kit is an example of a powerful merger of hardware along with an easy-to-use SDK.

Why Tuya SDK?

Tuya is not only a hardware company, in fact, but it also provides a full-fledged cloud IoT platform.

https://developer.tuya.com/en/?_source=aae11f336c7c5ca1ff908513b7c5802f

Using the Tuya Cloud Development platform, you can add, remove, update and manage your fleet of IoT devices very easily and can even run analytics on real-time data. To make the life of the IoT developers easier, Tuya provides its easy-to-use SDK which with pre-built templates, a lot of tutorials, well-written documentation and a large community of developers using Tuya. All of these features make Tuya an ideal choice for new IoT products.

How Do Traditional IoT Systems Work?

The traditional IoT systems work as shown in the picture above. An IoT solution architect has to manage each and every part of the system in order to roll out a product and it spans over 1-2 years of development.

Typical Tuya Workflow

A typical Tuya solution workflow looks something like shown in the picture above. You need to have an MCU and a Tuya module connected over UART. This configuration makes things very easy as you don’t have to worry about the WiFi configurations, communications taking place between the Tuya module and Tuya Cloud Platform and data delivery as all of these things are handled by a black box which we can call Tuya Module. You just need to send simple instructions from your MCU to Tuya Module and the rest is handled by Tuya Module. Tuya Module communicates with the Tuya Cloud Development Platform and you can connect a number of the different devices to the Cloud Development Platform including your custom-built smartphone and webapp.

Components Required

The list below is a suggested list of components.

Wemos D1 Mini ESP8266

  • Wemos D1 Mini ESP8266

https://www.amazon.com/Makerfocus-NodeMcu-Development-ESP8266-Compatible/dp/B01N3P763C/ref=sr_1_16?dchild=1&keywords=wemos+d1+mini&qid=1630581477&sr=8-16

Arduino Nano

  • Arduino Nano

https://www.amazon.com/Zmarthumb-Pre-soldered-ATmega328P-Microcontroller-Development/dp/B08NCHM372/ref=sr_1_4?dchild=1&keywords=arduino+nano&qid=1630581524&sr=8-4

DHT22

  • DHT22

https://www.amazon.com/ICQUANZX-Digital-Temperature-Humidity-Monitor/dp/B08XQNKW4P/ref=sr_1_3?dchild=1&keywords=dht22&qid=1630581572&sr=8-3

4 Channel Relay

  • 4 Channel Relay

https://www.amazon.com/JBtek-Channel-Module-Arduino-Raspberry/dp/B00KTEN3TM/ref=sr_1_1?dchild=1&keywords=4+channel+relay&qid=1630581605&sr=8-1

Small 5V UPS to Power Arduino and WeMos

  • Small 5V UPS to Power Arduino and WeMos

https://www.amazon.com/MakerHawk-Raspberry-Uninterruptible-Management-Expansion/dp/B082CVWH3R/ref=sr_1_15?dchild=1&keywords=small+5v+ups&qid=1630581650&sr=8-15

Setting-up Tuya IoT

Create an account at http://iot.tuya.com/?_source=fbe89820b4f49372b482d22144e5889aand log-in to the account

Then click on Create

Then again click on Create

Then select HVAC as shown in the picture below

Put the product details as shown below and click Create button

Now select the functions(from Select HVAC Functions and Other Functions tab) as shown below in the next screen

Now in Hardware Development tab, your properties should look like as shown below

And don’t forget to note down your own device PID.

Now go to https://pms.tuyacn.com/en/login, create an account, login access the “Activation Code Verification” option, and enter your “Production Certificate” code. Click on “Confirm” to complete the activation process.

Then send PID and Tuya Account for devops@tuya.com and you’ll receive your token code.

Configuring WeMos

Now, download the Tuya program from the link here: https://drive.google.com/file/d/1SF-rM5qDLaPJiuMHrkqFauVyRXSSHMkj/view?usp=sharing

Extract it, open it and follow the instruction screenshots below

📷📷Now install the ESP8266 drivers as shown below.📷

📷

Once it succeeds, you are good to go. Your ESP8266 is now flashed with the Tuya SDK.

Firmware and Configurations

Softwares Used

Arduino IDE

  • Arduino IDE

Arduino Nano Firmware

Download and install Tuya library from the link given below

https://github.com/tuya/tuya-wifi-mcu-sdk-arduino-library?_source=e4e486334a69bede1529897274cd23a3

Get Firmware Version from the software used above for flashing ESP8266

Download the Firmware from this github repository

https://github.com/Nauman3S/TuyaHVAC

Open Firmware.ino file and put correct PID and Firmware versions in these variables

unsigned char pid[] = {"ma67l9sgmdyg3d2k"};

unsigned char mcu_ver[] = {"1.0.0"};

Circuit Diagram

WeMos D1 Mini Pinout

Arduino Nano Pinout

System Circuit

📷

Testing

To test the Firmware just upload it to Arduino Nano and press the reset button. It will automatically start sending the data feed to the Tuya IoT cloud platform and will control the relays accordingly.

In simple words, whenever the Sensor Node runs, it will get the temperature readings and will use the readings to do comparison with the set-point mentioned in the Firmware to control the heater of Air Conditioner relays.

Connect the relays and other components as shown in the diagram above and you will get something like this shown below.

Please note that Arduino Nano can be replaced with Arduino UNO, Arduino Mega or even with ESP32 or ESP8266 boards.

Connected Network State

Once the system is powered on you will see the RED LED lights up on ESP32 or your Arduino.

When the system connects to the Tuya platform over WiFi you will see Blue LED lights up on your ESP32 or Arduino.

Short Demo Video

Demo Vidoe: https://youtu.be/PJBbCqMyLOo

Details About the project: https://youtu.be/UVlWeG-6pZQ

Conclusion

In conclusion, we can now say that Tuya IoT Cloud Development Platform and SDK has made the development of Smart IoT products much easier.

In order to learn more about the Tuya ecosystem, have a look at the articles below.

Tuya IoT Platform: http://iot.tuya.com/?_source=fbe89820b4f49372b482d22144e5889a

Tuya Developer Platform:https://developer.tuya.com/en/?_source=aae11f336c7c5ca1ff908513b7c5802f

Tuya Arduino Developer Program:https://pages.tuya.com/develop/ArduinoBetaTest_discord?_source=58a75a214b395949d57c2c03283c251c

Firmware burning guide:https://github.com/GITOLEO/Tuya-ESP8266-firmware-burningauthorizations-guide

Schematics, diagrams and documents

Circuit Diagram

Code

Smart HVAC

Credits

Leave your feedback...