Tuya Smart Module SDK Development Course Series - 2. Introduction to Tuya IoT Platform
[Copy link]
There are three main ways to develop products using Tuya Wi-Fi modules and Tuya Wi-Fi & Bluetooth LE dual-mode modules:
- Zero-code development: Tuya provides a visual function configuration interface. No programming experience is required. You only need to configure the product functions online to complete firmware development and quickly make the product intelligent.
- MCU SDK development: Perform function development on the MCU, and use the MCU SDK provided by Tuya to communicate with the Tuya module through the serial port to realize product intelligence. Tuya provides MCU SDK, which encapsulates the function interface of uplink and downlink communication, OTA, data analysis and other functions. You can transplant the SDK to the MCU for interface adaptation, and call the relevant interface to complete the application code development, so as to realize product intelligence.
- Module SDK development: Tuya provides module SDK, and developers use the SDK provided by Tuya to perform secondary development on the module. SDK encapsulates the HAL hardware layer, system layer, network layer, OTA and other interface functions. You only need to call the relevant interface functions to develop application code without worrying about complex functional logic, and you can quickly complete product intelligence.
This chapter mainly introduces the operation steps on the Tuya IoT platform when performing secondary development of Tuya modules by using the module SDK, as well as the six data types and three different data transmission types on the Tuya IoT platform .
1. Product creation
Before development, you need to create the corresponding product on the Tuya IoT platform, select the relevant functions, panels and modules to be used, and obtain the function point ID (DP ID) and product ID (PID) before you can perform secondary development on the Tuya SDK. First log in to the Tuya IoT platform. If you do not have an account, you need to create an account on the Tuya IoT platform.
Next, we will use the CBU module to customize the development of a white light as an example to demonstrate the operation steps on the Tuya IoT platform:
1.1 Confirm the category
1. Click the "Create Product" button pointed by the arrow to start creating a product.
2. Select "Lighting" in the standard category and select "Light Source".
1.2 Select a development plan
1. Select "Customize Plan" according to the arrow instructions.
Zero-code implementation, just configure the product online to generate the firmware. For detailed introduction, click here.
Here we are doing secondary development of the Tuya module, so select "Custom Solution".
2. Fill in the product name according to the product and module you are going to develop, select the corresponding communication protocol, and click "Create Product" after the configuration is completed.
Here we plan to use the CBU module to develop a product that can adjust the light brightness. The CBU module is a Wi-Fi & Bluetooth LE dual-mode module, and the selected communication protocol is "WiFi-Bluetooth".
If you are not sure what protocol your Tuya module uses, you can click here to find the specification sheet of the corresponding module.
1.3 Adding Function Points
1. According to the functions that the product wants to achieve, select the corresponding function points, and click "Confirm" after completing the selection.
If some of the function points you need are not included in the standard function points, you can customize the function points you need after selecting the standard function points. (Standard function points can be well displayed and operated on the public version panel. If you select a custom function point, it may not be displayed and operated on the panel).
Note: For product stability considerations, it is recommended that the total number of standard function points and custom function points for each product should not exceed 40. If exceeded, please pay attention to product stability testing.
1.4 Select Panel
Select the panel. You can choose the panel according to your preference. (The function points selected above are too few. If you use the "Light Source-007P" panel, the panel may not open. It is recommended to use other panels.)
1.5 Hardware Development Setup
1. Click "Hardware Development", select "TuyaOS", and select "CBU Wi-Fi&Bluetooth Module" (if you are using other modules, just select the corresponding module).
2. "Add custom firmware" pointed by arrow ① means uploading the product firmware you have developed (how to develop will be explained in the following content).
3. Click "ty_iot_wf_bt_sdk_rtos_BK7231N" pointed by arrow ② to download the SDK of the module.
2. Function point introduction
DP (Data Point): Often referred to as a function point, it is the most important part of smart product development and is used to describe product functions and their parameters.
DP (Data Point) is a very important concept on the Tuya IoT platform. Only by understanding the settings of the function points can we better carry out development.
DP ID: The code of the function point. The function data between the device and the cloud is transmitted through the function point ID. The first 100 DP IDs are reserved for use by Tuya, and the custom DP point starts from 101.
DP data type: Each function can be defined by different data types. Tuya supports six data types: Boolean, numeric, enumeration, fault, string, and transparent.
Boolean, numeric, and enumeration are basic types. Most functions can be defined by these three data types.
Fault type is specifically used for fault definition, which is convenient for fault statistics in the background.
String type and transparent type are used for more complex functions. They are recommended only when other types cannot meet the requirements.
2.1 Boolean
Applicable to binary variable functions that are either true or false.
For example, a switch function can have a value of on or off.
2.2 Numerical type
Applicable to linearly adjustable types of data.
For example, temperature regulation, temperature range 20-40℃.
Value range: the maximum and minimum values reported by the device.
Spacing: Starting from the minimum value, the distance between every two adjacent values.
For example: Assuming the data range is 0-100, when the interval is 1: the data values are 0, 1, 2, 3...; when the interval is 2: the data values should be 0, 2, 4, 6...; when the interval is 3: the data values are 0, 3, 6, 9...
Multiples: When a decimal number needs to be entered, convert it using multiples.
For example: when the device reports 9999, if the multiple is set to 0, the panel displays a value of 9999; if the multiple is set to 1, the panel displays a value of 999.9; if the multiple is set to 2, the panel displays a value of 99.99; if the multiple is set to 3, the panel displays a value of 9.999...
2.3 Enumeration
Useful when there is a limited set of custom values.
When editing function points, enumeration values support letters, numbers, and underscores. After pressing the Enter key, the enumeration value is automatically generated. The enumeration value code starts from 0 and is transmitted in the hardware joint debugging as enumeration value code. Each enumeration value is no longer than 15 characters, and a maximum of 10 enumeration values can be defined.
For example, working gear, low/mid/high.
2.4 Fault type
Applicable to function points for reporting and counting faults, supports multiple faults, and data is only reported but not sent.
For example, temperature sensor failure, motor failure, and high temperature failure.
2.5 String Type
Function point transmitted as a string.
The maximum length of a character string is 255 bytes.
2.6 Transparent transmission
Function point for transparent transmission in binary form.
The maximum length of transparent data does not exceed 255 bytes.
2.7 Data Transfer Type
On the Tuya IoT platform, except for the DP data type of fault type, which can only be a reporting data transmission type, the other five data types can be selected according to actual needs.
Data transmission type Meaning
Can be sent and reported Command data can be sent to the device, and device data can be transmitted to the cloud.
Report only Data can only be transmitted from the device to the cloud.
Send only Data can only be sent from the cloud to the device.
3. Device Panel
After the product is created and the function definition is set, the panel needs to be set. For the control panel, you can directly select the public version panel, or you can develop a new panel yourself using the panel SDK. Some products also support visual configuration panels. You can complete the panel development by simply dragging and dropping on the panel workbench. What you see is what you get.
Panel Detailed Introduction: Panel Development-Document Center-Tuya Developer
4. Hardware Development
In the hardware development part, the main operations are to select the development method, select the module, download the development data, upload the firmware, etc.
Hardware Development Details: Managing Custom Firmware - Document Center - Tuya Developers
5. Product Configuration
The main functions in product configuration are: managing firmware upgrades, multi-language management, device message push, network configuration information, quick switch settings, scene linkage settings and product language capability configuration.
Product configuration details: Product Configuration-Document Center-Tuya Developer
|