The integration of smart contracts (SCs) within blockchain technology represents a pivotal direction in the evolution of the Internet of Things (IoT), enabling decentralization and enhancing user trust in the system. However, ensuring data privacy is a fundamental challenge that must be addressed during the deployment of these SCs. Many scholars have adopted data aggregation to protect privacy, but these methods are difficult to achieve fine-grained data collection. To this end, this paper proposes an efficient anonymous data collection (EADC) scheme suitable for the IoT environment. The scheme combines matrix algorithms with homomorphic encryption (HE) technology to effectively cut off the connection between users and data during data upload. In addition, the EADC scheme introduces a sophisticated data grouping protocol to improve the overall efficiency of the system. Analysis shows that the scheme can achieve efficient data collection without compromising user privacy.