| With the continuous development of the national economy,traditional lighting systems with manual switch mode can no longer meet the energy-saving needs of lighting and are gradually being replaced by intelligent lighting systems.Compared with traditional lighting systems,intelligent lighting systems have advantages such as simple operation and more energy-saving.With the rapid development of artificial intelligence,intelligent lighting is moving towards a more high-end direction of intelligence,which puts forward higher requirements for current intelligent lighting,especially in terms of intelligent algorithms and control.The K-means algorithm,as a type of machine learning algorithm,has relatively low time complexity.After solving the stability and adaptability problems of its algorithm,it is a good choice for application in intelligent lighting systems.Therefore,this paper proposes an intelligent lighting system based on Wi Fi(Wireless Fidelity)communication protocol,MQTT(Message Queuing Telemetry Transport)communication protocol,and improved K-means clustering algorithm.By improving the traditional K-means algorithm,it can be more suitable for intelligent lighting systems and achieve higher levels of intelligent lighting.The improved K-means clustering algorithm can predict users’ future lighting habits based on their past lighting habits data and enable intelligent lighting systems to adapt to users’ lighting behavior.On this basis,with the help of the Internet,ESP8266 module,and MQTT server,the Android mobile app is connected to LED lights to automatically control the switch status of LED lights.The main work of this paper is as follows:(1)Based on the analysis of the problems and requirements of intelligent lighting systems,this article designs and implements an overall plan for an intelligent lighting system.This article designs the front-end,back-end,database,algorithm,and hardware of the system to achieve various functions such as user login and exit,home light group binding,remote control of lighting,automatic subscription/publication of theme messages,and prediction of user light on time.(2)This article is based on the ESP8266 IoT development chip,and designs and manufactures a hardware circuit for an intelligent lighting system.In the overall circuit design of the system,this article fully considers the application based on Wi Fi and MQTT communication protocols and the energy consumption of the chip,completing the implementation of network communication and hardware control light group logic.Implement various functions such as connecting to the network,connecting to MQTT servers,publishing/subscribing to topic messages,binding light groups,and LED control.(3)In response to the applicability and instability of the K-means clustering algorithm,this article optimizes and improves the K-means clustering algorithm,and writes and analyzes the algorithm in the Py Charm development environment.Finally,the algorithm is implemented in Java language and embedded in the backend project.The system uses the MQTT communication protocol to transmit control signals and collect user behavior habits data,selecting the user’s daily light usage time and light usage duration as two characteristic values.In order to adapt the algorithm to different user data and reduce algorithm time complexity,a method is proposed to determine the upper and lower bounds of the search range for the number of clusters in the K-means clustering algorithm.In order to solve the unstable clustering effect of K-means algorithm,a method based on user behavior habit data to set initial center points is proposed.Finally,by analyzing and comparing various effectiveness indicators,the appropriate effectiveness indicators for this system are selected to determine the optimal number of clusters.The experiment utilizes the ESP8266 module,MQTT server,and mobile testing interface to test the control and data collection of the light.By using Py Charm software,the traditional K-means algorithm and the improved K-means algorithm are compared in terms of determining the search range of clustering numbers,effectiveness indicators,and clustering effectiveness on user behavior habits data.The simulation results show that compared with the traditional K-means algorithm,the improved K-means algorithm has more accurate classification results,better stability,and faster computational speed.Finally,the intelligent lighting system design of this article was validated through experiments.The use of Wi Fi and MQTT communication protocols can control and monitor the status of lights,and the database can obtain and store user light data.The improved K-means algorithm in this article can achieve automatic control of LED lights.Finally,by connecting a relay,control of household 220 V voltage LED lights was achieved. |