3 min read

Seeed Xiao ESP32S3 Sense with ESPHome (and Home Assistant)

Seeed Xiao ESP32S3 Sense with ESPHome (and Home Assistant)
Photo by Vishnu Mohanan / Unsplash

While looking for a solution as my 3D printer's nozzle camera, I stumbled upon Seeed Xiao ESP32S3 Sense mentioned in the title. It received a relative lot of positive reviews, and was suggested as a well-balanced hardware for the application. So I decided to pull the trigger, and two days later I was able to start fiddling with it. Unfortunately implementing it as a camera wasn't as easy as I initially imagined.

Seeed Xiao ESP32S3 Sense (let's call it Xiao Sense from now on in this text) is not my first ESP32 module with a camera in the ESP32/ESPHome ecosystem. Before that I worked with the idea of enhancing my door with Ai-Thinker Camera with mixed results. That is, camera worked fairly well, just the fact of other things overwhelming me stopped me from continuing that project, at least for now.

Having a template-alike implementation of camera for ESPHome ready in my repo I thought that using Xiao Sense will be a breeze. I started with, obvious from my experiences, ESPHome entry on the camera component, where there is already an entry on that module.

esp32_camera:
  external_clock:
    pin: GPIO10
    frequency: 20MHz
  i2c_pins:
    sda: GPIO40
    scl: GPIO39
  data_pins: [GPIO15, GPIO17, GPIO18, GPIO16, GPIO14, GPIO12, GPIO11, GPIO48]
  vsync_pin: GPIO38
  href_pin: GPIO47
  pixel_clock_pin: GPIO13

This is helpful, but does not resolve the issue on which board to pick for the esp32 root element. The next step was to check the ESPHome's documentation on this section, where there is this instruction in the ESP-IDF paragraph:

This is an alternative base framework for ESP32 chips, and recommended for variants of the ESP32 like ESP32S2, ESP32S3, ESP32C3 and single-core ESP32 chips.

Let's call it a good starting point. The full list of supported chips and boards is available in the PlatformIO portal, where there is already an entry on the Seeed's ESP32S3. Compiling all the following into one, I ended up with the following:

esp32:
  board: seeed_xiao_esp32s3
  framework:
    type: esp-idf

# rest of the implementation follows

Should be enough, right? Unfortunately not. Even picking the latest (as of writing of this text) version of the platform, 6.8.1, does not help. In this case, ESPHome forces upon selection of board's variant. For Xiao Sense it's esp32s3.

This does not help either, as ESPHome now switches to claims that seeed_xiao_esp32s3 is not a recognized board. That's because ESPHome 2024.7.3 uses the platform of version 5.4.0, while this board was added around version 6.3.0 if I got things right. That's why picking any platform version of 6.3.0 or higher will get rid of the error. I decided to go with latest, which is 6.8.1 as of writing of this post.

But again, this only changes the resulting compilation error. Cutting the story short, the framework version has to be upped, so I went simply with latest. At this point there is the following declaration:

esp32:
  board: seeed_xiao_esp32s3
  variant: esp32s3
  framework:
    type: esp-idf
    version: latest
    platform_version: "6.8.1"

Compiling with the following config throws a bunch of pin-related obsoleting warnings, and fails with the code of 1. The message does not help at all.

CMake Error: Error processing file: /mnt/c/_git/Configurations/esphome/.esphome/build/camera-seeed-xiao-sense-01/.pioenvs/camera-seeed-xiao-sense-01/esp-idf/esp_system/ld/linker_script_generator.cmake
*** [.pioenvs/camera-seeed-xiao-sense-01/esp-idf/esp_system/ld/sections.ld.in] Error 1

What caught my attention though were messages few lines earlier:

Warning! Flash memory size mismatch detected. Expected 4MB, found 2MB!
Please select a proper value in your `sdkconfig.defaults` or via the `menuconfig` target!

I was clearly doing something wrong. This led me to searching the Internet with the term "seeed xiao sense esphome" and an article in the Seeed Studio's wiki. What surprised me was that it suggested using the esp32-s3-devkitc-1 board and arduino framework. But more importantly it contained some additional flags:

  • Information about the PSRAM.
  • The board has 8 MB of flash memory.
  • For Arduino build process, there is an info of qio_opi memory type.
  • The flash mode for the board is qio.

Two last points can be omitted, so the updated yaml file looks like that now:

esp32:
  board: seeed_xiao_esp32s3
  variant: esp32s3
  flash_size: 8MB
  framework:
    type: esp-idf
    version: latest
    platform_version: "6.8.1"

psram:

Unfortunately this took care of warnings only, and compilation was still crashing at the end. With that I decided to ditch the ESPHome recommendation, and follow with Arduino framework - so the type entry in framework section of esp32 root element can be skipped, as arduino is the default value.

And with those changes, there's finally this one wonderful message at the end of the compilation process:

INFO Successfully compiled program.

Just to be sure I compiled the firmware multiple times, with and without cleans inbetween, always successfully. So in the end, the basics for the board are:

esp32:
  board: seeed_xiao_esp32s3
  variant: esp32s3
  flash_size: 8MB
  framework:
    version: latest
    platform_version: "6.8.1"

psram:

esp32_camera:
  external_clock:
    pin: GPIO10
    frequency: 20MHz
  i2c_pins:
    sda: GPIO40
    scl: GPIO39
  data_pins: [GPIO15, GPIO17, GPIO18, GPIO16, GPIO14, GPIO12, GPIO11, GPIO48]
  vsync_pin: GPIO38
  href_pin: GPIO47
  pixel_clock_pin: GPIO13

This and more devices skeletons can be found in my GitHub repo. I have a repository with configurations for all my devices hosted on GitHub, too.