Hexagonal boron nitride (hBN) and black phosphorus (bP) are crystalline materials that can be seen as ordered stackings of two-dimensional layers, which lead to outstanding anisotropic physical properties. Knowledge of the thermal equations of state of hBN and bP is of great interest in the field of 2D materials for a better understanding of their anisotropic thermo-mechanical properties and exfoliation mechanism towards the preparation of important single-layer materials like hexagonal boron nitride nanosheets and phosphorene. Despite several theoretical and experimental studies, important uncertainties remain in the determination of the thermoelastic parameters of hBN and bP. Here, we report accurate thermal expansion and compressibility measurements along the individual crystallographic axes, using in situ high-temperature and high-pressure high-resolution synchrotron X-ray diffraction. In particular, we have quantitatively determined the subtle variations of the in-plane and volumetric thermal expansion coefficients and compressibility parameters by subjecting these materials to hydrostatic conditions and by collecting a large number of data points in small pressure and temperature increments. In addition, based on the anisotropic behavior of bP, we propose the use of this material as a sensor for the simultaneous determination of pressure and temperature in the range of 0-5 GPa and 298-1700 K, respectively.