In this paper, we propose an improved clustering algorithm for wireless sensor networks (WSNs) that aims to increase network lifetime and efficiency. We introduce an enhanced fuzzy spider monkey optimization technique and a hidden Markov model-based clustering algorithm for selecting cluster heads. Our approach considers factors such as network cluster head energy, cluster head density, and cluster head position. We also enhance the energy-efficient routing strategy for connecting cluster heads to the base station. Additionally, we introduce a polling control method to improve network performance while maintaining energy efficiency during steady transmission periods. Simulation results demonstrate a 1.2% improvement in network performance using our proposed model.