Wireless sensor networks (WSN) have found more and more applications in remote control and monitoring systems. Energy management in the network is crucial because all nodes in the WSN are energy constrained. Therefore, the design and implementation of WSN protocols that reduce energy depletion in the network is still an open scientific problem. In this paper, we propose a new clustering protocol that combines DEC (deterministic energy-efficient clustering) protocol with K-means clustering, called DEC-KM (deterministic energy-efficient clustering protocol with K-means). DEC is a very energy-efficient clustering protocol that outperforms its predecessors, such as LEACH and SEP. K-means ensures more effective clustering and shorter data transmission distances within the network. The shorter distances improve the network's lifetime and stability and reduce power consumption. Additional heuristic rules in DEC-KM ensure improved cluster head selection, taking into account node energy level and position and minimising the risk of premature cluster head exhaustion. The simulation results for the DEC-KM protocol using MATLAB show that cluster heads have shorter distances to nodes in cluster areas than for the original DEC protocol. The proposed protocol ensures reduced energy consumption, outperforms the standard DEC, and extends the stability period and lifetime of the network.