Secure data transmission and data aggregation are critical in designing cluster-based sensor networks. This paper presents an Energy-efficient and Secure Pattern-based Data Aggregation protocol (ESPDA) for wireless sensor networks. ESPDA is energy and bandwidth efficient because cluster-heads prevent the transmission of redundant data from sensor nodes. ESPDA is also secure because it does not require the encrypted data to be decrypted by cluster-heads to perform data aggregation. In ESPDA, cluster-head first requests sensor nodes to send the corresponding pattern code for the sensed data. If multiple sensor nodes send the same pattern code to the cluster-head, then only one of them is permitted to send the data to the cluster-head. Hence, ESPDA has advantages over the conventional data aggregation techniques with respect to energy, bandwidth efficiency and security. Simulations results show that as data redundancy increases, the amount of data transmitted from sensor nodes to cluster-head decreases up to 45% when compared to conventional algorithms.