This Demo is based on Tuya Smart Cloud Platform, Tuya Smart APP, IoTOS Embeded WiFi &Ble SDK, using Tuya WiFi/WiFi+BLE series modules to quickly set up an automatic light replenishment controller to achieve remote monitoring of light intensity data by cell phone and automatically control light intensity to replenish to the set value.
-
Download Tuya IoTOS Embeded WiFi & BLE sdk
-
Download the demo to the apps directory of the SDK
$ cd apps $ git clone https://github.com/Tuya-Community/tuya-iotos-embeded-demo-wifi-ble-supplementary-illumination
-
Execute the following command in the SDK root directory to start compiling.
sh build_app.sh apps/tuya-iotos-embeded-demo-wifi-ble-supplementary-illumination tuya-iotos-embeded-demo-wifi-ble-supplementary-illumination 1.0.0
-
Firmware burn-in license information please refer to: Wi-Fi + BLE series module burn-in license
├── src
| ├── app_driver
| | ├── bh1750.c
| | └── plant_pwm.c
| ├── app_soc
| ├── tuya_device.c
| ├── app_sensor.c
| └── sensor_control.c
|
├── include
| ├── app_driver
| | ├── bh1750.h
| | └── plant_pwm.h
| ├── app_soc
| ├── tuya_device.h
| ├── app_sensor.h
| └── sensor_control.h
|
└── output
Entry file: tuya_device.c
Important functions: device_init()
- Call tuya_iot_wf_soc_dev_init_param() interface to initialize the SDK, configure the operating mode, the mating mode, and register various callback functions and store the firmware key and PID.
- Calling the tuya_iot_reg_get_wf_nw_stat_cb() interface to register the device network status callback functions.
- Call the application layer initialization function app_plant_init()
- Send down dp point data stream: dev_obj_dp_cb() -> deal_dp_proc()
- Report dp point interface: dev_report_dp_json_async()
function name | OPERATE_RET dev_report_dp_json_async(IN CONST CHAR_T *dev_id,IN CONST TY_OBJ_DP_S *dp_data,IN CONST UINT_T cnt) |
---|---|
devid | device id (if it is a gateway, MCU, SOC class device then devid = NULL; if it is a sub-device, then devid = sub-device_id) |
dp_data | dp structure array name |
cnt | number of elements of the dp structure array |
return | OPRT_OK: Success Other: Failure |
BH1750 | Supplementary light board | |
---|---|---|
SDA P6 |
PON P8 |
|
SCL P7 |
RON P9 |
Tuya Demo Center: https://developer.tuya.com/demo/
You can get support for Tuya by using the following methods:
- Developer Center: https://developer.tuya.com
- Help Center: https://support.tuya.com/help
- Technical Support Work Order Center: https://service.console.tuya.com