2555 views|1 replies

98

Posts

0

Resources
The OP
 

IoT Smart Lights [Copy link]

This post was last edited by Ansersion on 2019-6-22 11:42

IoT Smart Lights

1. Introduction:

Physical network smart lights can synchronize data to users' mobile terminals in real time through the Internet, and users can also remotely control smart lights through mobile terminals.

2. System Description:

Smart lights are mainly composed of 3 parts:

  1. GD32E231 acts as the master controller, thus controlling peripherals;
  2. ESP8266, as a Wifi communication module, is responsible for transparently transmitting data between the main control and the BcServer server, and interacting with GD32E231 through the serial port;
  3. The LED light, which is a peripheral, is controlled by GD32E231 using GPIO .

Smart lights and Android apps use the Beecom protocol ( BC protocol for short) to transmit data to each other through the BcServer server.

3. GD32E231 control logic description:

GD32E231 uses a state machine to implement five states, as described below:

  1. CONNECT

Use the CONNECT command of the BC protocol to initiate a connection to the BcServer server. If successful, it means that the BcServer server has been connected, and then enters the "REPORT verification code" state; otherwise, wait for a while and continue to initiate the CONNECT command.

  1. REPORT check code

Use the REPORT command of the BC protocol to send the signal table check code to the BcServer server. If successful, it means that the BcServer server has saved the signal table of the device and then enters the "REPORT all signal values" state; otherwise, it enters the "REPORT signal table" state.

  1. REPORT signal table

Use the REPORT command of the BC protocol to send the device signal table to the BcServer server. If successful, it means that the BcServer server has received and saved the device signal table, and then enters the "REPORT all signal values" state; otherwise, it returns to the "CONNECT state".

  1. REPORT all signal values

Use the REPORT command of the BC protocol to send all signal values (i.e. LED status, etc.) to the BcServer server. If successful, it means that the BcServer server has received and synchronized the device signal value, and then enters the "working cycle" state; otherwise, it returns to the "CONNECT state".

  1. Working cycle

In the "working cycle" state, GD32E231 remains idle unless it receives the following events:

  1. Key triggers external interrupt event:

After the event is triggered, GD32E231 uploads the latest LED signal value to the BcServer server.

  1. Receive network data event (i.e. serial port interrupt)

After this event is triggered, GD32E231 will parse the network data and update local parameters or perform related operations accordingly, and clear the command sending timeout.

  1. Command sending timeout event

After this event is triggered, it means that there is no response to the network data packet sent by GD32E231, and it returns to the "CONNECT state".

  1. Keep-alive timeout event

After this event is triggered, GD32E231 must send a BC protocol PING command to the BcServer server to maintain the link between the smart light and the BcServer server.

4. Demonstration video (recommended to switch to "HD" to watch):


5. Source code and documentation:

基于GD32E231的物联网智能灯.docx (1.47 MB, downloads: 13)



bc_light_keil_eeworld_gd32e231.zip (1.19 MB, downloads: 13)

This post is from GD32 MCU

Latest reply

Thanks for sharing   Details Published on 2021-4-19 21:40
 

661

Posts

0

Resources
2
 

Thanks for sharing

This post is from GD32 MCU
 
 
 

Guess Your Favourite
Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list