Created Xiaomi Mi Desk Lamp (markdown)

Gabor Simon 2019-02-17 14:54:08 +04:00
parent 579198450f
commit 36d1d6d187
1 changed files with 95 additions and 0 deletions

95
Xiaomi-Mi-Desk-Lamp.md Normal file

@ -0,0 +1,95 @@
***Supported in Development since 2019-01-15***
Mi Desk Lamp is a cold+warm white led lamp, which has a rotary knob that also acts as a push-button:
- pushing it turns the lamp on/off
- rotating it controls the brightness
- rotating it while pushed controls the color temperature
At the bottom of the lamp stand there is also a 'Reset' button, which can be pressed by a hairpin/toothpick/etc only.
[Manufacturer Link](https://www.mi.com/global/smartlamp/)
![Device image here](https://u01.appmifile.com/images/2018/03/07/7aa83e74-3fe4-4445-80cf-2bf2201bfffe.jpg)
## Configuration
Tasmota supports it directly as `Module "Mi Desk Lamp"`.
To configure it as `Generic`, here is the GPIO assignment:
- GPIO02: Button (`GPIO_KEY1`)
- GPIO04: Cold White (`GPIO_PWM1`)
- GPIO05: Warm White (`GPIO_PWM2`)
- GPIO12: Rotary switch A pin (`GPIO_ROT_A`)
- GPIO13: Rotary switch B pin (`GPIO_ROT_B`)
# Flashing
This lamp is based on a YeeLight LXU 1.7 module, that contains:
- an ESP8266
- **2 MB** flash
## Disassembly
First of all, remove the knob by pushing some soft and flat tool underneath it and gently pry away from the stand.
Then remove the bottom of the stand, held by 3 screws underneath the rubber strips:
![Feel around the rubber strips for depressions, the screws are underneath](https://github.com/gsimon75/Tasmota_MiDeskLamp_Notes/raw/master/00_remove_bottom.jpg)
Underneath you find a small board for the power input and the reset button, and the controller board:
![White PCB, 3 wires from the power board, 3 wires to the LEDs, and a Yeelight module underneath it](https://github.com/gsimon75/Tasmota_MiDeskLamp_Notes/raw/master/01_controller_board_bottom.jpg)
The test points (8 vertical, 2 horizontal) are connected to the module pins 7..14 and 17..18 (see below).
As GPIO0 is not among them, they aren't enough for flashing, so the board must be removed anyway.
NOTE: You need to remove the knob before you can remove this controller board.
The controller board contains
- a 3.3V converter on the side of the white power wires
- two LED drivers on the side of the red/blue/black LED wires
- the rotary button
- the Yeelight module
![The controller board](https://github.com/gsimon75/Tasmota_MiDeskLamp_Notes/raw/master/02_controller_board_top.jpg)
## Pinout
![Pinout image](https://github.com/gsimon75/Tasmota_MiDeskLamp_Notes/raw/master/03_controller_board_pinout.jpg)
- Pin 1: ADC (N.C.)
- Pin 2: GPIO15 (N.C.)
- Pin 3: GND
- Pin 4: GPIO0
- Pin 5: GND
- Pin 6: GND
- Pin 7: GND
- Pin 8: Vcc (3.3V)
- Pin 9: GPIO14 (Reset button)
- Pin 10: GPIO2 (Rotary button)
- Pin 11: GPIO13 (Rotary B)
- Pin 12: GPIO12 (Rotary A)
- Pin 13: GPIO4 (Cold white)
- Pin 14: GPIO5 (Warm white)
- Pin 15: GND
- Pin 16: GND
- Pin 17: RxD (N.C.)
- Pin 18: TxD (N.C.)
- Pin 19: GND (N.C.)
- Pin 20: GND (N.C.)
Three pins (ADC, GPIO0 and GPIO15) are not used by the lamp, they are available for hacking :).
## Procedure
For serial flashing we need 2 power wires (GND, Vcc), 2 serial wires (RxD, TxD) and the boot mode button (GPIO0):
![Wiring image](https://github.com/gsimon75/Tasmota_MiDeskLamp_Notes/raw/master/04_controller_board_wired.jpg)
As there is plenty of free space in the lamp stand, I left the wires long enough to reach some empty area and soldered solo pin head sockets on them. This way they will be available if/when I decide to add something on those 3 extra pins :).
The rest of the serial flashing process is the usual, but if you want to make a backup of the original firmware, keep in mind that the flash size is **2 MBs**.
A bonus feature for debugging/logging: The lamp has an external DC12V power supply, so there is no shock hazard. Nonetheless, accidental 12V can still cause damage to a 3.3V serial converter, so be cautious if you do serial logging on a live lamp.