🌐 VI | EN

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

Nghia Phan
Nghia Phan
🌐 Bản tiếng Việt Technical Guide Views

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.
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: 4MBesp32:  board: esp32-c3-devkitm-1  framework:    type: esp-idf    sdkconfig_options:      CONFIG_BT_BLE_42_FEATURES_SUPPORTED: y      CONFIG_BT_BLE_50_FEATURES_SUPPORTED: nlogger:  level: INFOota:  - platform: esphome    password: "******"wifi:  ssid: "WIFI SSID"  password: "password"mqtt:  broker: "192.168.0.4"  username: "username"  password: "password"  discovery: false  discover_ip: falseesp32_ble_tracker:  scan_parameters:    active: falsesensor:  - 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:lywsd03mmclabel: LYWSD03MMC SensorsthingTypeUID: mqtt:topicconfiguration: {}bridgeUID: mqtt:broker:17653025f5channels:  - 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

Comments & Discussion

Share your thoughts, ask questions and feedback

Markdown & QQ Emoji
Loading comments...