xiaomi-mijia-bluetooth-firmware icon indicating copy to clipboard operation
xiaomi-mijia-bluetooth-firmware copied to clipboard

Custom firmware for the Xiaomi Thermometers and Telink Flasher via USB to Serial converter

ATC_MiThermometer & MHO-C401

Initial forked from https://github.com/atc1441/ATC_MiThermometer

(Thanks @atc1441 for initial parsing and js code for OTA)

LYWSD03MMC Custom Firmware Version 2.1p

MHO-C401 Custom Firmware Version 2.1p

LYWSD03MMC Original Firmware v1.0.0_0106

MHO-C401 Original Firmware v1.0.0_0010

OTA and Custom Setup

TelinkMiFlasher.html - OTA and customize, auto-download files new firmware

History Firmware versions:

1.2 Bind, Set Pin-code, Support MHO-C401
1.3 Get/Set comfort parameters
1.4 Get/Set device name, Get/Set MAC
1.5 Add Standard Device Information Characteristics
1.6 Fix alternation of Advertising in mi mode
1.7 Authorization and encryption in permissions to access GAP ATT attributes, if pin code is enabled
1.8 Time display (instead of a blinking smile)
1.9 Recording measurements to flash memory (cyclic buffer for 19632 measurements)
2.0 Recording measurements with averaging to flash memory
2.1 Periodic display refresh for MHO-C401, 'Erase mi-keys' option to return to original firmware

Average consumption:

  • LYWSD03MMC - Default settings (Advertising interval of 2.5 seconds, the measurement interval 10 sec):

  • Advertisement: 15..20 uA 3.3V (CR2032 over 6 months)

  • Connection: 14..25 uA 3.3V (CR2032 over 6 months)

  • MHO-C401 - Default settings (Advertising interval of 2.5 seconds, the measurement interval 20 sec):

  • Advertisement: 12..30 uA 3.3V (depends on the amount of temperature or humidity changes over time to display)

  • Connection: 15..30 uA 3.3V (depends on the amount of temperature or humidity changes over time to display)

Advertising in 4 formats:

  1. UUID 0x181A - size 16: atc1441 format

  2. UUID 0x181A - size 19: Custom format (all data little-endian):

uint8_t     size;   // = 19
uint8_t     uid;    // = 0x16, 16-bit UUID
uint16_t    UUID;   // = 0x181A, GATT Service 0x181A Environmental Sensing
uint8_t     MAC[6]; // [0] - lo, .. [6] - hi digits
int16_t     temperature;    // x 0.01 degree
uint16_t    humidity;       // x 0.01 %
uint16_t    battery_mv;     // mV
uint8_t     battery_level;  // 0..100 %
uint8_t     counter;        // measurement count
uint8_t     flags;  // GPIO_TRG pin (marking "reset" on circuit board) flags: 
                    // bit0: GPIO_TRG pin input value (real level)
                    // bit1: GPIO_TRG pin output value (pull Up/Down)
                    // bit2: Output GPIO_TRG pin is controlled according to the set parameters
                    // bit3: Temperature trigger event
                    // bit4: Humidity trigger event
  1. UUID 0xFE95 - 0x0A: Xiaomi - battery charge level 0..100%, battery voltage in mV

  2. UUID 0xFE95 - 0x0D: Xiaomi - temperature x0.1C, humidity x0.1%

  • Configuring mode of transferring everything in turn

In Connection mode:

  • Primary Service - Environmental Sensing Service (0x181A):
  • Characteristic UUID 0x2A1F - Notify temperature x0.1C
  • Characteristic UUID 0x2A6E - Notify temperature x0.01C
  • Characteristic UUID 0x2A6F - Notify about humidity x0.01%
  • Primary Service - Battery Service (0x180F):
  • Characteristic UUID 0x2A19 - Notify the battery charge level 0..99%
  • Primary Service (0x1F10):
  • Characteristic UUID 0x1F1F - Notify, frame id 0x33 (configuring or making a request): temperature x0.01C, humidity x0.01%, battery charge level 0..100%, battery voltage in mV, GPIO-pin flags and triggers.

Reading Measurements from Flash

GraphMemo.html

FlashData

Reading Measurements in Connected Mode

GraphAtc.html GraphAtc1.html GraphAtc2.html DevPoint.html

GraphAtc_html

Reading Measurements in Advertising Mode (experimental web platform features)

Advertising.html

Temperature or humidity trigger on GPIO PA5 (label on the "reset" pin)

trg_menu

Hysteresis:

  • =0 off,
  • if less than zero - activation on decrease,
  • if more than zero - activation on excess

Setting the pin to "1" or "0" works if both hysteresis are set to zero (TRG off).

OnOff

Interface for receiving and displaying data on the LCD.

  • LCD shows:
  • Big number: -99.5..1999.5
  • Small number: -9..99
  • Smiley, battery, degrees
  • Setting the display time limit in sec

ShowData

The USB-COM adapter writes the firmware in explorer. Web version.

  • Connect only TX-SWS and GND wires.

USBCOMFlashTx.html

USBCOMFlashTxHtml

Sample show LCD

Display on LCD in a loop: (YouTube video)

(Battery and clock display are enabled in the settings. The rest of the settings in default.)

  1. Temperature and humidity
  2. Temperature and % of battery
  3. Temperature and humidity
  4. Hours and minutes

The video contains 2 cycles.

Chipset:

  • TLSR8251F512ET24 (TLSR8258 in 24-pin TQFN). SoC: TC32 32-bit MCU 48Mhz, 64 KiB SRAM, 512 KiB Flash (GD25LE40C), Bluetooth 5.0: Mesh, 6LoWPAN, Zigbee, RF4CE, HomeKit, Long Range, Operating temperature: -40°C to +85°C, Power supply: 1.8V to 3.6V.
  • SHTV3 sensor. Measurement range: Temperature -40°C to +125°C, Humidity 0 to 100 %RH. Power supply: 1.8V to 3.6V
  • IST3055NA0 LCD controller

LYWSD03MMC BoardPinout

TabPins

Building firmware:

  1. Go to wiki.telink-semi.cn and getting IDE for TLSR8 Chips.
  2. Clone https://github.com/Ai-Thinker-Open/Telink_825X_SDK
  3. Install IDE and export the 'ATC_MiThermometer' project.
  4. Change 'Linked resource' and 'C/C++ Build/Build command'. Compile.

Telink Linux Tool Chain 2020-06-26

MHO-C401 Info

Build Telink EVK on E104-BT10-G/N module (TLSR8269)

Alternative programmer TLSR SWire on module TB-04/03F or E104-BT10

Additional information on the format Advertising for Xiaomi LYWSD03MMC

Reading and recovering Mi-Home keys

HTML files

LYWSD03MMC Forum link (russian)

MHO-C401 Forum link (russian)

CJMCU-2557 BQ25570

CJMCU-2557