Hierarchical Wireless Sensor networks (WSNs) are becoming attractive to many applications due to their energy efficiency and scalability. However, if such networks are deployed in a privacy sensitive application context such as home utility consumption, protecting data privacy becomes an essential requirement. Our threat analysis in such networks has revealed that PPDA (Privacy Preserving Data Aggregation), NIDA (Node ID Anonymity) and ENCD (Early Node Compromise Detection) are three essential properties for protecting data privacy. The scope of this thesis is on protecting data privacy in hierarchical WSNs byaddressing issues in relation to two of the three properties identified, i.e., NIDA and ENCD, effectively and efficiently. The effectiveness property is achieved by considering NIDA and ENCD in an integrated manner, and the efficiency property is achieved by using an adaptive approach to security provisioning. To this end, the thesis has made the following four novel contributions.Firstly, this thesis presents a comprehensive analysis of the threats to data privacy and literature review of the countermeasures proposed to address these threats. The analysis and literature review have led to the identification of two main areas for improvements: (1) to reduce the resources consumed as the result of protecting data privacy, and (2) to address the compatibility issue between NIDA and ENCD.Secondly, a novel Adaptive Pseudonym Length Estimation (AdaptPLE) method has been proposed. The method allows the determination of a minimum acceptable length of the pseudonyms used in NIDA based on a given set of security and application related requirements and constraints. In this way, we can balance the trade-off between an ID anonymity protection level and the costs (i.e., transmission and energy) incurred in achieving the protection level. To demonstrate its effectiveness, we have evaluated the method by applying it to two existing NIDA schemes, the Efficient Anonymous Communication (EAC) scheme and theCryptographic Anonymous Scheme (CAS).Thirdly, a novel Adaptive Early Node Compromise Detection (AdaptENCD) scheme for cluster-based WSNs has been proposed. This scheme allows early detections of compromised nodes more effectively and efficiently than existing proposals. This is achieved by adjusting, at run-time, the transmission rate of heartbeat messages, used to detect nodes' aliveness, in response to the average message loss ratio in a cluster. This adaptive approach allows us to significantly reduce detection errors while keeping the number of transmitted heartbeat messages as low as possible, thus reducing transmission costs.Fourthly, a novel Node ID Anonymity Preserving Scheme (ID-APS) for clusterbased WSNs has been proposed. ID-APS protects nodes ID anonymity while, at the same time, also allowing the global identification of nodes. This later property supports the identification and removal of compromised nodes in the network, which is a significant improvement over the state-of-the-art solution, the CAS scheme. ID-APS supports both NIDA and ENCD by making a hybrid use of dynamic and global identification pseudonyms. More importantly, ID-APS achieves these properties with less overhead costs than CAS. All proposed solutions have been analysed and evaluated comprehensively to prove their effectiveness and efficiency.