English
English
简体中文
Contact Us
Register
Log In
layoutIndex
IoT App SDKConceptsDevice Pairing

Device Pairing

Last Updated on : 2021-09-03 01:49:38download

A pairing task is intended to connect and register an IoT device to the cloud and allow it to communicate with the cloud. The matching mobile app or project management background can thus control the IoT device and create business value with specific smart scenes. This topic describes the helpful knowledge about pairing and the types of pairing modes supported by Tuya.

The device pairing capabilities mentioned in this topic apply to the development of Tuya IoT mobile apps. Whether your App SDK provided by a third party supports a certain pairing mode only depends on that App SDK.

Scenarios

To interconnect with a smart device over a protocol, such as Wi-Fi, Bluetooth, or Zigbee, a user must connect the device to a network or a networked mobile phone and add it to the user’s app account. This way, the device can report data to the cloud and receive commands from the cloud.

  • For devices with display screens, such as mobile phones, tablets, and touchscreen control panels, users can enter networking information on the screens.
  • For devices without display screens, such as sockets, lights, sensors, and motors, users cannot connect the devices to a network by entering networking information. Thus, pairing is required to achieve interconnection with the devices.

Protocols

IoT protocols and standards are classified into:

  • Network protocols: Wi-Fi, Zigbee, Bluetooth, Long Range (LoRa), Narrowband Internet of Things (NB-IoT), cellular networks (such as 5G), Global System for Mobile Communications (GSM), General Packet Radio Service (GPRS), Modbus, serial port types (such as RS433, RS485, USB), and more.
  • IoT data protocols: HTTP/HTTPS, Constrained Application Protocol (CoAP), Message Queuing Telemetry Transport (MQTT), Extensible Messaging and Presence Protocol (XMPP), Advanced Message Queuing Protocol (AMQP), and Java Message Service (JMS), and more.

Wireless standards

In terms of wireless standards, wireless networking technologies are classified into three categories:

  • To connect devices to a router over Wi-Fi, users must provide Wi-Fi information, including the service set identifier (SSID) and password.
  • Protocols such as Bluetooth and Zigbee require networking through a gateway. The devices to be networked must be paired with the gateway that supports the same protocol.
  • Cellular networks (such as 5G) allow the devices with a SIM card to be independently networked.

Common pairing modes

  • Wi-Fi device pairing: To pair a Wi-Fi device, the Wi-Fi SSID and password of a router are transmitted to the device in a certain way. Then, the device can access the Wi-Fi network.
  • NB-IoT and GPRS device pairing: This type of device has a built-in SIM card that enables access to the internet. The device to be paired must be definitely bound with a user’s app account.
  • Wired device pairing: Wired gateways or cameras are paired in this mode.
  • Gateway sub-device pairing: Gateway sub-devices are connected to a gateway that enables interconnection between its sub-devices and a network. This mode applies when sub-devices cannot independently connect to a network or topological management is required. For example, Wi-Fi, Bluetooth, or Zigbee gateways support this pairing mode. Zigbee or Wi-Fi sub-devices are paired through their gateways.
  • Password-free pairing: This mode applies to common Wi-Fi devices. Users can pair the devices in access point (AP) mode (also known as the hotspot mode) and Wi-Fi Easy Connect (EZ) mode.
  • Bluetooth mesh pairing: Bluetooth mesh gateways and sub-devices are paired in this mode. Bluetooth mesh can transform a Bluetooth topology from a typical point-to-point, star-based network style to a mesh networking style:
    • Each Bluetooth mesh device serves as a child node, and multiple mesh devices form a mesh network, in which the child nodes communicate with each other by advertising.
    • A mobile phone can connect to one of the child nodes to access the entire mesh network. The device that is connected to the mobile phone can send the received advertising data to the mobile phone.

Typical pairing processes

In the following examples, a Wi-Fi device and a Zigbee device are used to describe how the app, device, and cloud interconnect with each other during the pairing processes.

Wi-Fi device pairing

Three pairing modes are included: Wi-Fi EZ, AP, and QR code.

  • AP or hotspot mode: a connection capability for pairing over Wi-Fi. After the mobile phone is connected to the Wi-Fi hotspot of the device to be paired, the app is paired and communicates with the mobile phone over Wi-Fi. This pairing mode features a high success rate and excellent reliability, and supports routers that can process data using both 2.4 GHz and 5 GHz frequencies. Users must manually change the Wi-Fi band on their mobile phones to enable pairing.
  • Wi-Fi EZ or SmartConfig mode: After a user connects a mobile phone to a router, the router broadcasting is used to communicate and pair the mobile phone with the device. It is easy-to-use, but has compatibility requirements for mobile phones and routers. The success rate is lower than that of hotspot pairing.
  • The Wi-Fi EZ mode and QR code mode are implemented in a similar process. The difference is that the Wi-Fi SSID, password, and token are transmitted over a QR code.

    QR code pairing only applies to IP cameras (IPCs).

In the following example, the AP mode is used to describe the Wi-Fi device pairing process:

  1. The user selects the 2.4 GHz Wi-Fi network and enters the password.
  2. The app gets the pairing token from the cloud.
  3. The app uses a socket to broadcast UDP packets, including the SSID, password, and token.
  4. Listen for changes in network status and change the connected network. The device will disable its hotspot after receiving the UDP packets.
  5. The app polls for the newly added device with the token and registers the device in the cloud.
  6. The app gets a list of devices. If the paired device gets online, the app shows that the device is paired.

The following diagram shows the pairing process.

Device Pairing

Zigbee sub-device pairing

A Zigbee sub-device is paired in the following steps:

  1. The user selects a paired Zigbee gateway.
  2. The app sends a pairing request to the gateway. If the gateway is online in the cloud, it uses MQTT to transmit messages. If it is online on a local area network (LAN), it uses TCP for transmission.
  3. The app receives the MQTT message that indicates the paired sub-device.

The following diagram shows the pairing process.

Device Pairing

References

Service iOS Android
Industry App SDK Device Pairing Device Pairing
Smart Life App SDK Device Pairing Device Pairing
Commercial Lighting App SDK Device Pairing Device Pairing