diff --git a/stmhal/Makefile b/stmhal/Makefile
index 9d4640d1f90963939f762053a6ae0b613953e5b2..60e5fde3d3b55284bf5975ac125f398a4de9b6f9 100644
--- a/stmhal/Makefile
+++ b/stmhal/Makefile
@@ -74,6 +74,7 @@ SRC_C = \
 	pyexec.c \
 	pybmodule.c \
 	osmodule.c \
+	timemodule.c \
 	import.c \
 	lexerfatfs.c \
 	gpio.c \
diff --git a/stmhal/main.c b/stmhal/main.c
index 22f7be23ebd9f262cfed754a1e957a8fd3f37a13..2b4daa370519abf06fab4eb383439ff3fe04e2cd 100644
--- a/stmhal/main.c
+++ b/stmhal/main.c
@@ -23,6 +23,7 @@
 #include "pyexec.h"
 #include "pybmodule.h"
 #include "osmodule.h"
+#include "timemodule.h"
 #include "usart.h"
 #include "led.h"
 #include "exti.h"
@@ -276,9 +277,10 @@ soft_reset:
     // probably shouldn't do this, so we are compatible with CPython
     rt_store_name(MP_QSTR_pyb, (mp_obj_t)&pyb_module);
 
-    // pre-import the os module
+    // pre-import the os and time modules
     // TODO don't do this! (need a way of registering builtin modules...)
     rt_store_name(MP_QSTR_os, (mp_obj_t)&os_module);
+    rt_store_name(MP_QSTR_time, (mp_obj_t)&time_module);
 
     // check if user switch held (initiates reset of filesystem)
     bool reset_filesystem = false;
diff --git a/stmhal/qstrdefsport.h b/stmhal/qstrdefsport.h
index be30848e398491d7dd8e90fab4bdac9fe12c829d..9961102a35b042895f248023eab78a5d8e04651b 100644
--- a/stmhal/qstrdefsport.h
+++ b/stmhal/qstrdefsport.h
@@ -66,3 +66,7 @@ Q(rmdir)
 Q(unlink)
 Q(sep)
 Q(urandom)
+
+// for time module
+Q(time)
+Q(sleep)
diff --git a/stmhal/timemodule.c b/stmhal/timemodule.c
new file mode 100644
index 0000000000000000000000000000000000000000..b2dac6a54c8aea4afea2f3c8a45444ebb2f2f4a7
--- /dev/null
+++ b/stmhal/timemodule.c
@@ -0,0 +1,44 @@
+#include <stm32f4xx_hal.h>
+
+#include "nlr.h"
+#include "misc.h"
+#include "mpconfig.h"
+#include "qstr.h"
+#include "obj.h"
+#include "map.h"
+#include "timemodule.h"
+
+STATIC mp_obj_t time_sleep(mp_obj_t seconds_o) {
+#if MICROPY_ENABLE_FLOAT
+    if (MP_OBJ_IS_INT(seconds_o)) {
+#endif
+        HAL_Delay(1000 * mp_obj_get_int(seconds_o));
+#if MICROPY_ENABLE_FLOAT
+    } else {
+        HAL_Delay((uint32_t)(1000 * mp_obj_get_float(seconds_o)));
+    }
+#endif
+    return mp_const_none;
+}
+
+MP_DEFINE_CONST_FUN_OBJ_1(time_sleep_obj, time_sleep);
+
+STATIC const mp_map_elem_t time_module_globals_table[] = {
+    { MP_OBJ_NEW_QSTR(MP_QSTR___name__), MP_OBJ_NEW_QSTR(MP_QSTR_time) },
+
+    { MP_OBJ_NEW_QSTR(MP_QSTR_sleep), (mp_obj_t)&time_sleep_obj },
+};
+
+STATIC const mp_map_t time_module_globals = {
+    .all_keys_are_qstrs = 1,
+    .table_is_fixed_array = 1,
+    .used = sizeof(time_module_globals_table) / sizeof(mp_map_elem_t),
+    .alloc = sizeof(time_module_globals_table) / sizeof(mp_map_elem_t),
+    .table = (mp_map_elem_t*)time_module_globals_table,
+};
+
+const mp_obj_module_t time_module = {
+    .base = { &mp_type_module },
+    .name = MP_QSTR_time,
+    .globals = (mp_map_t*)&time_module_globals,
+};
diff --git a/stmhal/timemodule.h b/stmhal/timemodule.h
new file mode 100644
index 0000000000000000000000000000000000000000..70e35b1fde35cb432f2dcfba26a785730e4949c0
--- /dev/null
+++ b/stmhal/timemodule.h
@@ -0,0 +1 @@
+extern const mp_obj_module_t time_module;