🏆 Join the TuyaOpen AI Hardware Contest! 100 days to build the future of AI devicesLearn More →
Skip to main content

Simple Tuya IoT Switch

Project Overview

The IoT Switch project is a simple yet powerful demonstration of how to build a cloud-connected device using Tuya's platform. This example showcases a basic switch that can be controlled via a mobile app, highlighting essential concepts such as DP (Data Point) control and minimal code implementation for a connected device. The project includes secure device authentication using PID, UUID, and Auth Key, and is compatible with a wide range of hardware platforms, including Tuya T series MCUs, ESP32, and Linux-based MCUs.

IoT Switch Project Screenshot

Features

  • Simple Tuya cloud-connected switch device
  • App-based remote control
  • Minimal and easy-to-understand codebase
  • Secure device authentication (PID, UUID, Auth Key)
  • Supports multiple hardware platforms

Supported Hardware

  • Hardware platforms/chip models: Tuya T5, Tuya T2, Tuya T1, ESP32, Linux SoCs, and more

Quick Start

  1. Clone the TuyaOpen repository or download the source code.
  2. Set up your development environment following the Quick Start Guide.
  3. Obtain your Device (UUID/Auth Key) Key Pair from the Tuya Developer Platform.
  4. Update the credential information in the tuya_config.h header file.
  5. Compile and flash the firmware to your device.
  6. Run and debug your IoT Switch.

Need Custom Features?

The PID (Product ID) is a unique string used to identify and associate your product definition in the cloud. If you want to implement control for multiple sensors or multiple switches, you can create your own custom device ("product") on the Tuya Developer Platform here and define your own control DPs (Data Points). This allows you to achieve more complex and diverse device functions through the cloud. Finally, on the device, update the PID of your defined product in the tuya_config.h header file and develop support for the new DP points as needed.

🚀 Go to Project Repository