Xiaomi Smart Kettle 2 Pro with ESPHome

Hello everyone,

I recently installed ESPHome on my Xiaomi Smart Kettle 2 Pro, and I wanted to share my experience while seeking some advice.

Using this guide, the installation went smoothly and was relatively straightforward. At the moment, the ESP32 successfully connects to my Wi-Fi network when I plug the kettle into the socket. However, that’s where things currently stand.

So far, I’ve only used the basic ESPHome configuration from the guide, but I haven’t added the necessary sensors yet. I could use some help configuring those, as I’m unable to remove the circuit board due to the rotary head holding it in place.

Here’s what needs to be integrated into the configuration:

• Piezo buzzer
• Temperature sensor
• Rotary knob (with lighting and a two-digit display)
• Two sensor buttons
• Heating logic

If anyone has experience with this or could point me in the right direction, I’d greatly appreciate it!




I doubt it’s glued, so find a way to disconnect it, otherwise you are half blind.
Locate all connected hardware and identify sensors.
Observe chips onboard U1…U4 and try to identify them.
Find the ssr (or whatever switch is used) that connects mains to heating element.
Try to trace components that are connected to Esp gpios with multimeter in continuity mode…



Touch buttons can use Esp touch pins or dedicated circuit

I could already identify the following connections

Update:

Nice job, what are those U2/U4?

I don’t fully understand that yet. Over the next few days/weeks, I will try to control some components with ESPHome (of course only with 3.3V and 5V). If anyone has tips on components and control, feel free to share.

They don’t have any markings?

My current assumption, since I can’t see any markings, is

U1: AMS1117 (3V3 to 5V)
U2: I2C-Expander

substitutions:
  device_name: "xiaomi-smart-kettle-2-pro"
  friendly_name: "Xiaomi Smart Kettle 2 Pro"

esphome:
  name: ${device_name}
  friendly_name: ${friendly_name}
  comment: ''



esp32:
  board: esp32doit-devkit-v1
  framework:
    type: esp-idf # Suggest using the ESP-IDF Framework. Changing from 'arduino' to 'esp-idf' needs a cabled flash to correct partitions
    version: recommended # recommended, latest or dev

    # these just for the esp32doit-devkit-v1 and Mi S Lamp 
    sdkconfig_options:
      CONFIG_FREERTOS_UNICORE: y
    advanced:
      ignore_efuse_mac_crc: true
      ignore_efuse_custom_mac: true  #added in 2024-11 as a fix https://community.home-assistant.io/t/xiaomi-mi-led-desk-lamp-1s-error-integration/787346

logger:
  level: DEBUG

api:
  encryption:
    key: !secret api_encryption_key

ota:
  - platform: esphome
    id: ota_password
    password: !secret ota_password

safe_mode:
  
wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: ${device_name}
    password: !secret wifi_ap_password

captive_portal:

web_server:
  port: 80
  #auth:
  #  username: !secret web_server_username
  #  password: !secret web_server_password

binary_sensor:
  - platform: status
    name: Device Status
    id: device_status
  - platform: gpio
    pin: GPIO5
    name: "Touch Button - Boil - Direct"
  - platform: gpio
    pin: GPIO18
    name: "Touch Button - Boil - Controller"
  - platform: gpio
    pin: GPIO19
    name: "Touch Button - Keep Warm - Controller"
  - platform: gpio
    pin: GPIO21
    name: "Touch Button - Keep Warm - Direct"
  - platform: tm1637
    id: tm1637_binary_sensor
    name: key1-00
    tm1637_id: tm1637_display
    key: 0


time:
  - platform: homeassistant
    id: homeassistant_time


text_sensor:
  - platform: version
    name: Version
  - platform: wifi_info
    ip_address:
      name: IP Address


globals:
  - id: last_rotary_value
    type: float
    restore_value: true
    initial_value: '0'

sensor:
  - platform: uptime      # Uptime for this device
    name: Uptime
    update_interval: 60s
  - platform: wifi_signal # Wifi Strength
    name: Wifi Signal
    update_interval: 60s

  - platform: template   
    name: "Rotary Value"
    id: rotary_value_sensor
    unit_of_measurement: "°C"
    accuracy_decimals: 0
    update_interval: 60s
    lambda: |-
      return id(last_rotary_value);
  - platform: rotary_encoder
    id: rotation
    pin_a: GPIO16
    pin_b: GPIO17
    resolution: 2
    on_value:
      then:
        - lambda: |-
            float new_value = id(last_rotary_value) + (x * 5);
            new_value = std::min(100.0f, std::max(0.0f, new_value));
            id(last_rotary_value) = new_value;
            id(rotary_value_sensor).publish_state(new_value);
        - sensor.rotary_encoder.set_value:
            id: rotation
            value: 0


    # ERROR: ESP32 doesn't support ADC on this pin when Wi-Fi is configured.
#  - platform: ntc
#    sensor: resistance_sensor
#    calibration:
#      b_constant: 3950
#      reference_temperature: 25°C
#      reference_resistance: 10kOhm
#    name: "NTC Temperature"
#  - platform: resistance
#    id: resistance_sensor
#    sensor: adc_sensor
#    configuration: DOWNSTREAM
#    reference_voltage: 3.3V
#    resistor: 10kOhm
#    name: "Resistance Sensor"
#  - platform: adc
#    id: adc_sensor
#    pin: GPIO12
#    attenuation: 6db
#    update_interval: 5s
#    samples: 10


output:
  - platform: ledc
    pin: GPIO4 
    id: buzzer_output

number:
  - platform: template
    name: "Buzzer Control"
    id: buzzer_slider
    min_value: 0
    max_value: 100
    step: 1
    unit_of_measurement: "%"
    optimistic: true
    set_action:
      then:
        - if:
            condition:
              lambda: 'return x > 0;'
            then:
              - output.turn_on: buzzer_output
              - output.ledc.set_frequency:
                  id: buzzer_output
                  frequency: 1000Hz
              - output.set_level:
                  id: buzzer_output
                  level: !lambda "return x / 100.0;"
            else:
              - output.turn_off: buzzer_output

switch:
  - platform: gpio
    name: "Switch Power"
    pin: GPIO22 
    id: switch_power

  - platform: gpio
    name: "Switch Unkown"
    pin: GPIO23 
    id: switch_unkown
  - platform: gpio
    name: "Switch Display"
    pin: GPIO33
    id: switch_display


#https://github.com/ssieb/esphome_components/tree/master/components/ht16k33_alpha

display:
    platform: tm1637
    id: tm1637_display
    clk_pin: GPIO26
    dio_pin: GPIO27
    #inverted: true
    update_interval: 10s
    intensity: 3
    length: 2
    lambda: |-
      // Print 0 at position 0 (left)
      it.print("0");
      // Result: "0   "

#      // Print 1 at position 1 (second character)
#      it.print(1, "1");
#      // Result: "01  "
#
#      // it.printf(0, "%02d", (int)id(last_rotary_value));

Voltage regulator is AZ1117EH

What would be connected to I2C-expander? Generally expander is only needed if you have multiple I2C devices that are identic (all have same address).

It was neither :slight_smile:
I got the buzzer, rotary and four switches (I don’t know exactly what they are for) to work.

the two 8-pin ICs are a power management chip and a touch controller (see picture, the designation is there).

Do you have any idea how I could control the other components in ESP?
I did an i2c scan of the touch controller and nothing was found.

which ones?

  • There are 5 transistors to switch things, so far I’ve only really controlled one (Buzzer) with ESPHome. Another one is for the big relay, the others are not quite clear to me yet.
  • How could I control the touch controller?
  • How could I control the OLED display?
  • How could the thermomenter be controlled?

Those are simple. Just follow the trace from relay transistors base to Esp. Use gpio switch with option inverted.

Touch controller is trickier, if you are lucky it’s just high/low output on those pins that go to Esp.
If not… :slightly_frowning_face:

For display try with SSD1306 OLED Display component (I2C).

If thermometer is NTC (you wrote it has only two wires), you use ADC component.

Edit: no optocoupler so relay switch is not inverted

The touch buttons are now working.
I was also able to get the display to light up, but it is not an oled display but a 7-segment display (something like a TM1637).
So far the display just lights up, I can’t control the segments yet.

I still have problems with the following things:

  • The thermostat (GPIO12), I have tried the following but I get an error message when compiling.
    # ERROR: ESP32 doesn't support ADC on this pin when Wi-Fi is configured.
#  - platform: ntc
#    sensor: resistance_sensor
#    calibration:
#      b_constant: 3950
#      reference_temperature: 25°C
#      reference_resistance: 10kOhm
#    name: "NTC Temperature"
#  - platform: resistance
#    id: resistance_sensor
#    sensor: adc_sensor
#    configuration: DOWNSTREAM
#    reference_voltage: 3.3V
#    resistor: 10kOhm
#    name: "Resistance Sensor"
#  - platform: adc
#    id: adc_sensor
#    pin: GPIO12
#    attenuation: 6db
#    update_interval: 5s
#    samples: 10

The current esphome config is above.

If you only set plain adc_sensor with attenuation auto, what readings you get ?

Anyway the whole setup is very strange, GPIO12 is strapping pin, also it’s ADC2 pin and that has conflict with wifi. Wouldn’t be my first choice to use it for analog readings. Also, based your tracing it’s connected through Q5… You need to trace all the circuit left from Q5.

Based on your tracing relay is triggered by Gpio22 through Q2. That is clear circuit.
But what is that big boy with heat sink doing? It’s connected to Gpio23 through Q3 and I doubt that the two outer legs are connected to the resistor like you traced. And where is the middle leg going?? I see physical separation on PCB, could be triac, but what is it controlling if heating element is switched by relay?

Edit:
I’m quite sure NTC is connected to ADC1 pin. Can you trace the pad “NTC” to some upper left gpio, 32 for example…?

I’ll have a look next week, this picture is the current status

The large relay switches 230v on and off, the triac somehow controls the current for the heating element (keep warm function), therefore controllable.
Or it is responsible for the conversion from 230v to 5v, but then why is it controllable?