Prototype a Temperature and Humidity Sensor with Zigbee Module SDK

Doria
5 min readSep 29, 2021

--

Overview

The temperature and humidity sensor is widely used in the smart home. The data of temperature and humidity collected by the sensor can be the trigger for executing home automation.

For example, when the indoor temperature exceeds a preset value, such as 29°C, the air conditioner will be automatically turned on to cool down the room. When the temperature drops below a preset value, such as 23°C, the air conditioner will be automatically turned off. When the indoor temperature drops below a lower preset value, such as 12°C, the air conditioner will be automatically turned on to heat the room. Air conditioner automation can keep a preferred indoor temperature and help to conserve energy and cut down utility bills. Importantly, users can enjoy superior comfort all the way.

Based on the Tuya IoT Platform, you can quickly and easily prototype a smart temperature and humidity sensor from scratch. This demo describes how to quickly prototype a smart temperature and humidity sensor with the demo code and Tuya Sandwich development board.

Steps

  • Step 1: Create product and download SDK
  1. Log in to the Tuya IoT Platform.
  2. See Create Products to create a Zigbee temperature and humidity sensor with a custom solution.

3. Select functions for the temperature and humidity sensor. In this demo, the selected functions are shown in the following figure.

4. Select a device panel. For more information, see Design App UI.

5. In the step of Hardware Development, select the Self-developed Module SDK, and complete the relevant information.

6. In the Download Documents area, you can download the SDK.

  • Step 2: Compile code
  • After you extract the SDK, you can find the demo and documentation in the apps folder.
  • You can refer to the tuya_simple_tmp_hum_sensor demo for the EFR32MG13P732F512 chip in the sensor directory and modify the code to implement sensing functionality.
  1. Modify firmwareInfo in the package.json file, including pid, model_id, and manufacture_name. The specific description is as follows:
  • pid is generated when you create a product in Step 1.
  • The values for model_id and manufacture_name can be found in the Zigbee Protocol Specification.
  • In this demo, fill TS0201 in model_id field and TZ3000 in manufacture_name field.
  • The following figure shows the modified firmwareInfo in the package.json file.

2. Modify ioConfig in the package.json file according to circuit parameters. The following figure shows the modified values.

3. When you have finished modifying package.json, you can compile the IAR project. The system will automatically apply the modified values to the application code and generate the firmware for production and updates in the exe folder under the build folder.

  • Step 3: Program and authorize
  • Test stage
  • With the Simplicity Commander provided by Silicon Labs, you can program the production firmware generated in Step 2 to the development board for testing. The authorization is only valid for seven days. The following section describes how to have the firmware authorized permanently.
  • Production stage
  • Go to Tuya Service & Support and submit a technical ticket for assistance. Tuya’s technical staff will help you upload the firmware and apply for an authorization code for programming and authorizing.
  • Step 4: Pair sensor
  • Zigbee devices are connected to the network through a Zigbee gateway.
  1. Connect the Zigbee gateway to the cloud with the Tuya Smart app.
  2. Enable the device to be pending for pairing according to the pairing setting specified in the code. In this demo, you can press and hold the button on the Zigbee SoC master control board (ZS3L) until the indicator flickers fast.
  3. Open the Tuya Smart app, select the added gateway, and tap Add subdevice.

4. Follow the prompts to operate. When the device is connected to the cloud, you can control the sensor with the Tuya Smart app.

  • Step 5: (Optional) Voice assistant integration
  • You can integrate popular voice assistants into your products. Go to Tuya Value Added Service and click Smart Voice to find more.

Summary

You have prototyped a smart temperature and humidity sensor successfully. Based on the Tuya IoT Platform, you can quickly and easily build a smart prototype from scratch with Tuya Sandwich Evaluation Kit.

--

--