Error when compiling esp32 C3 mini

No matter which configurations I try, I get errors when trying to compile esphome for a esp32 C3 mini. I have uninstalled Esphome, deleted the esphome folder and reinstalled the Esphome add on. I get errors trying the arduino framerwork or esp-idf.

INFO ESPHome 2024.9.2
INFO Reading configuration /config/esphome/diffuser1.yaml...
INFO Generating C++ source...
INFO Compiling app...
Processing diffuser1 (board: esp32-c3-devkitm-1; framework: arduino; platform: platformio/[email protected])
--------------------------------------------------------------------------------
HARDWARE: ESP32C3 160MHz, 320KB RAM, 4MB Flash
 - toolchain-riscv32-esp @ 8.4.0+2021r2-patch5
Dependency Graph
|-- AsyncTCP-esphome @ 2.1.4
|-- WiFi @ 2.0.0
|-- FS @ 2.0.0
|-- Update @ 2.0.0
|-- ESPAsyncWebServer-esphome @ 3.2.2
|-- DNSServer @ 2.0.0
|-- ESPmDNS @ 2.0.0
Compiling .pioenvs/diffuser1/src/esphome/components/api/api_connection.cpp.o
In file included from src/esphome/components/api/api_connection.h:3,
                 from src/esphome/components/api/api_connection.cpp:1:
src/esphome/components/api/api_frame_helper.h:2:10: fatal error: cstdint: No such file or directory
 #include <cstdint>
          ^~~~~~~~~
compilation terminated.
*** [.pioenvs/diffuser1/src/esphome/components/api/api_connection.cpp.o] Error 1
Compiling .pioenvs/diffuser1/src/esphome/components/api/api_frame_helper.cpp.o
In file included from src/esphome/components/api/api_frame_helper.cpp:1:
src/esphome/components/api/api_frame_helper.h:2:10: fatal error: cstdint: No such file or directory
 #include <cstdint>
          ^~~~~~~~~
compilation terminated.
*** [.pioenvs/diffuser1/src/esphome/components/api/api_frame_helper.cpp.o] Error 1
========================== [FAILED] Took 6.27 seconds ==========================

Have you also tried to first clean the build files?

Yes, I have done that as well.

Obviously you did but I had to ask to be sure.
So bare with me because I have another question. Have you tried to compile a bare minimum config for your device. Something like the config that will be created for you when you create a new device in ESPHome. Can you post it here including the error if you got one?

Thanks for helping me! I followed your advice and I am trying to compile a bare minimun config (wifi, api, ota) I am trying the following config and now I am getting this error.

esphome:
  name: ${main_devicename}
  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: arduino
INFO ESPHome 2024.9.2
INFO Reading configuration /config/esphome/diffuser1.yaml...
INFO Generating C++ source...
INFO Compiling app...
Processing diffuser1 (board: esp32-c3-devkitm-1; framework: arduino; platform: platformio/[email protected])
--------------------------------------------------------------------------------
Library Manager: Installing esphome/AsyncTCP-esphome @ 2.1.4
INFO Installing esphome/AsyncTCP-esphome @ 2.1.4
Unpacking  [####################################]  100%
Library Manager: [email protected] has been installed!
INFO [email protected] has been installed!
Library Manager: Installing esphome/ESPAsyncWebServer-esphome @ 3.2.2
INFO Installing esphome/ESPAsyncWebServer-esphome @ 3.2.2
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.1.4
|-- WiFi @ 2.0.0
|-- FS @ 2.0.0
|-- Update @ 2.0.0
|-- ESPAsyncWebServer-esphome @ 3.2.2
|-- DNSServer @ 2.0.0
|-- ESPmDNS @ 2.0.0
Compiling .pioenvs/diffuser1/src/esphome/components/api/api_connection.cpp.o
In file included from src/esphome/components/api/api_connection.h:3,
                 from src/esphome/components/api/api_connection.cpp:1:
src/esphome/components/api/api_frame_helper.h:2:10: fatal error: cstdint: No such file or directory
 #include <cstdint>
          ^~~~~~~~~
compilation terminated.
Compiling .pioenvs/diffuser1/src/esphome/components/api/api_frame_helper.cpp.o
*** [.pioenvs/diffuser1/src/esphome/components/api/api_connection.cpp.o] Error 1
In file included from src/esphome/components/api/api_frame_helper.cpp:1:
src/esphome/components/api/api_frame_helper.h:2:10: fatal error: cstdint: No such file or directory
 #include <cstdint>
          ^~~~~~~~~
compilation terminated.
*** [.pioenvs/diffuser1/src/esphome/components/api/api_frame_helper.cpp.o] Error 1
========================== [FAILED] Took 6.73 seconds ==========================

I am not sure how to include that folder or where to look for it. My HA installation is on a Rapi 4

That is not the bare minimum config that ESPHome generates

If I try to make one for the ESP32-C3 (mini not available) then I got this config generated.

esphome:
  name: test
  friendly_name: test

esp32:
  board: esp32-c3-devkitm-1
  framework:
    type: arduino

# Enable logging
logger:

# Enable Home Assistant API
api:

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

And it will compile nicely.

INFO ESPHome 2024.9.2
INFO Reading configuration /config/esphome/test.yaml...
INFO Generating C++ source...
INFO Compiling app...
Processing test (board: esp32-c3-devkitm-1; framework: arduino; platform: platformio/[email protected])
--------------------------------------------------------------------------------
HARDWARE: ESP32C3 160MHz, 320KB RAM, 4MB Flash
 - toolchain-riscv32-esp @ 8.4.0+2021r2-patch5
Dependency Graph
|-- WiFi @ 2.0.0
|-- ESPmDNS @ 2.0.0
Compiling .pioenvs/test/src/esphome/components/api/api_connection.cpp.o
. . . .
Compiling .pioenvs/test/FrameworkArduino/wiring_shift.c.o
Archiving .pioenvs/test/libFrameworkArduino.a
Linking .pioenvs/test/firmware.elf
RAM:   [=         ]  10.8% (used 35548 bytes from 327680 bytes)
Flash: [====      ]  41.4% (used 758822 bytes from 1835008 bytes)
Building .pioenvs/test/firmware.bin
Creating esp32c3 image...
Successfully created esp32c3 image.
esp32_create_combined_bin([".pioenvs/test/firmware.bin"], [".pioenvs/test/firmware.elf"])
Wrote 0xcc970 bytes to file /data/build/test/.pioenvs/test/firmware.factory.bin, ready to flash to offset 0x0
esp32_copy_ota_bin([".pioenvs/test/firmware.bin"], [".pioenvs/test/firmware.elf"])
========================= [SUCCESS] Took 44.70 seconds =========================
INFO Successfully compiled program.

First try to get it compiling for the ESP32-C3 before adding other things such as a ESPAsyncWebServer and other dependencies.
I am running this on a nuc with HAOS. I am not able to install anything so any dependencies are added automatically.

So copied/pasted your config, just changed the name and friendly_name. I get the following error.

INFO ESPHome 2024.9.2
INFO Reading configuration /config/esphome/diffuser1.yaml...
INFO Generating C++ source...
INFO Compiling app...
Processing diffuser1 (board: esp32-c3-devkitm-1; framework: arduino; platform: platformio/[email protected])
--------------------------------------------------------------------------------
HARDWARE: ESP32C3 160MHz, 320KB RAM, 4MB Flash
 - toolchain-riscv32-esp @ 8.4.0+2021r2-patch5
Dependency Graph
|-- WiFi @ 2.0.0
|-- ESPmDNS @ 2.0.0
Compiling .pioenvs/diffuser1/src/esphome/components/api/api_connection.cpp.o
In file included from src/esphome/components/api/api_connection.h:3,
                 from src/esphome/components/api/api_connection.cpp:1:
src/esphome/components/api/api_frame_helper.h:2:10: fatal error: cstdint: No such file or directory
 #include <cstdint>
          ^~~~~~~~~
compilation terminated.
Compiling .pioenvs/diffuser1/src/esphome/components/api/api_frame_helper.cpp.o
*** [.pioenvs/diffuser1/src/esphome/components/api/api_connection.cpp.o] Error 1
In file included from src/esphome/components/api/api_frame_helper.cpp:1:
src/esphome/components/api/api_frame_helper.h:2:10: fatal error: cstdint: No such file or directory
 #include <cstdint>
          ^~~~~~~~~
compilation terminated.
*** [.pioenvs/diffuser1/src/esphome/components/api/api_frame_helper.cpp.o] Error 1
========================== [FAILED] Took 5.65 seconds ==========================

It seems that the problem is with the Esphome installation. I am going to uninstall/reinstall it again.

This might help someone. It finally worked with the following configuration:

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

I tried your solution with my ESP32C3 Mini, but I still get those error messages.

Is this still a bug in ESPhome with Home Assistant ( on a RPi4) ?

Unfortunately, I think that the RPi4 does not have enough resources. I setup a VM and that’s how it worked. Nevertheless, I am not very happy with the results of the Esp32 C3 Mini. I regret that I bought those controllers.

I understand. Fortunately the ESP32 C3 Mini doesn’t cost much. The small format is nice, but it has to work properly. For now, I’m trying to use the ESP-WROOM-32D and this device is working great with ESPhome.