GithubHelp home page GithubHelp logo

ccccmagicboy2021 / tuya-iotos-embeded-demo-wifi-ble-smart-fan-wbru Goto Github PK

View Code? Open in Web Editor NEW

This project forked from tuya/tuya-iotos-embeded-demo-wifi-ble-smart-fan-wbru

0.0 0.0 0.0 36 KB

The Wi-Fi and Bluetooth solution for smart fan devices with Tuya WBRU network modules.

License: MIT License

Shell 3.57% C 96.43%

tuya-iotos-embeded-demo-wifi-ble-smart-fan-wbru's Introduction

Tuya IoTOS Embedded Wi-Fi & Bluetooth LE Smart Fan (WBRU)

English | 中文


Introduction

In this demo, we will show you how to retrofit an ordinary fan and make it IoT-enabled. Based on the Tuya IoT Platform, we use Tuya's Wi-Fi and Bluetooth LE combo module, SDK, and the Tuya Smart app to connect the fan to the cloud.


Get started

Compile and flash

  • Create a product on the Tuya IoT Platform and download the SDK in the third step of Hardware Development.

  • Clone this demo to the demos folder in the downloaded SDK.

    $ cd demos
    $ git clone https://github.com/Tuya-Community/tuya-iotos-embeded-demo-wifi-ble-smart-fan-wbru.git

    Note that the build.sh file is only used for SDK earlier than v2.0.3.

  • Run the following command in the SDK root directory to start compiling.

    sh build_app.sh demos/tuya_demo_bldc_fan tuya_demo_bldc_fan 1.0.0
  • For more information about flashing and authorization, see Flash Firmware to and Authorize WBR Modules.


File introduction

├── src         /* Source code files */
|    ├── common
|    |    └── tuya_tools.c        /* Common tools */
|    ├── driver
|    |    └── tuya_rotary.c       /* Rotary encoder driver */
|    ├── soc
|    |    ├── soc_flash.c         /* SoC flash */
|    |    └── soc_timer.c         /* SoC timer */
|    ├── tuya_device.c            /* Entry file of application layer */
|    ├── tuya_fan_app.c           /* Fan application */
|    ├── tuya_fan_dp_process.c    /* DP data processing */
|    ├── tuya_fan_flash.c         /* Read/write flash memory */
|    ├── tuya_fan_key.c           /* Key press detection */
|    ├── tuya_fan_led.c           /* LED indicator control */
|    ├── tuya_fan_motor.c         /* Motor control */
|    ├── tuya_fan_rotary.c        /* Rotary encoder application */
|    └── tuya_fan_timer.c         /* Timer control */
|
└── include     /* Header files */
     ├── common
     |    └── tuya_tools.h        /* Common tools */
     ├── driver
     |    └── tuya_rotary.h       /* Rotary encoder driver */
     ├── soc
     |    ├── soc_flash.h         /* SoC flash */
     |    └── soc_timer.h         /* SoC timer */
     ├── tuya_device.h            /* Entry file of application layer */
     ├── tuya_fan_app.h           /* Fan application */
     ├── tuya_fan_dp_process.h    /* DP data processing */
     ├── tuya_fan_flash.h         /* Read/write flash memory */
     ├── tuya_fan_key.h           /* Key detection */
     ├── tuya_fan_led.h           /* LED indicator control */
     ├── tuya_fan_motor.h         /* Motor control */
     ├── tuya_fan_rotary.h        /* Rotary encoder application */
     └── tuya_fan_timer.h         /* Timer control */

Entry to application

Entry file: /demos/src/tuya_device.c

Main function: device_init()

  • Call tuya_iot_wf_soc_dev_init_param() for SDK initialization to configure working mode and pairing mode, register callbacks, and save the firmware key and PID.
  • Call tuya_iot_reg_get_wf_nw_stat_cb() to register callback of device network status.
  • Call fan_device_init() for application initialization.

Data point (DP)

  • Report DP data: dev_report_dp_json_async()

    Function 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 For gateways and devices built with the MCU or SoC, the devid is NULL. For sub-devices, the devid is sub-device_id.
    dp_data The name of DP struct array
    cnt The number of elements in the DP struct array
    Return OPRT_OK: success. Other values: failure.

Pin configuration

Peripherals I/O Peripherals I/O Peripherals I/O Peripherals I/O
Power key PA7 Rotary encoder A PA18 Level indicator 1 PA9 Standard mode indicator TX
Timer key PA8 Rotary encoder B PA0 Level indicator 2 PA2 Natural mode indicator PA10
Device pairing key PA19 Brushless DC motor PA11 Level indicator 3 PA3 Sleep mode indicator PA20
Rotary encoder C PA17 Light adjustment of indicators PA12 Level indicator 4 PA4 Network status indicator RX

Reference


Technical support

You can get support from Tuya with the following methods:


tuya-iotos-embeded-demo-wifi-ble-smart-fan-wbru's People

Contributors

coral-hu avatar fangamy avatar zlinoliver avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.