diff --git a/arch/esp32/esp32s2.ini b/arch/esp32/esp32s2.ini
new file mode 100644
index 000000000..ca4f576d6
--- /dev/null
+++ b/arch/esp32/esp32s2.ini
@@ -0,0 +1,47 @@
+[esp32s2_base]
+extends = arduino_base
+platform = platformio/espressif32@^5.2.0
+build_src_filter =
+ ${arduino_base.build_src_filter} - - - - -
+upload_speed = 961200
+monitor_speed = 115200
+debug_init_break = tbreak setup
+monitor_filters = esp32_exception_decoder
+board_build.filesystem = littlefs
+
+# Remove -DMYNEWT_VAL_BLE_HS_LOG_LVL=LOG_LEVEL_CRITICAL for low level BLE logging.
+# See library directory for BLE logging possible values: .pio/libdeps/tbeam/NimBLE-Arduino/src/log_common/log_common.h
+# This overrides the BLE logging default of LOG_LEVEL_INFO (1) from: .pio/libdeps/tbeam/NimBLE-Arduino/src/esp_nimble_cfg.h
+build_flags =
+ ${arduino_base.build_flags}
+ -Wall
+ -Wextra
+ -Isrc/platform/esp32
+ -std=c++11
+ -DLOG_LOCAL_LEVEL=ESP_LOG_DEBUG
+ -DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_DEBUG
+ -DMYNEWT_VAL_BLE_HS_LOG_LVL=LOG_LEVEL_CRITICAL
+ -DAXP_DEBUG_PORT=Serial
+ -DCONFIG_BT_NIMBLE_ENABLED
+ -DCONFIG_NIMBLE_CPP_LOG_LEVEL=2
+ -DCONFIG_BT_NIMBLE_MAX_CCCDS=20
+ -DESP_OPENSSL_SUPPRESS_LEGACY_WARNING
+ -DHAS_BLUETOOTH=0
+ -DDEBUG_HEAP
+
+lib_deps =
+ ${arduino_base.lib_deps}
+ ${networking_base.lib_deps}
+ ${environmental_base.lib_deps}
+ https://github.com/meshtastic/esp32_https_server.git#23665b3adc080a311dcbb586ed5941b5f94d6ea2
+ https://github.com/lewisxhe/XPowersLib.git#84b7373faea3118b6c37954d52f98b8a337148d6
+ caveman99/ESP32 Codec2@^1.0.1
+
+lib_ignore =
+ segger_rtt
+ ESP32 BLE Arduino
+
+; customize the partition table
+; http://docs.platformio.org/en/latest/platforms/espressif32.html#partition-tables
+board_build.partitions = partition-table.csv
+
diff --git a/src/modules/SerialModule.cpp b/src/modules/SerialModule.cpp
index 116690d74..c25f69fa4 100644
--- a/src/modules/SerialModule.cpp
+++ b/src/modules/SerialModule.cpp
@@ -82,7 +82,7 @@ SerialModuleRadio::SerialModuleRadio() : MeshModule("SerialModuleRadio")
int32_t SerialModule::runOnce()
{
-#if (defined(ARCH_ESP32) || defined(ARCH_NRF52)) && !defined(TTGO_T_ECHO)
+#if (defined(ARCH_ESP32) || defined(ARCH_NRF52)) && !defined(TTGO_T_ECHO) && !defined(CONFIG_IDF_TARGET_ESP32S2)
/*
Uncomment the preferences below if you want to use the module
without having to configure it from the PythonAPI or WebUI.
@@ -239,7 +239,7 @@ void SerialModuleRadio::sendPayload(NodeNum dest, bool wantReplies)
ProcessMessage SerialModuleRadio::handleReceived(const MeshPacket &mp)
{
-#if (defined(ARCH_ESP32) || defined(ARCH_NRF52)) && !defined(TTGO_T_ECHO)
+#if (defined(ARCH_ESP32) || defined(ARCH_NRF52)) && !defined(TTGO_T_ECHO) && !defined(CONFIG_IDF_TARGET_ESP32S2)
if (moduleConfig.serial.enabled) {
auto &p = mp.decoded;
diff --git a/src/platform/esp32/main-esp32.cpp b/src/platform/esp32/main-esp32.cpp
index 21df018d8..e36a8cfd8 100644
--- a/src/platform/esp32/main-esp32.cpp
+++ b/src/platform/esp32/main-esp32.cpp
@@ -3,7 +3,9 @@
#include "esp_task_wdt.h"
#include "main.h"
+#if !defined(CONFIG_IDF_TARGET_ESP32S2)
#include "nimble/NimbleBluetooth.h"
+#endif
#include "BleOta.h"
#include "mesh/http/WiFiAPClient.h"
@@ -16,13 +18,9 @@
#include
#include "soc/rtc.h"
+#if !defined(CONFIG_IDF_TARGET_ESP32S2)
NimbleBluetooth *nimbleBluetooth;
-void getMacAddr(uint8_t *dmac)
-{
- assert(esp_efuse_mac_get_default(dmac) == ESP_OK);
-}
-
void setBluetoothEnable(bool on) {
if (!isWifiAvailable() && config.bluetooth.enabled == true) {
@@ -36,6 +34,15 @@ void setBluetoothEnable(bool on) {
}
}
}
+#else
+void setBluetoothEnable(bool on) { }
+void updateBatteryLevel(uint8_t level) { }
+#endif
+
+void getMacAddr(uint8_t *dmac)
+{
+ assert(esp_efuse_mac_get_default(dmac) == ESP_OK);
+}
#ifdef HAS_32768HZ
#define CALIBRATE_ONE(cali_clk) calibrate_one(cali_clk, #cali_clk)
diff --git a/src/sleep.cpp b/src/sleep.cpp
index 39ee43ebc..6625da2a3 100644
--- a/src/sleep.cpp
+++ b/src/sleep.cpp
@@ -300,6 +300,8 @@ void enableModemSleep()
#if CONFIG_IDF_TARGET_ESP32S3
esp32_config.max_freq_mhz = CONFIG_ESP32S3_DEFAULT_CPU_FREQ_MHZ;
+#elif CONFIG_IDF_TARGET_ESP32S2
+ esp32_config.max_freq_mhz = CONFIG_ESP32S2_DEFAULT_CPU_FREQ_MHZ;
#else
esp32_config.max_freq_mhz = CONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ;
#endif