Select Page


This tutorial aims at making a Smart Door Bell using TuyaOS Link SDK on Raspberry Pi.


There are a number of Smart DoorBells available on the market, most of them are classic and others are smart with cameras and speakers. Like this SmartDoor Bell showcased by Tuya in their expo.

What features does a smart doorbell have?

  1. It should be securely connected to the internet.
  2. It should take a picture or show a live video of the person pressing the doorbell button.
  3. The live camera feed should be accessible from a smartphone or should be visible on a LCD screen in the house.

Based on the above features, we can make a DIY smart doorbell.

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

Tutorial Parts

  1. What is Tuya
  2. Why Tuya Link SDK?
  3. Components Used
  4. System Architecture
  5. Circuit Diagram
  6. 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 Link SDK?

Tuya is not only a hardware company, in fact, but it also provides a full-fledged cloud IoT platform and easy to use SDKs,

Tuya also provides a RTOS based operating system called TuyaOS and the amazing fact about TuyaOS is that it is a cross-platform OS so that you can run it on Linux, MCUs and even on non-OS based devices.

TuyaLink SDK is also provided which can be compiled and easily be used in Python or C programs on Linux SBCs like Raspberry Pi. You can find more about Tuya Link SDK on Tuya Github Repository.

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 has 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 web app.

Components Required

The list below is a suggested list of components.

We will connect the Big Dome button, speaker and Pi Camera with Raspberry Pi and Raspberry Pi will be powered with 12V power supply via Buck Converter.

Main components of the smart doorbell.


Sensor Node

Above shown is the sensor node architecture of our smart DoorBell. Raspberry Pi is acting as a mainboard to which the camera, bell button and speakers are connected.

System Architecture

The complete architecture of our system is shown in the picture above. When a person presses the smart doorbell button, the live camera feed will be displayed on the HDMI monitor and the notification will be sent to the Tuya IoT Cloud using TuyaOS Link SDK. The Tuya IoT Management App can then see the doorbell notifications by connecting to the Tuya Cloud.

Setting-up Tuya IoT

Step1: Configuring Device

Create an account at log-in to the account

Then click on Create

Then again click on Create

Find Standard Category, scroll down to the bottom of the page, and click Can’t find the category? hyperlink.
Raspberry Pi is a non-standard category in Tuya Platform, you will need to select Can’t find the category? when you create a product.

Type-in the product information(Link SDK Demo) and select Wi-Fi as the protocol type, choose Standard Power Consumption, and click Create Product.

Get the PID information of your newly created device.

Step 2: Functions Definition

Tuya devices communicate with the cloud through data points (DPs). We need to add the DP ID according to product functions, and then configure related information.

The Tuya IoT Platform supports six data types, including Boolean, value, enum, fault, string, and raw. For more information, see Custom Functions.

Only custom functions can be added in this step because we are using Raspberry Pi.

In the Function Definition > Custom Functions section, click Create Functions.
Add functions

In the Newly created custom function pop-up window, enter the relevant information of the DP and click Confirm.
Create custom functions
The created function will be displayed in the Custom Functions section.
Custom functions

Step 3: Selecting a panel

You can view the data that is transmitted between the device and the cloud on the app. Select the DIY Style Panel for better debugging experiences.

Step 4: Getting licenses

In the Hardware Development tab, select the Self-Developed Module SDK, and set the required fields.
Self-Developed Module SDK

In the Develop SDK section, keep the default settings for Chipset Platform, Operating System, and Toolchain, enter a module name, and then click OK.
Wait a minute. The page will refresh and the free licenses will be displayed.

On the right side of the Selected Module section, get free licenses.

Step 5: Creating Cloud Development Environment

Navigate to Cloud from the left sidebar and press the “Create Cloud Project” button. Then fill-in the details shown in the picture below.

In the next screen click “Authorize”. In the Configuration Wizard, enter your email address and password

Configuring Raspberry Pi

Connect your Raspberry Pi to an HDMI LCD Screen and then connect USB keyboard and mouse to the USB ports of the Raspberry Pi.

  1. Power on your Raspberry Pi
  2. Download Raspberry Pi Imager from this link
  3. Put the SD Card in your laptop SD Card port or use a USB SD Card reader.
  4. Install and Open Raspberry Pi Imager
  1. Click on Choose OS
  1. Choose Raspberry Pi OS (32-bit)
  1. Then Choose Storage(sd-card)
  2. Click on the Write button so that it can Download and Write Raspberry Pi OS to the SD Card.
  3. Once done, put the SD Card in the Raspberry Pi SD Card port and power on your Raspberry Pi.
  4. Then open Raspberry Pi Terminal.

Firmware and Configurations

Once the terminal on your Raspberry Pi is opened, execute the following commands one-by-one.

nano tuya-iot-sdk-embedded-c/examples/switch_demo to edit tuya_config.h

  • Change the parameter of TUYA_PRODUCT_KEY to the PID of your product created on the Tuya IoT Platform.
  • Change the parameter of TUYA_DEVICE_UUID to the UUID provided in the license list.
  • Change the parameter of TUYA_DEVICE_AUTHKEY to the key provided in the license list.
  • cd tuya-iot-sdk-embedded-c
  • mkdir build && cd build
  • cmake ..
  • make

More details can be found here

The commands stated above will update your Raspberry Pi OS, download curl and git and then download the smart doorbell firmware from github repository.

Circuit Diagram

Raspberry Pi Pinout

System Circuit

Complete circuit diagram is shown above. You just need to connect an ordinary speaker and a PiCam to the raspberry pi to the respective ports. Then connect a big dome button to the raspberry pi on pin number 18. Optionally, you can also connect the big dome button LED pins to the 12v power supply.


  1. Download the Tuya IoT Management App. Scan the QR Code below to download it.
  1. Once you have the app installed, log in using the QR code of the project, the username, and the password you used when you created the asset and the user.

You can find the QR code of the project by navigating to Cloud > Development > My Cloud Project > Devices > Add Device > Add Device with IoT Device Management App

Then from the Devices section of the Cloud menu, add a new device

Once the device is added, scan the QR code with your app and enter your username and password to log in.

You will be automatically redirected to a page where you can see all your assets. Click on the asset that we created and navigate to the Devices section.


To test it, turn on your raspberry pi and execute the following commands

cd ~

cd Smart-Doorbell


Once you run the program, two c++ programs will run simultaneously.

  1. The first program is the camera, sound and button handler. When you press the button it will start the live preview and play the bell sound.
  2. The second program is the cloud program which connects with the Tuya IoT Cloud using TuyaOS Link SDK. When the buttons is pressed, the notification is sent to the smartphone app so that the user should know that someone pressed the smart doorbell button.

Smart Doorbell Powered On

Smart Doorbell powered on. If you are using a big dome button with LED in it, the LED will light up. If you don’t have a speaker but have an HDMI monitor, you can skip the speaker connection as HDMI monitors already have speakers in them so pressing the big dome button will play the bell sound from the HDMI speaker.

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 Video:

Github Repository:


In conclusion, we developed a Smart Doorbell using the TuyaOS Link SDK which connects to the Tuya IoT Platform. The Smartphone app also gets notifications from Tuya IoT Platform. Following the whole tutorial yields a working smart Doorbell.

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

Tuya IoT Platform:

Tuya Developer Platform:

Tuya Arduino Developer Program: