MCU SDK Development

Last Updated on : 2024-03-13 10:17:33download

This topic will walk you through how to develop with MCU interfacing solution to enable your products to connect to the cloud. The step-by-step guide focuses on the operation performed on the Tuya IoT Platform. For more information about the implementation process, see the documentation as per your connectivity solution.

Overview

The MCU interfacing solution enables products with built-in microcontrollers to connect to the cloud and become connected. Tuya provides one-stop IoT development services including the three essentials for typical IoT products, namely network modules, mobile apps, and cloud services. With Tuya’s MCU SDK, all-in-one mobile apps, and control panels, you can focus on application development simply, connect your product to the Tuya IoT Platform easily, and benefit from the cloud services quickly.

Solution selection

The following block diagram shows how the MCU communicates with Tuya’s network modules.

MCU SDK Development
  • Hardware solution: including the selection of the communication protocol and network module.

    • A module that is flashed with the generic firmware is referred to as the generic module. The generic modules support popular communication protocols including Wi-Fi, Bluetooth LE, Zigbee, NB-IoT, and GPRS.
    • You need to decide which protocol to use and then choose a network module accordingly. The Tuya IoT Platform will recommend you the best-suited modules as per your protocols.
  • Mobile app solution: all-in-one apps or OEM apps.

    • Two free all-in-one apps for iOS and Android, namely the Tuya Smart app and the Smart Life app, can be downloaded from the App Store or app markets.
    • The OEM app service can help you build a branded mobile app online without coding. For more information, see OEM App.
  • Cloud services: safe and reliable cloud services that can serve users around the world. Have your product integrated with Tuya’s network modules to connect to the cloud. Tuya also provides a host of OpenAPIs to help you quickly implement native applications. For more information, see Cloud Development Platform.

Product creation

Log in to the Tuya IoT Platform, create a product, and download the MCU SDK.

Tuya IoT Platform provides one-stop services to help you in the development process from prototype to mass production. You can make your product IoT-enabled with the Tuya IoT Platform in four steps.

Step 1: Create product

For more information about the detailed processes of product creation, see Create Products. The Tuya IoT Platform provides two development methods, namely the no-code development and custom solution. You need to choose Custom Solution to interface an MCU with Tuya’s network modules. The protocol determines your options for network modules.

MCU SDK Development

Step 2: Define functions

For more information about how to define functions, see Product Functions.

A data point (DP) is an abstract representation of a product function. Tuya provides all products with standard DPs. You can select the ready-made standard DPs or create custom DPs to customize the required functions.

MCU SDK Development

Step 3: Select panel

The interface on the mobile app used for users to interact with a smart device is called a panel. Tuya provides up to 100 free all-in-one panels that also support personalized editing. For more information, see Design App UI.

MCU SDK Development

Step 4: Download SDK

The Tuya IoT Platform recommends modules to you based on your product and protocol. You can place an order for the modules online. You can also change the selected modules online as needed. For more information, see the Module Datasheet.

MCU SDK Development

You can download all the development documents with one click. They include:

  • MCU SDK: an SDK in C automatically generated based on your defined functions. The SDK has implemented the communication architecture and protocol parsing, allowing you to directly import it to your project to proceed with application development.

  • General serial protocol: a protocol automatically generated based on your defined functions.

  • Module debugging assistant: an integral debugger used to verify the serial communication between the MCU, module, and the cloud.

  • Function debugging file: used for the debugging assistant to test the product ID (PID) and DPs.

    MCU SDK Development

Development and debugging

After a product is created, you can purchase a sample module, download the SDK, and start embedded programming and debugging. A range of documentation will help you get started quickly.

Hardware debugging

After you get the sample module, you can build a minimum system to learn how the communication between the MCU, module, and the cloud works as well as the pairing process. For more information, see the following documentation.

Software debugging

If your MCU has sufficient resources, we recommend you port the MCU SDK for efficiency purposes. You only need to implement the serial communication and the required applications without taking care of the protocol infrastructure. The requirements for MCU resources vary depending on the SDKs. Take the Wi-Fi MCU SDK as an example. Its requirements for hardware resources are as follows.

  • 4 KB flash memory.
  • About 100 bytes of the RAM, depending on the data length of the DP.
  • If you enable OTA updates, it must be greater than 260 bytes. 9-level nested function.

If your MCU does not have sufficient resources, you can refer to the functions in the SDK for interfacing with Tuya’s protocol. For more information, see MCU SDK Porting.

Joint debugging

If you get errors, you can view the device logs on the Tuya IoT Platform to locate problems. For more information, see Device Log Service.

If the documentation cannot resolve your questions, you can submit a ticket to request technical support. For more information, see Service and Support.