Recent advances in technology have led to the rapid development of the Internet of Things (IoT) and the use of smartphones. The phenomenon has been widely influenced by the use of smart sensors, the accuracy of which is critical to the quality of service provided. Hence, it is vital that sensors are calibrated at both the device and software levels. Some applications even rely on environment-dependent sensing results. Floor detection by barometers is one example, where the pressure of a floor actually depends on the base reference pressure. This observation motivates us to study the floor detection problem by using barometers with device-to-device (D2D) communications. In this paper, we propose the Floor Calibration Protocol (FCP), which enables a mobile device to be calibrated with other mobile devices and anchor devices by considering both temporal and spatial factors. We conducted trace-based simulations to evaluate the proposed scheme and compared its performance with that of state-of-the-art approaches to validate the efficacy of our protocol.