4$ Xiaomi Temperature Sensor for Home Assistant

This article is a kind of follow-up on the one I did originally in 2019. ESPhome has improved a lot over time and now there are these 4$ Xiaomi temperature and humidity sensors that can be hacked and then work in the same way. The absolute best way to get per room temperature sensing into Home Assistant in my opinion!

Video Tutorial

The main part of this tutorial comes in the form of a video. In there I walk you through “hacking” the little 4$ modules, getting the right code into ESPhome and all surrounding subjects.

Product shopping links:

👉 New 4$ sensor (LYWSD03MMC): https://geni.us/A3KWeh
👉 “Old” Non-E-Ink Xiaomi Mijia Temp and Humi sensor (LYWSDCGQ): https://geni.us/Tr2RpJH
👉 E-ink Round (CGG1) model: https://geni.us/eJIB
👉 E-ink Bigger rectangular (LYWSD02) model: https://geni.us/JBWKR

ESP32 boards:
👉 MH-ET Live ESP32: http://geni.us/4OZdAj
👉 Wemos D32 Mini: https://geni.us/9aXV

USB power:
👉 High Quality Phone charger (very stable for ESP32, 5v 2A continuous): https://geni.us/TiSqB

USB Cable:
👉Good Micro-USB cable: https://geni.us/4Yqui9t

Shoutout:

Again a big shoutout to Aaron Christophel for creating this amazing hack and putting it all together. Check out his video and Github!

Link to Hack Creator Video: https://youtu.be/NXKzFG61lNs
Link to Hack Creator Github: https://github.com/atc1441/ATC_MiThermometer

Text Bits:

To go with the video here are the text bits mentioned in there.

The below configuration sets some settings the way I like to use them, the most important line is the “esp32_ble_tracker” which enables bluetooth advertisement tracking. Please flash the binary with this enabled using USB the first time to make sure all internal partitioning is done correctly.

substitutions:
  esphome_name: minividtemp

esphome:
  name: ${esphome_name}
  platform: ESP32
  board: mhetesp32devkit

wifi:
  ssid: !secret esphome_wifi_ssid
  password: !secret esphome_wifi_pass
  domain: .quindorian.iot

logger:
  level: debug

api:
  reboot_timeout: 60min
  password: !secret esphome_api_pass

ota:
  password: !secret esphome_ota_pass

time:
  - platform: homeassistant
  
esp32_ble_tracker:

switch:
  - platform: gpio
    name: "${esphome_name}-Onboard-LED"
    pin: 2
    inverted: True

  - platform: restart
    name: ${esphome_name}-restart
    id: restart_switch

sensor:
  - platform: uptime
    name: "${esphome_name}_Uptime Sensor"
    
  - platform: wifi_signal
    name: "${esphome_name} WiFi Signal"
    update_interval: 60s

The MAC address lines you are looking for looks something like this:

[16:33:56][D][esp32_ble_tracker:544]: Found device A4:C1:38:FA:4C:CB RSSI=-33
[16:33:59][D][esp32_ble_tracker:565]:   Address Type: PUBLIC
[16:33:59][D][esp32_ble_tracker:567]:   Name: 'ATC_FA4CCB'

One you have found the MAC address (In this case the “A4:C1:38:FA:4C:CB” part), please add the following to the bottom of the config (in the sensor section):

- platform: xiaomi_lywsd03mmc
  mac_address: A4:C1:38:FA:4C:CB
  bindkey: "05e04076be48f427f3d90e166d0fbd5e"
  temperature:
    name: "MiniVideoTemp Temperature"
  humidity:
    name: "MiniVideoTemp Humidity"
  battery_level:
    name: "MiniVideoTemp Battery Level"

*If you are using the original firmware, please change bindkey value to what you saw on webpage, if using custom firmware, just leave bindkey line as it is and you only need to change the names.

The complete configuration then looks like this:

substitutions:
  esphome_name: minividtemp

esphome:
  name: ${esphome_name}
  platform: ESP32
  board: mhetesp32devkit

wifi:
  ssid: !secret esphome_wifi_ssid
  password: !secret esphome_wifi_pass
  domain: .quindorian.iot

logger:
  level: debug

api:
  reboot_timeout: 60min
  password: !secret esphome_api_pass

ota:
  password: !secret esphome_ota_pass

time:
  - platform: homeassistant
  
esp32_ble_tracker:

switch:
  - platform: gpio
    name: "${esphome_name}-Onboard-LED"
    pin: 2
    inverted: True

  - platform: restart
    name: ${esphome_name}-restart
    id: restart_switch

sensor:
  - platform: uptime
    name: "${esphome_name}_Uptime Sensor"
    
  - platform: wifi_signal
    name: "${esphome_name} WiFi Signal"
    update_interval: 60s
    
  - platform: xiaomi_lywsd03mmc
    mac_address: A4:C1:38:FA:4C:CB
    bindkey: "05e04076be48f427f3d90e166d0fbd5e"
    temperature:
      name: "MiniVideoTemp Temperature"
    humidity:
      name: "MiniVideoTemp Humidity"
    battery_level:
      name: "MiniVideoTemp Battery Level"

Ending remarks:

Battery life for the new sensors is currently still unknown, with the custom firmware it will be directly linked to the advertising interval, so be careful with setting it too low!

Also make sure to take a look at the old video and article, if you are unsure about the steps to take and process, there is other information in there!

Other then that, happy hacking and I believe this is a very easy way to add some cheap temperature and humidity sensors to Home Assistant which can then be deployed in various areas of your home!

Leave a Reply

Your email address will not be published. Required fields are marked *