M5StickC Plus-based wifi temperature/humidity sensor for HomeAssistant using ESPHome infrastructure.
Once configured, the following entities will be available within Home Assistant:
- sensor
- Temperature (°C)
- Humidity (%)
- Battery level (%)
- Wifi RSSI (dBm)
- Uptime (s)
- binary_sensor
- Button A (front, display control)
- Button B (bottom)
- switch
- Led
M5StickC will also fetch temperature and humidity corrections from HomeAssistant to compensate for M5Stick heat leaking into ENV III Hat (see following comment/measurement data). This correction is zero-order/a simple offset as of today.
A typical application uses this device as a temperature or humidity sensor for the HA Generic Thermostat (target_sensor parameter) to control a heater/cooler/fan switch. Led can be used within HomeAssistant to indicate e.g. switch state and button B is available to switch an auxiliary equipment or HA state.
-
Install ESPHome, e.g. using docker
docker pull esphome/esphome
-
Clone this repo
git clone https://github.com/jpcornil-git/HA-M5StickC.git
-
Start ESPhome with configuration folder set to this one, e.g. using docker (replace <full path> with the actual path and, if required, adapt ttyUSB0 [on Windows, replace --device /dev/ttyUSB0 with --privileged]).
docker run --device /dev/ttyUSB0 -p 6052:6052 -v "<full path>/HA-M5StickC/configuration:/config" esphome/esphome
-
Start a web browser and navigate to http://localhost:6052/ to access ESPHome dashboard, you should see a new m5stickc_env device.
-
Edit secrets.yaml (1) and edit/add following credentials ("myOtaPassword" will be used to secure firmware update Over-The-Air/OTA):
# Your Wi-Fi SSID and password wifi_ssid: "myWifiSSID" wifi_password: "myWifiPassword" # Your OTA password ota_password: "myOtaPassword"
-
Build and install firmware on your M5StickC (2)
- Wireless update is only possible once M5StickC is on the network, i.e. after initial (wired) configuration and correct Wifi SSID/password configured.
-
Once uploaded, you should see a splash screen on the M5StickC displaying the name of the device for 3 seconds followed by a black screen (screen off by default). Cycle thru available screens using the M5/front button to select a different one:
[Off] -> [Corrected Temp/Humidity sensor] -> [Raw Temp/Humidity sensor] -> [Network parameters] -> [Off] -> ...
Corrected Temp/Humidity sensor screen
-
Edit HA configuration.yaml
Add/adapt following content to control temperature and humidity corrections (entity names, e.g. m5stickc_env_1_offset_temperature below, have to match devicename in m5stickc_env.yaml). If you have multiple M5StickC, each of them needs two such entries.
input_number: m5stickc_env_1_offset_temperature: name: Température offset unit_of_measurement: "°C" mode: box min: -5.0 max: +5.0 step: 0.1 m5stickc_env_1_offset_humidity: name: Humidity offset unit_of_measurement: "%" mode: box min: -10.0 max: +10.0 step: 0.5
-
Restart HA
You should see a new ESPHome integration.
Example of a lovelace dashboard illustrating M5StickC entities and associated temperature and humidity correction controls.
Note: When you update correction data, it will take up to 30s (update cycle) for these to become effective.
- [1] AXP192 Power Management unit (PMU) is reused from esphome-m5stickC