Skip to main content

Connecting XIAO ESP32-C5 to Home Assistant

This wiki tutorial will demonstrate how to connect the Seeed Studio XIAO ESP32-C5 to Home Assistant, as well as how to control devices or transmit data after connecting Grove modules to the XIAO ESP32-C5. So, let's get started!

Introduction to Home Assistant

Home Assistant is a powerful open-source home automation platform that allows you to control and monitor your smart home devices from a single, unified interface. It acts as the central hub for your smart home, enabling you to automate routines, monitor sensors, and create a more intelligent living space.

ESPHome Integration

ESPHome is an open-source firmware creation tool specifically designed for ESP8266 / ESP32 devices. It allows you to create custom firmware using simple YAML configuration files, which can then be flashed to your device.


Method 1: Using ESPHome

This example will connect to Home Assistant via ESPHome.

Hardware Preparation

You need to prepare the items listed in the table.

Seeed Studio XIAO ESP32-C5Seeed Studio Grove Base for XIAOGrove - Red LED

Install The Firmware

If you have not set up Home Assistant, you can click this link and follow the official Home Assistant tutorial to complete the setup.Home Assistant Installation

Step 1. Install ESPhome

If you have already installed ESPHome, you can skip this step.

  • Go to Settings -> Add-ons
  • ADD-ON STORE -> Search ESPHome
  • Start ESPhome
tip

Make sure that the version of ESPHome you have installed is greater than or equal to 25.11.5; otherwise, it may not support the XIAO ESP32-C5.

Step 2. Add new device

Go to ESPHome, and click on the Add New Device button at the bottom right.


Add a new device and name it XIAO ESP32-C5.



Step 3. Install firwmare

Reference YAML File Configuration
tip

You need to modify the parameters to match those of your device, such as the API key, SSID, password, and so on. In addition, the XIAO ESP32-C5 supports dual-band WiFi (2.4 GHz & 5 GHz), which means you can connect it to the 5 GHz router in your home.

esphome:
name: xiao-esp32-c5
friendly_name: XIAO ESP32-C5

esp32:
board: esp32-c5-devkitc-1
variant: esp32c5
framework:
type: esp-idf

# Enable logging
logger:

# Enable Home Assistant API
api:
encryption:
key:

ota:
- platform: esphome
password:

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

# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Xiao-Esp32-C5 Fallback Hotspot"
password:

captive_portal:
# Example configuration entry
output:
- platform: gpio
pin: GPIO1
id: led_gpio_output
inverted: false

switch:
- platform: output
name: "LED Switch"
output: led_gpio_output
id: dev_board_led

Click INSTALL to install the code to the device and you will see the following image.

tip

If your Home Assistant Host (Raspberry PI/Green/Yellow etc.) is far away from you, we recommend using this method. You can install it with the computer you have on hand.

First, you need to click Manual download to download the compiled firmware.

Open this website where we will upload the firmware to the XIAO ESP32-C5.
ESPHome dashboard_install


Go back to ESPHome to download the firmware.


Select Factory format.

Use USB cable to connect the device to your computer and click CONNECT.
ESPHome dashboard_install


Select usbmodemxxx(Windows is COMxxx) and click connect.

Click INSTALL and select the firmware you just downloaded.

Step 4. Add Device

  • Navigate to SettingsDevices & services

  • ESPHome Device -> Add.

  • If you have opted to add a secret key, you need to enter it, which can be found in the YAML file you created.

  • The following screen will be displayed after a successful addition.

Display on the Dashboard

Step 1. Open Overview -> Click Edit in the upper right corner

Step 2. Create a section and name it LED Control -> Add the Card

Step 3. Add by entity -> Search XIAO ESP32-C5 -> Continue

Step 4. Select Add to dashboard in the pop-up window -> Click Done in the upper right corner to complete the addition.

  • The effects are as follows:

Method 2: Seeed Home Assistant Discovery

  • Seeed HA Discovery is a complete solution for easily connecting ESP32/nRF52840 devices to Home Assistant, provided by Seeed Studio.
  • With just a few lines of code in Arduino IDE or PlatformIO for your XIAO series development boards, you can connect to Home Assistant via WiFi or BLE.
  • Here we will use an example of reading a greenhouse temperature and humidity sensor to show you how to use Seeed Home Assistant Discovery to connect the XIAO ESP32-C5 to Home Assistant.

Hardware Preparation

Seeed Studio XIAO ESP32-C5Seeed Studio Grove Base for XIAOGrove - Temperature & Humidity Sensor (DHT11)

Install HACS Instagram

Before adding the Seeed Home Assistant Discovery integration, you need to install HACS first.

Installation Steps:

  1. Settings -> Devices & services -> Add integration -> Search HACS
  1. Select all options -> Submit
  1. Click on the hyperlink and copy the activation code within it.

  2. Enter the activation code mentioned earlier

  3. Return to HomeAssistant -> Developer tools -> Reboot system

  1. The left navigation bar shows HACS

Install Integration

  • One-Click Installation via HACS (Recommended)
  1. Open HACS -> Integrations:

  2. Click the icon in the upper right corner -> Custom repositories

  3. Enter https://github.com/limengdu/Seeed-Homeassistant-Discovery, elect category Integration

  4. Click Add, then search for Seeed HA Discovery and install

  5. Restart Home Assistant

Install Arduino Library

Install the WiFi Dependency Library

  • For Arduino IDE
  1. Download the arduino/SeeedHADiscovery folder

  1. Copy to C:\Users\yourname\Documents\Arduino\libraries\

  2. ArduinoJson (by Benoit Blanchon)

  1. WebSockets (by Markus Sattler)
  • For PlatformIO
lib_deps =
bblanchon/ArduinoJson@^7.0.0
links2004/WebSockets@^2.4.0

Install the BLE Dependency Library

  • For Arduino IDE
  1. Download the arduino/SeeedHADiscoveryBLE folder

  2. Copy to C:\Users\yourname\Documents\Arduino\libraries\


  1. NimBLE-Arduino
  • For PlatformIO
lib_deps =
h2zero/NimBLE-Arduino@^1.4.0

Write Arduino Program

Choose the corresponding version according to your actual needs.

#include <SeeedHADiscovery.h>

const char* WIFI_SSID = "Your WiFi Name";
const char* WIFI_PASSWORD = "Your WiFi Password";

SeeedHADiscovery ha;
SeeedHASensor* tempSensor;
SeeedHASensor* humiditySensor;

void setup() {
Serial.begin(115200);
ha.setDeviceInfo("Living Room Sensor", "ESP32-C5", "1.0.0");
ha.enableDebug(true);

if (!ha.begin(WIFI_SSID, WIFI_PASSWORD)) {
Serial.println("WiFi connection failed!");
while (1) delay(1000);
}

tempSensor = ha.addSensor("temperature", "Temperature", "temperature", "°C");
tempSensor->setPrecision(1);

humiditySensor = ha.addSensor("humidity", "Humidity", "humidity", "%");
humiditySensor->setPrecision(0);
}

void loop() {
ha.handle();

static unsigned long lastUpdate = 0;
if (millis() - lastUpdate > 5000) {
lastUpdate = millis();
tempSensor->setValue(25.5);
humiditySensor->setValue(55);
}
}

After uploading the code, open the serial monitor. Once the WiFi connection is successful, the corresponding IP address will be printed.

tip

XIAO ESP-C5 supports dual-band WiFi (2.4 GHz & 5 GHz).
If you find manual network configuration too cumbersome, you can also use the firmware flashing webpage we launched.: Web Firmware Flasher

Add Device in Home Assistant

It Will be automatically discovered! Or add manually:

  1. Go to Settings -> Devices & Services

  2. Click Add Integration

  3. Search for Seeed HA Discovery

  4. Enter the IP address of the ESP32

Effect Demonstration


Congratulations! By now, you should have mastered two methods to connect the XIAO ESP32-C5 to Home Assistant. We look forward to seeing your amazing projects and welcome you to share them with us!

Tech Support & Product Discussion

Thank you for choosing our products! We are here to provide you with different support to ensure that your experience with our products is as smooth as possible. We offer several communication channels to cater to different preferences and needs.

Loading Comments...