Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mi Smart Standing Fan 2 Lite - dmaker.fan.1c Support #33

Open
The-May opened this issue Oct 8, 2024 · 6 comments
Open

Mi Smart Standing Fan 2 Lite - dmaker.fan.1c Support #33

The-May opened this issue Oct 8, 2024 · 6 comments

Comments

@The-May
Copy link

The-May commented Oct 8, 2024

Hi I am trying to contribute with my Information/hardware to this awesome project.

Hardware is: Mi Smart Standing Fan 2 Lite:
https://home.miot-spec.com/spec?type=urn:miot-spec-v2:device:fan:0000A005:dmaker-1c:1
I managed to disassemble the fan and could find a esp on a Mainboard:

The Mainboard revision is MJFS-P12E B1-CTRL-V1.0 and seems to be assembled on 2021.04.06

See PCB Upper side:
image

ESP32 is a ESP-WROOM-02D:

image

PCB bottom side:

image

Please advise and feel free what to do next to flash esphome on it and which config might help, since im not experienced with esphome at all...also i could not find any docs on how to flash the esp32.....thx!

@ronnieSVK
Copy link

Hi @The-May !

I recently flashed the same model. However, if you are not skilled in soldering, microcontrollers and ESPHome im unsure if this is good idea.

@helgek
Copy link

helgek commented Jan 1, 2025

You don’t need to solder. I flashed more than a dozen devices using PCBite from Sensepeek. Another cheap solution is using e.g. acupuncture needles with e.g. plasticine as holder. There are also 3d printed examples of holders.

regarding flashing there are many tutorials available, e.g. check for Syssi‘s yeelight GitHub page but also the Espressif docs for the individual ESP32 versions contain helpful information.

@ronnieSVK
Copy link

Yes, you dont need to solder, if you have prepared some minilab at home with all kind of equipment with 3D printed holders, needles etc... I flashed and developed equally - dozen of devices, and i always prefer soldering. It is the quickest and most stable way to have "contact". There is no need to check for some Yeelight documentations. The question was specifically about "Mi Standing Fan 2 Lite" and all informations are listed on this page. What he needs is ESPHome config file which has some changes in comparison with not "Lite" version.

@cristianchelu
Copy link
Contributor

cristianchelu commented Jan 1, 2025

@ronnieSVK The wiki is open to edits, so if you by chance snapped any pictures while you flashed it that show what to connect where it should already be helpful to others :)

The same again for the config -- open either a PR with it or just paste it in this thread; others with a bit more knowledge of soldering can make good use of it.

As for @The-May 's original question:

I'm sorry that this device is nowhere near beginner level (hardware wise) to convert :( lemme start by saying:

Caution

If this is your first time working with electronics, or you're not 100% comfortable with this, don't do anything with this device without a friend that knows electronics present.

Because this fan is connected to mains electricity, if you solder something where you shouldn't, you can start a fire. That fire can happen days after you're done.

If you accidentally touch a component at mains level you can end up in the hospital, or worse. If it that component is a capacitor, you can be shocked even long after you unplug the device.

And definitely don't do anything to the board while it's plugged in.
We want to stay safe while enjoying our hobby.

Because this is not a joke, *** You alone are responsible for your health and safety for this project ***

For the chip:

You can find the ESP-WROOM-02D's datasheet by searching online, scroll to page 3 for the pinout.

For flashing

Also by searching "esphome flashing", you can find this guide or plenty of different tutorials, but flashing a new board still requires some patience and ingenuity.

At the very least you will require a multimeter and a soldering iron, besides the USB<->UART flasher.

I've overlaid the pinout from the schematic over your picture and attempted to figure out what pins are broken out where:
(Most of the time, but not always, the designers add through-hole connectors, or at least pads so they don't have to touch the tiny pins of the chip while they debug their design)

diagram

Practically, you only need:

  • GND, 3.3V (3V3) for power
  • RX and TX for flashing (pay attention to cross-connect, RX->TX, TX->RX)
  • and IO0 connected to a GND when you first apply 3.3V to put the chip in programming mode, which you can then remove after a few seconds.

Reallistically, you will need to use a multimeter on continuity mode to figure out where, if at all all the pins are connected to a test pad.

I'm only confident in GND and TX (by the label UART0_TXD).

I think I read RXD to the right of UART0_TXD so that might be a candidate to check with a multimeter if it's connected to the right pin on the chip.

3V3 and IO0 I don't know, good luck checking, they might be somewhere.

If you can't find a beep anywhere -- I'm sorry, the only way would be to solder, use pcbite/acupuncture needles/tools/magic to connect straight to those tiny pins on the chip - and blame the designers in the process for not making it easier.

Actual flashing

  1. Install ESPTool.py - DOCS
  2. Read the flash first and save it somehwere - DOCS
  3. Generate an ESPHome bare config for this module; besides all the other goodies, it needs to contain:
esp8266:
  board: esp_wroom_02
  1. Download the .bin file from the ESPHome dashboard and flash it with esptool DOCS.
  2. Check the readme in this project as well as other configs to generate a working one, then post it here or in a PR so people after you won't have to suffer through the entire ordeal from the start :) .

Yeah, you might feel overwhelmed by all this if this is your first project because it's not a beginner task, and that's alright.

If it's not your first, just first time with ESPHome, sorry for the warnings, but better safe than sorry.

Hope this helps.
Happy new year!

@ronnieSVK
Copy link

ronnieSVK commented Jan 1, 2025

Hi @cristianchelu !
Fantastic description !

I have only one-two pictures for my evidence, but your schema is absolutely correct !

  • RX + TX are exposed on the board, YELLOW + GREEN on the picture. (Honestly, i dont know which is which on the board, since the marks are so small. I flashed also Mi Air Purifier 4 recently, where is the situation similar. So for me it was "hit/miss" while i was watching the USB UART flasher LEDs for feedback.)
  • Since i had no problem with soldering, i wasnt searching if 3.3V is exposed (but i didnt find it by quick look) so i used the ESP PIN marked RED for "it".
  • GND is self-explanatory, on the board
  • GPIO marked GRAY is IO0, which needs to be PULLED DOWN, so again, as you marked, with GND

IMG_0966

ESPHome code i wrote (of course, feel free to edit or change it to your needs)

external_components:
  source: github://dhewg/esphome-miot@main

esphome:
  name: "add_your_device_name"
  friendly_name: "add_your_friendly_name"

esp8266:
  board: esp_wroom_02

time:
  - platform: sntp
    id: sntp_time
    timezone: Europe/Bratislava
    servers:
     - 0.pool.ntp.org
     - 1.pool.ntp.org
     - 2.pool.ntp.org

# Enable logging
logger:

# Enable Home Assistant API
api:
  encryption:
    key:
  reboot_timeout: 0s
  services:
    - service: mcu_command
      variables:
        command: string
      then:
        - lambda: 'id(miot_main).queue_command(command);'

ota:
  - platform: esphome

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  power_save_mode: none
  fast_connect: True

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Bedroom-Mi-Air-Fan-2-Lite"
    password:

captive_portal:

uart:
  tx_pin: GPIO15
  rx_pin: GPIO13
  baud_rate: 115200

miot:
  id: miot_main

switch:
  - platform: "miot"
    id: "on"
    miot_siid: 2
    miot_piid: 1
    name: "Power"
    icon: "mdi:power"
    on_turn_off:
      - lambda: |- 
          if(id(template_fan).state == true) {
            auto call = id(template_fan).turn_off();
            call.perform();
          }
    on_turn_on:
      - lambda: |- 
          if(id(template_fan).state == false) {
            auto call = id(template_fan).turn_on();
            call.perform();
          }
  - platform: "miot"
    id: "horizontal_swing"
    miot_siid: 2
    miot_piid: 3
    name: "Oscillation"
    icon: "mdi:arrow-oscillating"
    on_turn_off:
      - lambda: |-
          if (id(template_fan).oscillating == true) {
            auto call = id(template_fan).make_call();
            call.set_oscillating(false);
            call.set_preset_mode(id(mode).state.c_str());
            call.perform();
          }
    on_turn_on:
      - lambda: |-
          if (id(template_fan).oscillating == false) {
            auto call = id(template_fan).make_call();
            call.set_oscillating(true);
            call.set_preset_mode(id(mode).state.c_str());
            call.perform();
          }

  - platform: "miot"
    miot_siid: 2
    miot_piid: 12
    name: "Indicator Lights"
    icon: "mdi:lightbulb"
    entity_category: config
  - platform: "miot"
    miot_siid: 2
    miot_piid: 11
    name: "Notification Sounds"
    icon: "mdi:volume-high"
    entity_category: config
  - platform: "miot"
    miot_siid: 3
    miot_piid: 1
    name: "Child Lock"
    icon: "mdi:lock"
    entity_category: config
  
select:
  - platform: "miot"
    id: "mode"
    miot_siid: 2
    miot_piid: 7
    name: "Mode"
    icon: "mdi:leaf"
    options:
      0: "Direct Breeze"
      1: "Natural Breeze"
    on_value:
      - lambda: |-
          if(id(template_fan).preset_mode != x) {
            auto call = id(template_fan).make_call();
            call.set_preset_mode(x.c_str());
            call.perform();
          }

number:
  - platform: "miot"
    miot_siid: 2
    miot_piid: 2
    name: "Fan Level"
    icon: "mdi:fan-chevron-up"
    min_value: 1
    max_value: 3
    step: 1
  - platform: "miot"
    miot_siid: 2
    miot_piid: 10
    name: "Off Delay"
    icon: "mdi:clock-outline"
    unit_of_measurement: "min"
    device_class: duration
    min_value: 0
    max_value: 480
    step: 1

button:
  - platform: "miot"
    miot_siid: 2
    miot_aiid: 1
    name: "Toggle Power"
    icon: "mdi:power-cycle"
  - platform: "miot"
    name: "Toggle Mode"
    icon: "mdi:leaf"
    miot_siid: 4
    miot_aiid: 1
  - platform: "miot"
    name: "Toggle Speed"
    icon: "mdi:fan"
    miot_siid: 4
    miot_aiid: 2

fan:
  - platform: "template"
    id: template_fan
    name: None
    has_oscillating: true
    speed_count: 100
    preset_modes:
      - "Direct Breeze"
      - "Natural Breeze"
    restore_mode: NO_RESTORE
    on_turn_on:
      - lambda: if (id(on).state == false) id(on).turn_on();
    on_turn_off:
      - lambda: if (id(on).state == true) id(on).turn_off();
    on_oscillating_set:
      - lambda: |-
          if (id(horizontal_swing).state != x) {
            if (x == true) {
              id(horizontal_swing).turn_on();
            } else {
              id(horizontal_swing).turn_off();
            }
          }
          auto call = id(template_fan).make_call();
          call.set_preset_mode(id(mode).state.c_str());
          call.perform();

@The-May
Copy link
Author

The-May commented Jan 3, 2025

Thx alot for the color-coded instruction.
I wasnt sure which contacts to use since im an ESP-Beginner and dumping it etc is noithing I did on a regular basis.
I'll try it in the future and report.
Thx alot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants