This study investigates combining the property of human vision system and a 2-phase data hiding strategy to improve the visual quality of data-embedded compressed images. The visual Internet of Things (IoT) is indispensable in smart cities, where different sources of visual data are collected for more efficient management. With the transmission through the public network, security issue becomes critical. Moreover, for the sake of increasing transmission efficiency, image compression is widely used. In order to respond to both needs, we present a novel data hiding scheme for image compression with Absolute Moment Block Truncation Coding (AMBTC). Embedding secure data in digital images has broad security uses, e.g., image authentication, prevention of forgery attacks, and intellectual property protection. The proposed method embeds data into an AMBTC block by two phases. In the intra-block embedding phase, a hidden function is proposed, where the five AMBTC parameters are extracted and manipulated to embed the secret data. In the inter-block embedding phase, the relevance of high mean and low mean values between adjacent blocks are exploited to embed additional secret data in a reversible way. Between these two embedding phases, a halftoning scheme called direct binary search is integrated to efficiently improve the image quality without changing the fixed parameters. The modulo operator is used for data extraction. The advantages of this study contain two aspects. First, data hiding is an essential area of research for increasing the IoT security. Second, hiding in compressed images instead of original images can improve the network transmission efficiency. The experimental results demonstrate the effectiveness and superiority of the proposed method.