With the rise of intelligent hardware and the rapid development of the Internet of Things, its security issues are also facing severe challenges. Internet of things devices are often limited devices with limited computing power and limited resource space. Therefore, a lightweight security solution needs to be designed specifically for this purpose. The purpose of this article is to study the method of IoT device access and network communication based on MQTT (Message Queuing Telemetry Transport). Based on the MQTT protocol and the theoretical foundation of Wi-Fi technology, this paper proposes a Wi-Fi distribution network optimization scheme and terminal communication method, and sets up a system test platform. The experiment proves that the communication method of the IoT terminal equipment based on MQTT proposed in this paper can reliably and flexibly implement the communication function of the equipment and meet the communication needs of the IoT system. According to the performance of the Wi-Fi access configuration method, this paper tests the performance of transmitting information with lengths of 10 bytes, 30 bytes, 50 bytes, and 70 bytes, respectively, the average time of the distribution network is 0.6692s, 1.3546s, 2.8600s, 4.7319s, all rates are 100 percent. It can be seen that the system has a higher efficiency in network distribution.