IFREEQ Docs
  • Introduction
  • Update Log
  • General Knowledge
    • About IoT
    • Electricity
      • Plug & socket types around the world
        • Power plug & outlet Types A & B
        • Power plug & outlet Type C
        • Power plug & outlet Type D
        • Power plug & outlet Type E
        • Power plug & outlet Type F (Schuko)
        • Power plug & outlet Type G
        • Power plug & outlet Type H
        • Power plug & outlet Type I
        • Power plug & outlet Type J
        • Power plug & outlet Type K
        • Power plug & outlet Type L
        • Power plug & outlet Type M
        • Power plug & outlet Type N
        • Power plug & outlet Type O
      • Full list: Plug, socket & voltage by country
      • Map showing the spread of the different plug types worldwide
      • Useful information for travellers
      • History of domestic electricity
        • Why isn’t there a universal standard electric plug?
        • Why isn’t there a standard voltage around the world?
      • Three-phase electric power (industrial applications only)
    • Certifications
    • Home Automation Brand
    • Home Automation Catalog
    • Industry Term
    • Network Term
    • The Third-party Control
      • AliGenie
      • Amazon Alexa
        • FAQs About Amazon Alexa
      • DuerOS
        • FAQs About DuerOS
      • Google Assistant
        • FAQs About Google Assistant
      • Home Assistant
        • FAQs About Home Assistant
      • HomeKit
        • FAQs About Homekit
      • IFTTT
      • Xiao AI
      • Yandex Alice
        • FAQs About Yandex Alice
  • Developer
    • Introduction
      • What is Tuya Smart?
      • What does Tuya do?
      • Tuya Smart Cloud Platform Overview
      • Advantages
      • Terms
      • Limits
    • Quick Start
    • Configure in Platform
      • Create Products
      • Function Definition
        • Overview
        • Standard Functions
        • Custom Functions
        • Cloud Functions
      • Design App UI
      • Configure Hardware
      • Cloud Configuration
        • Introduction
        • Upgrade Firmwares
        • Set up Multilingual UI
        • Manage Alarms
        • Configure Network for Devices
        • Enable Toggles on App
        • Automate the Smart Devices
      • Mass Production
    • Device Development
      • Access Mode MCU
        • MCU Access Guide
        • Wi-Fi General Solution
          • Wi-Fi Module MCU Development Overview
          • Hardware Design Reference Wi-Fi
          • Software Reference Wi-Fi
            • Tuya Cloud Universal Serial Port Access Protocol
            • Overview of migrating Tuya's MCU SDK
        • Wi-Fi Power Off Fast Connect Device Solution
          • Overview
        • Zigbee General Solution
          • Overview
          • Software development
            • Tuya Zigbee module UART communication protocol
          • Hardware Design
        • BLE General Solution
          • BLE Module MCU Development Overview
          • BLE Hardware Design
        • NB-IoT General Solution
          • NB-IoT Development Guide
          • Introduction to NB Module - NM1
      • Access Mode SoC
        • SoC Development Overview
        • Lighting
          • Guidance
          • Design
          • Test
        • Electrician
          • Guidance
          • Design
          • Test
      • Access Mode Link
        • Wi-Fi Chip SDK
          • Tuya Wi-Fi SDK Reference
          • Development Environment Setup When Using Tuya Wi-Fi SDK
        • BLE Chip SDK
          • TUYA BLE SDK User Guide
        • Zigbee Chip SDK
          • TUYA Zigbee SDK Document
      • Cloud Mode
        • Wi-Fi&BT Dual Mode Module
        • Wi-Fi Module
        • Bluetooth Module
        • Zigbee Module
        • Sub-G Module
      • Tuya Development Boards
      • Access Mode Simmulator
        • Module Debugging Assistant Instruction
      • Embedded License
        • Embedded open source license
    • Smart Product Solution
      • Gateway
        • MCU Access
        • Link SDK Access
        • PCB Details
      • HouseHold
        • Cleaner Robot
        • Air Conditioner
      • IPC
      • Lock
        • BLE Lock
        • Wi-Fi Lock
        • Zigbee Lock
      • Remote Control
      • Voice Product
        • Domestic Voice Speaker Solution
        • Domestic Voice Infrared SoC Solution
        • Overseas Voice Solution
        • Design Reference Materials - Alexa Module
        • Design Reference Materials - Domestic Voice Module
    • Firmware
      • S8E
  • FAQs
    • Device Development
      • Cloud Module
        • Wi-Fi Module
        • Zigbee Module
        • BLE Module
        • GPRS Module
        • NB-IoT Module
        • Dual-mode Module
        • Other Module Issues
      • Access Mode SoC
      • MCU Access Mode
        • Wi-Fi General Solution
        • Zigbee General Solution
        • BLE General Solution
          • BLE Single-point Solution
          • BLE Mesh General Solution
          • Other Issues of BLE Solution
        • NB-IoT General Solution
        • Other Issues of MCU Access Mode
      • Module SDK Development
        • BLE Chip SDK(single point)
        • Linux General SDK
        • NB-IoT Chip SDK
        • Wi-Fi Chip SDK
        • Others about Module SDK
      • Other Issues of Device Development
    • Smart Product Solution
      • Electrical
        • Outlet
        • Scenario Switch
        • Switch
      • Lighting
        • Wi-Fi Lighting
        • Zigbee Lighting
        • Bluetooth Lighting
        • Other Issues of Lighting
      • Lock
        • BLE Lock
        • NB-IoT Lock
        • Wi-Fi Lock
        • Zigbee Lock
        • Other Issues of Lock
      • Sensor
      • Gateway
        • BLE Gateway
        • Wireless Gateway
        • Zigbee Gateway
        • Other Issues of Gateway
      • IPC
      • Infrared Products
        • Infrared remote control
        • Infrared Capability Introduction
        • Infrared Code Library
      • Sweeper
      • Household Appliances
      • Pet Supplier
      • BLE Mesh Typical Solution
        • BLE Mesh Lighting Solution
        • BLE Mesh Electrical Solution
        • BLE Mesh Sensor Solution
        • BLE Mesh General Solution
    • Products
      • Electric
        • Smart Switch
        • Smart Plug
        • Curtain Controller
      • Lighting
      • Security
        • E202/203 Smart Lock
    • More
  • Links
    • ifreeq.cn
    • ifreeq.com
    • AIoT Expo
    • Official Store
Powered by GitBook
On this page
  • Introduction
  • Development Process
  • Creating products
  • Hardware Debugging
  • Software Debugging
  • Functions Debugging

Was this helpful?

  1. Developer
  2. Device Development
  3. Access Mode MCU
  4. BLE General Solution

BLE Module MCU Development Overview

PreviousBLE General SolutionNextBLE Hardware Design

Last updated 4 years ago

Was this helpful?

Introduction

Tuya is providing developers with MCU SDK that can be quickly programmed .This is a development kit generated automatically from the product’s function datapoint according to Tuya Serial Port Communication Protocol. MCU engineer can develop this procedure conveniently on this basis. This article will introduce you to the specific steps of MCU development.

Schematic of gatewayless BLE single-point communication

Schematic of BLE single-point with gateway communication

Development Process

The development process mainly includes: Creating products - Hardware Debugging- Software Debugging - Function Debugging.

Creating products

Tuya BLE Standard Module includes both Non-low power and Low power mode. User can choose whether to enable the low-power function through protocol instructions.

  • Non-low power mode is for products with long power supply and insensitive to power consumption.

  • Low power mode is for battery-powered products with higher power consumption requirements.

After the product is created, users can select functions, panels, modules and firmware according to the actual needs of the product, and download the corresponding MCU development kit.

Hardware Debugging

When selecting module on the platform, the platform will recommend some common module models. After selecting the module and firmware, you can purchase module samples online.

The hardware engineer can enter the drawing board stage, and the related materials for hardware development can be viewed in the developer center:

Note: When the battery is used as the power supply, when the power supply voltage is lower than the normal working voltage, the internal flash operation of the module will risk the error, causing the firmware or user data to be modified abnormally.

You can choose 2 way to rescue it: 1.When the MCU detects that the battery voltage is too low, cut off the module's power.

2.When the MCU detects that the battery voltage is too low, turn off the broadcast and system timing, put module in deep sleep mode. The minimum working voltage of Telink module is 1.8V, MCU can be set at 2.0V (slightly higher than 1.8V).

Network verification

After getting the module, you don't need to write code first, first determine whether the module is working properly. Using the module debugging assistant (MCU simulation mode) provided by Tuya to cooperate with the module can perform network config operation, verify the module and be familiar with the protocol interaction process at the same time, and the development and debugging efficiency will be greatly improved later.

The framework of Tuya BLE Standard Serial Communication Protocol is shown below:

Low-power Mode Control Pin: At present, It's necessary required in Scheme of Standard Door Lock (TYBN1,BK3431Q), and it needs to be connected and used by MCU. For other standard scheme, to use the low-power mode, you must also connect the module's Low-power Control Part. If you don't need this mode, it's enough to just finish the basic connection part.

Status of Connection Notification Pin: In Low-power Mode, the GPIO will output high level when BLE connection with Mobile is successful. And when it's disconnected, the Pin will output low level.

Note: Some module does not supply this function. For details, please refer to the Low-power Mode section of the protocol document (optional, different models have different screen printing, see the datasheet for details.

Tuya MCU simulation debugging assistant, the assistant can simulate MCU data transmission and reception. Set up the minimum system of the module and connect the serial port to the computer.The assistant has the following functions: 1. Pair with a networked module and verify that the module is working properly. 2. Before the MCU completes development, debug the App panel display. 3. When the MCU developer does not know how to send and reply data to the module, the data of the simulation assistant can be used as a reference.

Module Debugging Assistant (MCU simulation mode)

step1. According to the minimum system schematic diagram, build the module peripheral circuit, simple test can fly wire directly.

step2. Open the Tuya module debugging assistant in the development kit and import the debugging file. Protocol selection BLE single point general protocol, MCU simulation mode.

step3. Connect the module serial port to the computer through the USB to TTL tool. The assistant selects the corresponding serial port and baud rate. Open the serial port and click Start. You will see that the module and the host computer automatically perform the initialization process protocol interaction.

Note: After the Bluetooth module is powered on, it will continuously send heartbeat packets. After receiving the correct response, it will perform subsequent initialization protocol interactions. If no data is sent after power on, please check if the peripheral circuit of the module is correct.

step4. Click Reset Module, the module will disconnect the BLE connection of the module, release the BLE binding relationship, clear the module's cache information, and restart the module.

Software Debugging

During hardware debugging, you can see that the module and the MCU have a series of serial protocol interaction data. For the data analysis part, users can refer to the protocol document in the development kit. The agreement is mainly divided into two parts: the basic protocol and the functional protocol.

The basic protocol has nothing to do with the product. It is a common protocol of the module, including module initialization instructions and some extended function instructions.

There are two ways for the MCU to connect with the Tuya module protocol: transplant the MCU SDK or connect the protocol by yourself.

  • Connect protocol by yourself:

    When the MCU resources are limited or the MCU SDK is not suitable for porting, customers can choose to connect the serial port protocol by themselves.

  • Transplant MCU SDK:

    If the MCU resources are sufficient, it is generally recommended that users directly port the MCU SDK for efficient and convenient development. The MCU SDK in the development kit is a C-based protocol application code provided by Tuya, which can be directly added to the MCU project.

    The MCU SDK requires MCU hardware resources: Flash 4K bytes; RAM is related to the length of the DataPoint, about 100 bytes (if OTA function is required, it must be bigger than 260 bytes); the number of function nesting levels is 9 levels. If users with insufficient resources can connect the protocol by themselves, the functions in the SDK package can still be used as a reference.

Functions Debugging

After porting the MCU SDK code development, you can use the Tuya module debugging assistant - module simulation mode to verify the correctness of the MCU code. The usage method is similar to the MCU simulation mode. In the simulation module mode, the assistant will automatically send the initialization data stream to verify that the MCU response is correct and give corresponding prompts for the incorrect data. After the initial interaction is passed, you can manually click to test other extended functions.

Note: module simulation mode do not supply network functions, only used to verify the correctness of the MCU serial protocol transmission and reception. After the test is completed, the MCU can be connected to the actual module and test the network.

Module Debugging Assistant (Module simulation mode)

Other Debugging Common Tools Links:

Login to create products. Please note that the communication type is "BLE".

Creating a product is described in detail in the , so we won't go into details here.

Data manual link: ;

Hardware design guidance: (not available now);

PCB data: .

For more information, please refer to the

The functional protocol part is mainly based on the reporting and issuing command words of the basic protocol, and details the format of the Datapoint content. The full content of the basic protocol, the document center is kept updated in real time, you can click the link to view: (not available now).

For details can see: .

:Tuya Smart Developer Platform - Operation. You can check device background log here according to your product id.

:Tuya provide online technical support, you can ask any questions like the question about documents here.

(not available now):FAQ, you can read it before developing to avoid some problem.

Tuya Smart Developer Platform
MCU Access Guide
BLE module datasheet
BLE module hardware design
Common module package library
Module Debugging Assistant Instruction
Tuya Cloud BLE Universal Serial Port Access Protocol
Overview of migrating Tuya's MCU SDK
Operations Center Guide
Tutorial for Tuya Support Center
FAQ