Skip to main content

Building a smart home control centre around Home Assistant

In this article, we will detail how to set up Home Assistant on Seeed Studio's new product LinkStar H68K and deploy the ESPHome environment. ESPHome is a very common service in Home Assistant. Due to the system limitations of soft routing, we will use ESPHome as an example to guide you through a clever method of installing this service.

Getting Startedโ€‹

If you want to follow this tutorial through everything, you will need to prepare the following.

LinkStar H68K with Wi-Fi 6reRouter CM4 1432 (Optional)XIAO ESP32C3
Get One NowGet One NowGet One Now

*The reRouter CM4 1432 is also compatible with this tutorial. You can purchase LinkStar or reRouter.

The aim of this project is to install Home Assitant and ESPHome using LinkStar's Docker service, and then configure a LinkStar hotspot to connect to LinkStar using the XIAO ESP32C3's WiFi capabilities to complete the network.

Then combined with the vast Grove ecosystem, you can make even more possibilities in Home Assistant.

The content of this tutorial will broadly go through the following steps.

  1. Configure the Docker environment in LinkStar OpenWRT
  2. Installation and configuration of Home Assistant, ESPHome
  3. Add Seeed Studio XIAO ESP32C3 to ESPHome
  4. Grove Modules with ESPHome and Home Assistant

Configure the Docker environment in LinkStar OpenWRTโ€‹

Step 1. Install OpenWRT for LinkStarโ€‹

We have detailed how to install various systems for LinkStar in the LinkStar Wiki. In this tutorial, we will take the OpenWRT system as an example and explain how to install the Home Assistant Container while ensuring that LinkStar acts as a soft route.

Please select above the system location where you would like to install OpenWRT for LinkStar.

Step 2. Configure the LinkStar networkโ€‹

Please connect to LinkStar via a network cable and enter the IP address: 192.168.100.1 in your browser to access the operating backend of OpenWRT.

The initial account password is:

Account: root
Password: password

Next we need to get LinkStar connected to the internet.

You need to purchase a LinkStar with wireless networking, so you can choose to connect a network cable to the LinkStar or to WiFi.

  • If it is a wired network, please configure your network according to your network operator's instructions.
  • If you want to use a wireless LAN, you can search for a network in the Wireless options.

After that, just enter your network password, click Save and Apply.

Make sure you have a good network state before continuing with the next steps.

Step 3. Allocate more space to Dockerโ€‹

By default, docker is only about 250MB in size, which is not enough for us to install the image, so first we need to expand the capacity for Docker.

Click System --> Disk Man --> EDIT.

In the last line, write the size of the storage space to be added in the END SECTOR column. In my case, it's +20G. Then click NEW button.

Choose the ext4 format, then click FORMAT button.

When it is done, you'll see a new 20GB space is added. However, it's a free space now, you need to mount it to the Docker.

Then choose System --> Mount Points, find Mount Point section, click ADD button.

Choose the new space you've just created.

Choose the Mount Point Use as Docker data (/opt). Don't forget to check the checkbox Enable this mount, then click SAVE & APPLY button.

All settings for the expansion are complete, just need to reboot to make it valid.

Choose System --> Reboot, click the PERFORM REBOOT button. Wait for OpenWRT to reboot and login again.

Installation and configuration of Home Assistant, ESPHomeโ€‹

Step 4. Install Home Assistant with Dockerโ€‹

A better way to install Home Assistant in OpenWRT is to do it on Docker, which ensures that LinkStar is stable as a soft route and also allows Home Assistant to be deployed.

Then all we need to do is pull the specific Home Assistant image. This image will serve us well in installing the ESPHome service later on.

homeassistant/qemuarm-64-homeassistant:latest

We use the downloaded image to create a Container.

On the page where the container is created, we need to make some simple settings.

  • Container Name: your container name
  • Docker Image: choose just downloaded qemuarm-64-homeassistant image
  • Network: choose host mode
  • Environment Variables(-e): your environment variable

Once you have filled in the above, save and apply. You will see that the Container has been created. Let we start it.

Step 5. Install ESPHome with Dockerโ€‹

As we are installing the Home Assistant Container, we cannot simply download the ESPHome service via the Add-on shop, so a compromise is needed.

Repeating the above steps, we download the ESPHome image.

esphome/esphome:latest

On the page where the container is created, we need to make some simple settings.

  • Container Name: your container name
  • Docker Image: choose just downloaded esphome image
  • Network: choose host mode
  • Environment Variables(-e): your environment variable

Once you have filled in the above, save and apply. You will see that the Container has been created. You also need to start it.

Step 6. Add the ESPHome service to Home Assistantโ€‹

In order to achieve the same effect as downloading ESPHome in Home Assistant, we need to modify the configuration file under Home Assistant.

Go to the Home Assistant Container.

We go to the terminal in Home Assistant.

Enter the following command in the terminal.

vi configuration.yaml

Add following content to the end of configuration.yaml.

# Example configuration.yaml entry
panel_iframe:
esphome:
title: "ESPHome"
url: "http://192.168.100.1:6052"
icon: mdi:chip

Exit the docker container by type exit in the Home Assistant Container shell. Once this is done, we restart the Home Assistant container.

Create a new browser page, enter IP address 192.168.100.1:8123 and register your Home Assistant account and you will see ESPHome appear in the toolbar on the left.

Add Seeed Studio XIAO ESP32C3 to ESPHomeโ€‹

  • Step 1. Click + NEW DEVICE
  • Step 2. Click CONTINUE
  • Step 3. Enter a Name for the device and enter WiFi credentials such as Network name and Password. Then click NEXT
  • Step 4. Select ESP32-C3 and click
  • Step 5. Click SKIP because we will configure this board manually
  • Step 6. Click EDIT under the newly created board
  • Step 7. This will open a YAML file and this file will be used to set all the board configurations. Edit the content under esp32 as follows
esp32:
board: seeed_xiao_esp32c3
variant: esp32c3
framework:
type: arduino
version: 2.0.5
platform_version: 5.2.0

Note: Here we are using the latest version of Arduino core for ESP32 and ESP32 support for PlatformIO

  • Step 8. then, please click on the Save button in the top right corner.

LinkStar H68K do not support recognition of external MCU devices, we need to download the compiled firmware first and then upload the firmware via another PC.

  • Step 9. Click on the Install button in the top right hand corner. Then select the last item Manual download.
  • Step 10. Select Modern format.

It will then take a long time to download and compile, so please be patient. Once everything is ready, the firmware will be automatically downloaded to your computer.

  • Step 11. To upload the firmware to XIAO ESP32C3 there are couple options here we show 2 ways of doing it:

Make sure you have the right drivers installed. Below are the drivers for common chips used in ESP devices.

  1. CP2102 drivers: Windows & Mac
  2. CH342, CH343, CH9102 drivers: Windowns, Mac
  3. CH340, CH341 drivers: Windowns, Mac

Open the ESPhome Web tool with Chrome or Edge web browser.

Click CONNECT.

select the XIAO ESP32 serial port in the popup window.

Click INSTALL and then select the .bin file downloaded from above steps.

If you are still unable to upload firmware using method one after installing the driver and changing browsers, then you can try using method two. Please refer to the official tutorial for specific installation methods and instructions.

tip

If you wish to observe the log messages of the XIAO ESP32C3, you can also view them through the View Logs button of this software.

Once the upload is complete, you can disconnect the XIAO ESP32C3 from the PC (unless you have a need to view the logs) and simply power the XIAO separately.

If all goes well, the XIAO ESP32C3 will search for and connect to the WiFi you have set up for it.

Just like me, I use LinkStar H68K's network. You can find it in the network options and see the IP address assigned to it by LinkStar H68K.

  • Step 12. If you see the board status as ONLINE, that means the board is successful connected to WiFi
  • Step 13. Connect to XIAO ESP32C3

If you do not have many Home Assistant devices on your LAN, Home Assistant can automatically search for and add your ESP devices to the Devices tab. You can see this device inside the Devices & Services tab in Settings.

If it does not automatically search, you can also connect to the XIAO ESP32C3 based on its IP address.

Click ADD INTEGRSTION and search for esphome.

Then enter the IP address of the XIAO ESP32C3 with port number 6053. Then click on SUBMIT.

If the IP address and port number entered are correct, then you will see that you are asked to enter the Encryption key, which we asked to save in yaml file.

Then click on SUBMIT.

At this point, the steps to add the device have been successfully completed.

Grove Modules with ESPHome and Home Assistantโ€‹

Now we will connect Grove modules to Seeed Studio XIAO ESP32C3 so that we can display sensor data or control the devices using Home Assistant!

Connect Grove Modules to XIAO ESP32C3โ€‹

In order to use Grove modules with Seeed Studio XIAO ESP32C3, we will use a Grove Shield for Seeed Studio XIAO and connect XIAO ESP32C3 on it.

After that, the Grove connectors on the board can be used to connect Grove modules

Pin Definitionsโ€‹

You need to follow the table below to use the appropriate internal pin numbers when connecting the Grove modules to the Grove connectors on Grove Shield for Seeed Studio XIAO.

Internal Pin NumberPin Mapping
2D0
3D1
4D2
5D3
6D4
7D5
21D6
20D7
8D8
9D9
10D10
6SDA
7SCL

For example, if you want to connect a Grove module to D0 port, you need to define the pin on ESPHome as 2

Grove Compatibility List with ESPHomeโ€‹

Currently the following Grove modules are supported by ESPHome

Grove ModuleCategory
Grove - Laser PM2.5 Dust SensorGas
Grove - SEN55 All-in-one environmental sensor, NOx, PM, VOC, RH, TempGas
Grove - SEN54 All-in-one environmental sensor, PM, VOC, RH, TemperatureGas
Grove - CO2 & Temperature & Humidity Sensor (SCD30)Gas
Grove - CO2 & Temperature & Humidity Sensor - SCD41Gas
Grove - VOC and eCO2 Gas Sensor - SGP30Gas
Grove - 4 Channel 16-bit ADC (ADS1115)ADC
Grove - Time of Flight Distance Sensor(VL53L0X)Distance
Grove - Ultrasonic Distance SensorDistance
Grove - AHT20 I2C Industrial Grade Temperature and Humidity SensorEnvironmental
Grove - Temperature & Humidity Sensor V2.0 (DHT20)Environmental
Grove - Temperature & Humidity Sensor Pro (DHT22/AM2302)Environmental
Grove - Temp&Humi&Barometer Sensor (BME280)Environmental
Grove - Temperature, Humidity, Pressure and Gas Sensor for Arduino - BME680Environmental
Grove Temperature and Barometer Sensor (BMP280)Environmental
One Wire Temperature Sensor - DS18B20Environmental
Grove - Temperature & Humidity Sensor (DHT11)Environmental
Grove - I2C High Accuracy Temperature Sensor - MCP9808Environmental
Grove - Temperature & Humidity Sensor (SHT31)Environmental
Grove - Temperature&Humidity Sensor (SHT40)Environmental
Grove - High Precision Barometric Pressure Sensor (DPS310)Environmental
Grove - I2C Thermocouple Amplifier (MCP9600)Environmental
Grove - I2C Color Sensor V2Color
Grove - Digital Light Sensor - TSL2561Light
Grove - ADC for Load Cell (HX711)Weight
Grove - 12 Key Capacitive I2C Touch Sensor V3 (MPR121)Capacitive
Grove - 16-Channel PWM Driver (PCA9685)PWM
Grove - 4-Digit DisplayDisplay
Grove - OLED Display 0.66" (SSD1306)Display
Grove - RelayRelay
Grove - SPDT Relay(30A)Relay
Grove - Solid State Relay V2Relay
Grove - 2-Channel SPDT RelayRelay
Grove - PIR Motion SensorMotion
Grove - mini PIR motion sensorMotion
Grove - Digital PIR Motion Sensor(12m)Motion
Grove - ServoActuator
Grove - 8 Channel I2C Multiplexer/I2C Hub (TCA9548A)Multiplexer

Now we will select 6 Grove modules from the above table and explain how they can be connected with ESPHome and Home Assistant.

Grove - Temperature and Humidity Sensor (AHT20)โ€‹

Setup Configurationโ€‹

  • Step 2. Inside the xiao-esp32c3.yaml file that we created before, add the following at the end of the file and push it OTA to XIAO ESP32C3
i2c:
sda: 6
scl: 7

sensor:
- platform: aht10
temperature:
name: "Temperature"
humidity:
name: "Humidity"

You can learn more about the AHT10 component here. It allows you to use AHT10, AHT20 and AHT21 based sensors. Here we add the IยฒC Bus component because AHT20 communicates using I2C protocol.

Visualize on Dashboardโ€‹

  • Step 1. On the Overview page of Home Assistant, click the 3 dots and click Edit Dashboard
  • Step 2. Click + ADD CARD
  • Step 3. Select By ENTITY, type temperature and select the check box next to Temperature
  • Step 4. Repeat the same for Humidity
  • Step 5. Click CONTINUE
  • Step 6. Click ADD TO DASHBOARD

Now your Home Assistant dashboard will look like below

  • Step 7. You can also visualize sensor data as gauges. Click Gauge under BY CARD
  • Step 8. Select Temperature from the drop-down menu
  • Step 9. Click SAVE
  • Step 10. Repeat the same for Humidity

Now your dashboard will look like below

For the Grove - VOC and eCO2 Gas Sensor (SGP30) and Grove - CO2 & Temperature & Humidity Sensor (SCD41) in this wiki, you can follow a similar procedure to visualize the sensor data on the dashboard

Grove - VOC and eCO2 Gas Sensor (SGP30)โ€‹

Setup configurationโ€‹

  • Step 2. Inside the xiao-esp32c3.yaml file that we created before, add the following at the end of the file and push it OTA to XIAO ESP32C3
i2c:
sda: 6
scl: 7

sensor:
- platform: sgp30
eco2:
name: "eCO2"
accuracy_decimals: 1
tvoc:
name: "TVOC"
accuracy_decimals: 1

You can learn more about the SGP30 component here.

Grove - CO2 & Temperature & Humidity Sensor (SCD41)โ€‹

Setup configurationโ€‹

  • Step 2. Inside the xiao-esp32c3.yaml file that we created before, add the following at the end of the file and push it OTA to XIAO ESP32C3
i2c:
sda: 6
scl: 7

sensor:
- platform: scd4x
co2:
name: "CO2"
temperature:
name: "Temperature"
humidity:
name: "Humidity"

You can learn more about the SGP4x component here

Grove - Relayโ€‹

Setup configurationโ€‹

  • Step 1. Connect Grove - Relay to one of the Digital ports on the Grove Shield for Seeed Studio XIAO. Here we select D0 port
  • Step 2. Inside the xiao-esp32c3.yaml file that we created before, add the following at the end of the file and push it OTA to XIAO ESP32C3
switch:
- platform: gpio
pin: 2
name: "Relay"

You can learn more about the Relay component here

Visualize on Dashboardโ€‹

  • Step 1. Under + ADD CARD that we mentioned before, select BY ENTITY, type relay, select it and click CONTINUE
  • Step 2. Click ADD TO DASHBOARD

Now you can turn the relay ON/OFF using the toggle switch

Grove - mini PIR motion sensorโ€‹

Setup configurationโ€‹

  • Step 2. Inside the xiao-esp32c3.yaml file that we created before, add the following at the end of the file and push it OTA to XIAO ESP32C3
binary_sensor:
- platform: gpio
pin: 2
name: "PIR Sensor"
device_class: motion

You can learn more about the PIR component here

Visualize on Dashboardโ€‹

  • Step 1. Under + ADD CARD that we mentioned before, select BY ENTITY, type pir, select it and click CONTINUE
  • Step 2. Click ADD TO DASHBOARD

Now if a motion is detected, it will show as Detected

What Next?โ€‹

Congratulations, you have learned to complete the deployment of Home Assistant on LinkStar and are able to use the ESPHome plugin. For anything similar to not being able to install a Home Assistant Container with Add-on, you can use this method to install other Home Assistant plugin.

We also look forward to having you join our team of creators and bring us more useful examples!

Of course, there is more to the XIAO ESP32C3 than just support for the MR24HPCB1 in Home Assistant, and you can find more tutorials for your own use in this document.

Get your creative juices flowing!

Troubleshootingโ€‹

FAQ1: I got the following error while uploading firmware using ESPhome Web tool, how can I fix it?

A: If this prompt appears while uploading, disconnect the XIAO ESP32C3 from the PC. Then, hold the BOOT BUTTON, connect the board to your PC while holding the BOOT button, and then release it to enter bootloader mode. At this point it is sufficient to reconnect and upload the firmware again.

FAQ2: I can't install esphome flasher under Linux following the tutorial of esphome flasher?

A: When executing the following commands, you need to select your system version, otherwise an error will occur. For example, my computer is Ubuntu 22.04, then the command that should be executed is as follows.

sudo apt install python3

pip3 install -U \
-f https://extras.wxpython.org/wxPython4/extras/linux/gtk3/ubuntu-22.04/ \
wxPython

pip3 install esphomeflasher

FAQ3: I filled in the correct WiFi and password, why don't I see the IP address of the XIAO ESP32C3?

A: When you encounter this problem, please check that the XIAO ESP32C3's antenna is connected in place. If the antenna is already connected, please make sure that the XIAO is not further than 3m from the LinkStar if possible (unless you have replaced the antenna with a more powerful one). If you still do not see XIAO, you can use the esphome flasher software to check the XIAO log information and check the XIAO connection through the logs. You can re-plug the xiao to let it try to search for WiFi and connect again.

Tech Supportโ€‹

Please do not hesitate to submit the issue into our forum.


Loading Comments...