diff --git a/cores/esp32/esp32-hal-misc.c b/cores/esp32/esp32-hal-misc.c
index 5e6ea13df9e..704a273276f 100644
--- a/cores/esp32/esp32-hal-misc.c
+++ b/cores/esp32/esp32-hal-misc.c
@@ -21,7 +21,9 @@
 #include "esp_partition.h"
 #include "esp_log.h"
 #include "esp_timer.h"
+#ifdef CONFIG_BT_ENABLED
 #include "esp_bt.h"
+#endif //CONFIG_BT_ENABLED
 #include <sys/time.h>
 #include "esp32-hal.h"