AIoT.IO.VN
AIoT.IO.VN
SmartHome SERIES
🌐 VI • EN

[OpenHAB] Xiaomi LYWSD03MMC Temperature and Humidity Sensor with ESPHome on ESP32-C3

Ng Nghia Phan • • ⚡ 3 min read • -- views • --
VI EN
[OpenHAB] Xiaomi LYWSD03MMC Temperature and Humidity Sensor with ESPHome on ESP32-C3
TABLE OF CONTENTS (Nhấn để xem)

Requirements

  • OpenHAB version: 4.3.3
  • The MQTT binding is installed.
  • LYWSD03MMC sensors — see Shopee . Flash them with the ATC_MiThermometer custom firmware (guide).
  • An ESP32 or ESP32-C3 SuperMini. For an ESP32-C3 SuperMini, a model with an antenna is recommended (see Shopee).

Build with ESPHome

  • See the ESPHome project here.
  • Install ESPHome on your PC using this guide.
  • The following configuration sends data to the MQTT broker.
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
esphome:
  name: lywsd03mmc-mqtt
  friendly_name: LYWSD03MMC to MQTT
  min_version: 2025.3.2
  name_add_mac_suffix: true
  platformio_options:
    board_build.f_flash: 40000000L
    board_build.flash_mode: dio
    board_build.flash_size: 4MB

esp32:
  board: esp32-c3-devkitm-1
  framework:
    type: esp-idf
    sdkconfig_options:
      CONFIG_BT_BLE_42_FEATURES_SUPPORTED: y
      CONFIG_BT_BLE_50_FEATURES_SUPPORTED: n

logger:
  level: INFO

ota:
  - platform: esphome
    password: "******"

wifi:
  ssid: "WIFI SSID"
  password: "password"

mqtt:
  broker: "192.168.0.4"
  username: "username"
  password: "password"
  discovery: false
  discover_ip: false

esp32_ble_tracker:
  scan_parameters:
    active: false

sensor:

  - platform: ble_rssi
    mac_address: aa:aa:aa:aa:aa:aa
    name: "pNgu BLE Thermometer RSSI"

    - platform: ble_rssi
    mac_address: bb:bb:bb:bb:bb:bb
    name: "pKhach BLE Thermometer RSSI"

  - platform: atc_mithermometer
    mac_address: "aa:aa:aa:aa:aa:aa"
    temperature:
      name: "pNgu Temperature"
    humidity:
      name: "pNgu Humidity"
    battery_level:
      name: "pNgu Battery Level"

  - platform: atc_mithermometer
    mac_address: "bb:bb:bb:bb:bb:bb"
    temperature:
      name: "pKhach Temperature"
    humidity:
      name: "pKhach Humidity"
    battery_level:
      name: "pKhach Battery Level"

  - platform: wifi_signal
    name: "WiFi Signal dB"
    id: wifi_signal_db
    update_interval: 300s

  - platform: copy
    source_id: wifi_signal_db
    name: "WiFi Signal Percent"
    filters:
      - lambda: return min(max(2 * (x + 100.0), 0.0), 100.0);
    unit_of_measurement: "Signal %"
  • Line 24 configures the OTA update password.
  • Lines 27-28 configure Wi-Fi.
  • Lines 31-33 configure the MQTT broker.
  • Lines 44, 48, 52, and 61 contain the sensor Bluetooth MAC addresses.

Check the MQTT broker to confirm that it has received the sensor data.

Configure the Things in OpenHAB

UID: mqtt:topic:17653025f5:lywsd03mmc
label: LYWSD03MMC Sensors
thingTypeUID: mqtt:topic
configuration: {}
bridgeUID: mqtt:broker:17653025f5
channels:
  - id: pKhach_Temperature
    channelTypeUID: mqtt:number
    label: pKhach Temperature
    description: ""
    configuration:
      stateTopic: lywsd03mmc-mqtt-00b368/sensor/pkhach_temperature/state
  - id: pKhach_Humidity
    channelTypeUID: mqtt:number
    label: pKhach Humidity
    description: ""
    configuration:
      stateTopic: lywsd03mmc-mqtt-00b368/sensor/pkhach_humidity/state
  - id: pKhach_Battery_Level
    channelTypeUID: mqtt:number
    label: pKhach Battery Level
    configuration:
      stateTopic: lywsd03mmc-mqtt-00b368/sensor/pkhach_battery_level/state
  - id: pNgu_Temperature
    channelTypeUID: mqtt:number
    label: pNgu Temperature
    configuration:
      stateTopic: lywsd03mmc-mqtt-00b368/sensor/pngu_temperature/state
  - id: pNgu_Humidity
    channelTypeUID: mqtt:number
    label: pNgu Humidity
    configuration:
      stateTopic: lywsd03mmc-mqtt-00b368/sensor/pngu_humidity/state
  - id: pNgu_Battery_Level
    channelTypeUID: mqtt:number
    label: pNgu Battery Level
    configuration:
      stateTopic: lywsd03mmc-mqtt-00b368/sensor/pngu_battery_level/state
  - id: pKhach_BLE_RSSI
    channelTypeUID: mqtt:number
    label: pKhach BLE RSSI
    configuration:
      stateTopic: lywsd03mmc-mqtt-00b368/sensor/pkhach_ble_thermometer_rssi/state
  - id: pNgu_BLE_RSSI
    channelTypeUID: mqtt:number
    label: pNgu BLE RSSI
    configuration:
      stateTopic: lywsd03mmc-mqtt-00b368/sensor/pkhach_ble_thermometer_rssi/state
  - id: LYWSD03MMC_WIFI_Signal_Level_dB
    channelTypeUID: mqtt:number
    label: LYWSD03MMC Sensors WIFI Signal Level dBm
    configuration:
      stateTopic: lywsd03mmc-mqtt-00b368/sensor/wifi_signal_db/state
  - id: LYWSD03MMC_WIFI_Signal_Level_Percent
    channelTypeUID: mqtt:number
    label: LYWSD03MMC Sensors WIFI Signal Level Percent
    configuration:
      stateTopic: lywsd03mmc-mqtt-00b368/sensor/wifi_signal_percent/state
  - id: LYWSD03MMC_Sensors_Status
    channelTypeUID: mqtt:string
    label: LYWSD03MMC Sensors Status
    configuration:
      stateTopic: lywsd03mmc-mqtt/status
TAGS: #openhab
Series •

SmartHome

4 Tập
  1. [OpenHAB] Share a Vietnamese Lunar Calendar Script for OpenHAB
  2. [OpenHAB] Xiaomi LYWSD03MMC Temperature and Humidity Sensor with ESPHome on ESP32-C3 Reading
  3. [OpenHAB] Energy Meter with PZEM004T and ESPHome on ESP32-C3
  4. [OpenHAB] Share a Remote-Control Widget for LG WebOS TV

Discussion & Feedback 0

Share your questions, feedback or insights with the community