Blinky with ESPHome ESP32-C3

Updated on 13 November 2023
dev board ESP32-C3-DevKitM-1
chip ESP32-C3-MINI-1-N4
features esphome esp32c3 blinky
This tutorial is more than 1 year old. If the steps below do not work, then please check the latest versions and the documentations of the individual tools used.

Before starting

Dependancies

Ensure the following dependancies are downloaded and available:

Buy the components

Code

Download config blinky-esphome-esp32c3.yaml
esphome:
  name: blinky
  platformio_options:
    board_build.flash_mode: dio

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

logger:
  level: VERBOSE
  baud_rate: 115200
  deassert_rts_dtr: true

switch:
  - platform: gpio
    pin:
      number: 3 # on-board LED GPIO8 does not work, so GPIO3 is used
      mode: output
    id: led

interval:
  - interval: 2s
    then:
      - switch.toggle: led
      - logger.log: "LED toggling"

Makefile

YAML_FILE=blinky-esphome-esp32c3.yaml
PORT?=/dev/cu.usbserial-*

.PHONY: default compile upload log clean

default: clean compile upload log

help: ## Show help message
	@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n  make \033[36m\033[0m\n"} /^[$$()% 0-9a-zA-Z_-]+:.*?##/ { printf "  \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)

compile: ## Compile esphome
	esphome compile $(YAML_FILE)

upload: ## Upload the firmware to the board
	esphome upload --device $(PORT) $(YAML_FILE)

log: ## Start the logs
	esphome logs --device $(PORT) $(YAML_FILE)

clean: ## Remove all build files
	rm -rf .esphome

Prototype

A photo of the actual setup.

Blinky with ESPHome ESP32-C3 prototype

Schematic

Wire up the hardware accordingly

Blinky with ESPHome ESP32-C3 schematic

Serial console

Serial output from the firmware.

Blinky with ESPHome ESP32-C3 serial console

Description

LED

The default RGB LED on-board which is GPIO8 does on work. So, wire up a simple LED to GPIO3 with a 1k resistor to the ground.

Compile and upload

  1. Compile firmware for this board

     esphome compile blinky-esphome-esp32c3.yaml
    
  2. Plug into the USB port of the board and check the port address

     $ ls /dev/cu.*
     /dev/cu.Bluetooth-Incoming-Port  /dev/cu.SLAB_USBtoUART  /dev/cu.usbserial-1410
    
  3. Upload the firmware

     esphome upload --device /dev/cu.SLAB_USBtoUART blinky-esphome-esp32c3.yaml
    

Access logs

  1. Plug into the USB port of the board
  2. Check the new port address

     $ ls /dev/cu.*
     /dev/cu.Bluetooth-Incoming-Port  /dev/cu.SLAB_USBtoUART  /dev/cu.usbserial-1410
    
  3. Access the logs

     esphome logs --device /dev/cu.SLAB_USBtoUART blinky-esphome-esp32c3.yaml
    

References

Watch