diff --git a/esphome/components/modem/helpers.h b/esphome/components/modem/helpers.h
index 66e3861cc3..9cacd90f0e 100644
--- a/esphome/components/modem/helpers.h
+++ b/esphome/components/modem/helpers.h
@@ -9,13 +9,6 @@
 #include <esp_idf_version.h>
 #include <esp_task_wdt.h>
 
-#define ESPHL_ERROR_CHECK(err, message) \
-  if ((err) != ESP_OK) { \
-    ESP_LOGE(TAG, message ": (%d) %s", err, esp_err_to_name(err)); \
-    this->mark_failed(); \
-    return; \
-  }
-
 namespace esphome {
 namespace modem {
 
@@ -48,4 +41,4 @@ class Watchdog {
 
 }  // namespace modem
 }  // namespace esphome
-#endif  // USE_ESP_IDF
\ No newline at end of file
+#endif  // USE_ESP_IDF
diff --git a/esphome/components/modem/modem_component.cpp b/esphome/components/modem/modem_component.cpp
index 203e61896f..ec37879f63 100644
--- a/esphome/components/modem/modem_component.cpp
+++ b/esphome/components/modem/modem_component.cpp
@@ -20,6 +20,13 @@
 #include <cstring>
 #include <iostream>
 
+#define ESPHL_ERROR_CHECK(err, message) \
+  if ((err) != ESP_OK) { \
+    ESP_LOGE(TAG, message ": (%d) %s", err, esp_err_to_name(err)); \
+    this->mark_failed(); \
+    return; \
+  }
+
 static const size_t CONFIG_MODEM_UART_RX_BUFFER_SIZE = 2048;
 static const size_t CONFIG_MODEM_UART_TX_BUFFER_SIZE = 1024;
 static const uint8_t CONFIG_MODEM_UART_EVENT_QUEUE_SIZE = 30;