This article proposes a solution for the routing problem in wireless sensor networks (WSN) based on a neural mechanism. The basic concepts of wireless sensor networks, artificial neural networks (ANNs), and WSN routing protocols are presented. The Kohonen ANN was selected to solve the problem of routing in wireless sensor networks based on a neural mechanism. A radio visibility matrix is proposed, which is a mathematical description of the connectivity of network nodes and the radio visibility of each node with respect to all other network nodes. Based on the Kohonen ANN trained by the constructive method, a method for WSN neural network clustering was developed. Two software-modeling environments are presented that were created to confirm the theory with respect to the logic of the developed methods for WSN clustering, their correction and the verification of their adequacy. Numerical results of modeling the solution of the routing problem in a wireless sensor network based on a neural mechanism by neural network clustering, the WSN matrix clustering method and the energy distance neural clustering protocol (EDNCP) are presented. It was found that the developed EDNCP protocol was 29% more efficient than known analogs.