Getting Esphome to Work With an Esp32-c3 Board

I have an Espressif esp32-c3-devkitm1. I wanted to add it to esphome running in Docker. I tried all sorts of different ways to get it recognized without success. I finally got it work by connecting it to the box running ubuntu and the Docker image. In the add device process there’s an option to use the host on which esphome is running. It didn’t work right off. I had to change the compose file to allow it to find the esp32-c3. This is my compose file:

services:
  esphome:
    container_name: esphome
    image: esphome/esphome
    restart: unless-stopped
    privileged: true
    network_mode: host
    devices:
      - /dev/bus/usb:/dev/bus/usb
    volumes:
      - /home/curt/esphome/config:/config
      - /etc/localtime:/etc/localtime:ro

I first added

    devices:
      - /dev/bus/usb:/dev/bus/usb

That didn’t work. Then I added:

    privileged: true

That did the trick. I understand that privileged: true is a security risk so I’m going to turn it off now that I can connect to the esp32-c3 via wifi.

One other problem I had was that the device was in a boot loop. Over on the Discord channel, rradar gave me a fix for that. This is the pertinent part of the config.yaml:

esphome:
  name: esp32-c3
  platformio_options:
    board_build.f_flash: 40000000L
    board_build.flash_mode: dio
    board_build.flash_size: 4MB

esp32:
  variant: ESP32C3
  board: esp32-c3-devkitm-1
  framework:
    type: esp-idf

It was the platformio_options that finally got it to work. This may only be needed for the Espressif esp32-c3-devkitm1 board. YMMV

12 Likes

Thanks for sharing this, very helpful to know the issue was platformio_options. ESPHome does not auto generate that part.

Do you know if making ESPHome privileged a thing to see the device on WiFi is specific to Docker?

EDIT: This config works fine with a standard HA install; appears to be no need to set privileged for ESPHome.

interesting, different settings than here

I’m almost certain privileged mode is specific to Docker, but I’m far from a Docker expert. It appears to expose more of the underlying OS to the Docker container, something the wouldn’t be necessary running directly on the OS.

FYI, i’ve been able to flash esphome to an lolin wemos c3 mini using this config:

esphome:
  name: ts27meter
  platformio_options:
    board_build.flash_mode: dio

esp32:
  board: esp32-c3-devkitm-1
  framework:
    type: arduino
    version: 2.0.3
    platform_version: 4.4.0

I could (somehow) not flash it via the windows flasher (exe) or the Linux (via docker). The only way was via the web flasher at https://web.esphome.io/

1 Like

does it still work for you with esphome 2022.12.0?

I don’t have it actually doing anything that I could test. It still appears in Home Assistant after the upgrade and my other ESP Home devices work.

Works for me using this configuration as of today:

esp32:
  board: esp32-c3-devkitm-1
  framework:
    type: arduino
    version: 2.0.5
    platform_version: 5.2.0

uart working for you?

If anyone is having a problem with WeAct Studio ESP32C3 Core Board here is what i did to fix uploader getting stuck at “Running stub…”
I had to edit ./lib/python3.9/site-packages/esphome/__main__.py file, arround line 243 it look like this:

        cmd = [
            "esptool.py",
            "--before",
            "default_reset",
            "--after",
            "hard_reset",
            "--baud",

I had to add --no-stub option after esptool.py, like this:

       cmd = [
            "esptool.py",
            "--no-stub",  # Added this line
            "--before",
            "default_reset",
            "--after",
            "hard_reset",
            "--baud",

After this the uploader works and esphome run on that board.
Remember to remove this paramter after you upload esphome the first time on that board, next uploads can be done using Wifi, This option is safe to keep for other boards but it make the uploading slower, and it’s best to use the “Stub” when the board doesn’t have a problem running it, It’s just a new bootloader to flash the image, if not used esptool will use original bootloader found on the board

Might save someone same time, cause this show up first when searching for this problem

2 Likes

UPDATE: FIXED! Thanks to user damex from Discord, it’s working now. The key problem is that you need to delay the start of BT stack until wifi is connected.

here’s an example of a working configuration.

**** original post ****

Just received this board - says ESP32-C3-12f, but so far no luck.

With esp-idf I get this - Mozilla Community Pastebin/0QN36uif (JavaScript)

With Arduino it just refuses to boot.

P.S. Tasmota runs without a hitch, so it’s not the board.

1 Like

I seemed to really struggle with so many alternative variants being proposed for config necessary to get going with C3. So I just want to confirm that this minimal config works perfectly for ESP32 C3 Super Mini

esphome:
  name: ${name}
  friendly_name: ${friendly_name}

esp32:
  board: esp32-c3-devkitm-1
  framework:
    type: esp-idf

# Enable logging
logger:

# Enable Home Assistant API
api:
  encryption:
    key: !secret api_encryption_key

ota:
  password: !secret ota_password

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

Does not Work on the Luatos C3 Model.

i can flash the Tasmota32C3_factory.bin and it works. But haven’t got that to work with ESPHome…
Whenever the flash is done the board is just dead. Not even Bootloader shows up in Serial Console.

Hello again. I’m trying to compile for an Seed Studio XIAO ESP32C3. It always crashes during compiling in ESPhome on Home Assistant installed as HAOS on dedicated Rasperry Pi 3 with 1GB Ram.

INFO ESPHome 2024.2.2
INFO Reading configuration /config/esphome/esphome-web-0669cc.yaml...
INFO Generating C++ source...
INFO Compiling app...
Processing esp32-c3 (board: seeed_xiao_esp32c3; framework: arduino; platform: platformio/[email protected])
--------------------------------------------------------------------------------
Removing unused dependencies...
Library Manager: Installing esphome/AsyncTCP-esphome @ 2.0.1
INFO Installing esphome/AsyncTCP-esphome @ 2.0.1
Unpacking  [####################################]  100%
Library Manager: [email protected] has been installed!
INFO [email protected] has been installed!
Library Manager: Installing esphome/ESPAsyncWebServer-esphome @ 3.1.0
INFO Installing esphome/ESPAsyncWebServer-esphome @ 3.1.0
Unpacking  [####################################]  100%
Library Manager: [email protected] has been installed!
INFO [email protected] has been installed!
Library Manager: Resolving dependencies...
INFO Resolving dependencies...
HARDWARE: ESP32C3 160MHz, 320KB RAM, 4MB Flash
 - toolchain-riscv32-esp @ 8.4.0+2021r2-patch5
Dependency Graph
|-- AsyncTCP-esphome @ 2.0.1
|-- WiFi @ 2.0.0
|-- FS @ 2.0.0
|-- Update @ 2.0.0
|-- ESPAsyncWebServer-esphome @ 3.1.0
|-- DNSServer @ 2.0.0
|-- ESPmDNS @ 2.0.0
|-- noise-c @ 0.1.4
Compiling .pioenvs/esp32-c3/src/esphome/components/api/api_connection.cpp.o
Compiling .pioenvs/esp32-c3/src/esphome/components/api/api_frame_helper.cpp.o
Compiling .pioenvs/esp32-c3/src/esphome/components/api/api_pb2.cpp.o
riscv32-esp-elf-g++: fatal error: Killed signal terminated program cc1plus
compilation terminated.
*** [.pioenvs/esp32-c3/src/esphome/components/api/api_pb2.cpp.o] Error 1
========================= [FAILED] Took 60.98 seconds =========================

I also treid different YAML Setting. Acrtual config is (i took form here: Seeed Studio XIAO ESP32C3 — PlatformIO v6.1 documentation)

esphome:
  name: esp32-c3
  platformio_options:
    board_build.mcu: esp32c3
    board_build.f_cpu: 160000000L
    board_build.f_flash: 40000000L
    board_build.flash_mode: dio
    board_build.flash_size: 4MB

esp32:
  variant: ESP32C3
  board: seeed_xiao_esp32c3
  framework:
    type: arduino

Any hint will be appriciated.

For anyone finding this thread in the future: The following settings found here worked for me:

esphome:
  platformio_options:
    board_build.f_flash: 40000000L
    board_build.flash_mode: dio
    board_build.flash_size: 4MB

esp32:
  board: esp32-c3-devkitm-1
  variant: esp32c3
  framework:
    type: esp-idf
1 Like

I managed to revive my Shelly plus PM mini (which uses C3) with this command and arduino environment:

esphome:
  name: shelly_module
  platformio_options:
    board_build.mcu: esp32c3
    board_build.variant: esp32c3  
    board_build.f_cpu: 160000000L

esp32:
  board: esp32dev
  variant: ESP32C3  
  framework:
    type: arduino

Perhaps first two options under “esphome” are unnecesarry… (i didn’t test it). But f_cpu was “the one”, since without it i’ve got an error from esp’s uart: “cpu runs at 240MHz, which si unsupported by esp” (something in this style).

You are correct, those are not needed. I have removed them from the page since.

This is the correct way of setting the CPU frequency: [ESP32] Low performance of esp-idf build comparing to arduino one · Issue #5396 · esphome/issues · GitHub