diff --git a/main/CMakeLists.txt b/main/CMakeLists.txt
index ea39b5365940dd94aa760a9ef287354dab8f75ab..fd1ee897892b02f1399c1d0e89bc9c87d6cbc306 100644
--- a/main/CMakeLists.txt
+++ b/main/CMakeLists.txt
@@ -16,6 +16,8 @@ set(MICROPY_QSTRDEFS_PORT "${MICROPY_PORT_DIR}/qstrdefsport.h")
 
 include("${MICROPY_DIR}/py/py.cmake")
 
+set(USER_C_MODULES "${PROJECT_DIR}/usermodule/micropython.cmake")
+
 if(NOT CMAKE_BUILD_EARLY_EXPANSION)
     # Enable extmod components that will be configured by extmod.cmake.
     # A board may also have enabled additional components.
@@ -51,8 +53,6 @@ set(MICROPY_SOURCE_DRIVERS
 )
 
 set(MICROPY_SOURCE_PORT
-    ${MICROPY_PORT_DIR}/badge23_mp_hardware.c
-    ${MICROPY_PORT_DIR}/badge23_mp_synth.c
     ${MICROPY_PORT_DIR}/main.c
     ${MICROPY_PORT_DIR}/uart.c
     ${MICROPY_PORT_DIR}/usb.c
diff --git a/usermodule/micropython.cmake b/usermodule/micropython.cmake
new file mode 100644
index 0000000000000000000000000000000000000000..fbc5ed9b56ed0a2a667482ee6a62139568b8fe86
--- /dev/null
+++ b/usermodule/micropython.cmake
@@ -0,0 +1,12 @@
+add_library(usermod_badge23 INTERFACE)
+
+target_sources(usermod_badge23 INTERFACE
+    ${CMAKE_CURRENT_LIST_DIR}/mp_hardware.c
+    ${CMAKE_CURRENT_LIST_DIR}/mp_synth.c
+)
+
+target_include_directories(usermod_badge23 INTERFACE
+    ${CMAKE_CURRENT_LIST_DIR}
+)
+
+target_link_libraries(usermod INTERFACE usermod_badge23)
diff --git a/micropython/ports/esp32/badge23_mp_hardware.c b/usermodule/mp_hardware.c
similarity index 100%
rename from micropython/ports/esp32/badge23_mp_hardware.c
rename to usermodule/mp_hardware.c
diff --git a/micropython/ports/esp32/badge23_mp_synth.c b/usermodule/mp_synth.c
similarity index 100%
rename from micropython/ports/esp32/badge23_mp_synth.c
rename to usermodule/mp_synth.c