Along with the continuous growth and improvement of computer and communication technologies, wireless sensors are needed in more and more places to fulfil specific tasks. A lightweight data encryption mechanism is designed for the limited processing power, storage space and energy of wireless sensor networks. The mechanism improves the RC6 algorithm and adds the “symmetric layer” operation. In order to further improve the security of the ciphertext and the strength of the data encryption, the AES-128 encryption algorithm is used in the data link layer, the network layer, and the application layer, respectively. The experiment is based on the STM32L series of ultra-low-power ARM processors, and the operating frequency of the STM32L controller is tuned to 64 MHz to obtain faster efficiency; three groups of experiments on the encryption mechanism are carried out by using the original RC6 algorithm and the improved algorithm, and the lengths of the keys used in the experiments are 16 bytes, 24 bytes, and 32 bytes, respectively, and the data-receiving and transmitting functions are tested separately. This avoids the delay of transceiver mode switching when using a single module for communication, and improves the quality and stability of multi-machine bidirectional communication.