diff --git a/esp8266/esp_mphal.c b/esp8266/esp_mphal.c
index b522e87e3bfdb6dcb139fbc79fb0a4ad7ab2f42e..6a4b2f5ec347dfe75da7bd6c7cde4fa98c9e8811 100644
--- a/esp8266/esp_mphal.c
+++ b/esp8266/esp_mphal.c
@@ -33,6 +33,7 @@
 #include "ets_alt_task.h"
 #include "py/obj.h"
 #include "py/mpstate.h"
+#include "extmod/misc.h"
 
 extern void ets_wdt_disable(void);
 extern void wdt_feed(void);
@@ -68,24 +69,29 @@ int mp_hal_stdin_rx_chr(void) {
     }
 }
 
+void mp_hal_stdout_tx_char(char c) {
+    uart_tx_one_char(UART0, c);
+    mp_uos_dupterm_tx_strn(&c, 1);
+}
+
 void mp_hal_stdout_tx_str(const char *str) {
     while (*str) {
-        uart_tx_one_char(UART0, *str++);
+        mp_hal_stdout_tx_char(*str++);
     }
 }
 
 void mp_hal_stdout_tx_strn(const char *str, uint32_t len) {
     while (len--) {
-        uart_tx_one_char(UART0, *str++);
+        mp_hal_stdout_tx_char(*str++);
     }
 }
 
 void mp_hal_stdout_tx_strn_cooked(const char *str, uint32_t len) {
     while (len--) {
         if (*str == '\n') {
-            uart_tx_one_char(UART0, '\r');
+            mp_hal_stdout_tx_char('\r');
         }
-        uart_tx_one_char(UART0, *str++);
+        mp_hal_stdout_tx_char(*str++);
     }
 }
 
diff --git a/esp8266/mpconfigport.h b/esp8266/mpconfigport.h
index 40d51e38d3d799466382490f7ac94f805f1ebcf7..52dbc18f52b0f181afd23f5105cd9738d29f02ac 100644
--- a/esp8266/mpconfigport.h
+++ b/esp8266/mpconfigport.h
@@ -51,6 +51,7 @@
 #define MICROPY_PY_LWIP             (1)
 #define MICROPY_PY_MACHINE          (1)
 #define MICROPY_PY_MICROPYTHON_MEM_INFO (1)
+#define MICROPY_PY_OS_DUPTERM       (1)
 #define MICROPY_CPYTHON_COMPAT      (1)
 #define MICROPY_LONGINT_IMPL        (MICROPY_LONGINT_IMPL_MPZ)
 #define MICROPY_FLOAT_IMPL          (MICROPY_FLOAT_IMPL_FLOAT)