Lemontree

Tuya Smart_Arduino development board

 
Overview

Video link of station B’s colorful lights: https://www.bilibili.com/video/BV1HB4y1T75X/

 

Thanks to Tuya Smart for the event.

The world is big, let’s doodle together.

 

1.  Use Tuya serial port debugging assistant to simulate MCU docking with Tuya CBU module to implement network distribution.

Use USB_TTL to connect to the CBU module, baud rate: 9600

(Result: The test distribution network is normal)

k5v3w2Md80UUVTa8OzIEWn32NU5cPtWlUJvxHHCF.png

Figure 1 : Tuya serial port assistant

 

2.  Arduino programming boot program (that is, programming the program downloaded from the serial port)

Reference tutorial: https://blog.csdn.net/y511374875/article/details/79086301

 

3.  How to realize communication between Arduino soft serial port and Tuya CBU module

Change part:

SoftwareSerial mySerial(9, 10); // RX, TX

TuyaWifi my_device(&mySerial); // Use soft serial port

 

mySerial.begin(9600); // Software serial port initialization

The rest of the code is consistent with the hardware serial port

 

4.Transplant  DP points​

#define DPID_SWITCH_LED 20 // Switch ( can be issued and reported )

#define DPID_WORK_MODE 21 // Mode ( can be issued and reported )

#define DPID_MUSIC_DATA 27 // Music light ( only distributed )

#define DPID_DREAMLIGHT_SCENE_MODE 51 // Colorful scene ( can be distributed and reported )

#define DPID_LIGHTPIXEL_NUMBER_SET 53 // Point / length setting ( can be issued and reported )

 

unsigned char dp_array[][2] =

{

  {DPID_SWITCH_LED, DP_TYPE_BOOL},

  {DPID_WORK_MODE, DP_TYPE_ENUM},

  {DPID_MUSIC_DATA, DP_TYPE_STRING},

  {DPID_DREAMLIGHT_SCENE_MODE, DP_TYPE_RAW},

  {DPID_LIGHTPIXEL_NUMBER_SET, DP_TYPE_VALUE},

};

 

Change: my_device.set_dp_cmd_total(dp_array, 5); //incoming all DPs and their types array, DP numbers

 

5.  Use the library to light up the WS2812

Library usage tutorial: http://www.taichi-maker.com/homepage/reference-index/arduino-library-index/fastled-library/#intro

 

参考设计图片
×
 
 
Search Datasheet?

Supported by EEWorld Datasheet

Forum More
Update:2025-05-08 18:14:33

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
community

Robot
development
community

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号