pvvx / ATC_MiThermometer

Custom firmware for the Xiaomi Thermometers and Telink Flasher
https://github.com/pvvx/pvvx.github.io/tree/master/ATC_MiThermometer
Other
2.75k stars 196 forks source link

MJWSD05MMC features questions #322

Open erich74 opened 1 year ago

erich74 commented 1 year ago

First off I would really like to thank you for your work. I have flashed my MJWSD05MMC with your latest 4.3 beta fw

I have few questions though:

  1. In you readme page it is stated that it is possible to cycle the screen with different values like display time, then temperature etc... I do not see this option for the MJWSD05MMC , is it possible, or not (yet) implemented?
  2. Is there a way to permanently display the battery icon (and/or percent) at the top of the display)? I do not see any such option, looks like the icon is displayed only when the main screen is displaying battery (% or v)
  3. after flashing the top button is disabled, do you think it could be possible to re enable it in order for instance to scroll between the various screens (main display being time, temp, hum...)

Thanks a lot! Eric

pvvx commented 1 year ago
  1. Auto-switching of screens is not provided for MJWSD05MMC.
  2. The battery icon does not contain gradations of the charge level.
  3. The upper button enables connection by short pressing, and switching screen types by long pressing. Paragraph 3 replaces paragraph 1. MJWSD05MMC has a display of all values on one screen and there is no point in auto-switching. You can use the button to select which values will be displayed in the main line.

The bottom button works as a "Switch" in Home Assistant...

erich74 commented 1 year ago

Thank you very much for your answer:

  1. Ok no problem
  2. Ok I did not notice that, then I agree there's no point displaying it
  3. Thanks! I completely missed the long press and sorry I meant to say main value displayed, not auto-switching (well I meant to say auto switching the main value displayed but now I understand I can do it by long pressing the top button ;) )

Would you please mind elaborating a little bit how the button button can be used as a switch in HA? FYI I am integrating the MJWSD05MMC with OpenMQTTGateway BLE gateway based on ESP32. I am retrieving the data from MQTT to HA. Here is a typical advertisement I am receiving, how would the buttom button should be advertised?:

{"id":"A4:C1:38:DF:DE:2F","mac_type":0,"adv_type":0,"name":"BTH_DFDE2F","rssi":-46,"servicedata":"2fdedf38c1a4f4088711410c64bc05","servicedatauuid":"0x181a","brand":"Xiaomi","model":"LYWSD03MMC","model_id":"LYWSD03MMC_PVVX","type":"THB","tempc":22.92,"tempf":73.256,"hum":44.87,"batt":100,"volt":3.137}

pvvx commented 1 year ago

image

image image

The time of arrival of the message from the moment of pressing or releasing the button is 5 ms. Then there are 3 repeats of the transmission after 50 ms. ESP Home is a brake and is not suitable for such applications (lot of gaps when receiving BLE packets). ESP Home on ESP32 is not recommended for use.

erich74 commented 1 year ago

Thanks for the detailed explanation. Please note that I am not using ESP Home but the openmqttgateway project (https://docs.openmqttgateway.com/).

pvvx commented 1 year ago

Thanks for the detailed explanation. Please note that I am not using ESP Home but the openmqttgateway project (https://docs.openmqttgateway.com/).

I didn't find BLE version 5.0+ there. For ESP 32 chip - Bluetooth 4.2 max ESP32-C3 - Bluetooth 5.0 is specified, but there are no implementations.

erich74 commented 1 year ago

Yes this is BLE 4.2 (I am using a regular ESP32 chip). This is not an issue for reading temp & hum as I don't need to have a high refresh rate.

For the switch this might be a different story but in any case, I changed RS Mode to "switch" but it is not advertised for what I see in my MQTT client:

{"id":"A4:C1:38:DF:DE:2F","mac_type":0,"adv_type":0,"rssi":-45,"servicedata":"2fdedf38c1a4d009b510430c648805","servicedatauuid":"0x181a","brand":"Xiaomi","model":"LYWSD03MMC","model_id":"LYWSD03MMC_PVVX","type":"THB","tempc":25.12,"tempf":77.216,"hum":42.77,"batt":100,"volt":3.139}

pvvx commented 1 year ago

The "BTHome v1" protocol is used to transmit events 0x181C - 16-bit UUID Service 0x181C BTHome v1, no security 0x181E - 16-bit UUID Service 0x181E BTHome v1, security enable Opening/Closed, Opening counter

Invert RS event - Swaps "Opening"<->"Closed"

erich74 commented 1 year ago

Ok I am using your custom advertisement method and not BTHome so this should be the reason?

pvvx commented 1 year ago

Other protocols/formats do not contain "events". There are events only in Mijia and BT Home. The data transmission on the receiving side uses several accepted values and is rounded over a period, and "events" are perceived and processed immediately upon receipt. "Events" have a different priority and processing principle.

If you pressed a button and, for example, the light bulb did not turn on for 200 ms, then anyone starts looking for a hammer for this button. As a result, any action that does not display execution within 200 ms is uncomfortable for a person and causes various inappropriate reactions.

erich74 commented 1 year ago

ok understood, for whatever reason BTHome protocol is not working on my ESP32 with the OMG firmware (I do not get the encrypted data like temp and hum) , therefore I will stick to your advertising method and will not use Events (which is not a big deal, this was just a nice to have).

pvvx commented 1 year ago

Pressing and holding two buttons for a long time (more than 20 seconds) on the MJWSD05MMC resets to the default settings.

erich74 commented 1 year ago

ok good to know, thanks a lot for your great work and support!

pvvx commented 1 year ago

On all thermometers with a button, you can assign different events. On LYWSD03MMC, a revision is required - the installation of a reed switch. Then it turns into a door or window sensor. As well as the counter. There is no "Connect" assignment option for MJWSD05MMC, since it was originally assigned to another button.

The "Connect" button is necessary to connect to the thermometer in the explorer. The WEB bluetooth API does not yet support scanning BT 5.0+ devices and devices with long advertising periods. (But the connection itself in Android supports with any BLE devices, including BT5.3. Problems arise due to the introduction of erroneous and malicious fixes for BLE in Linux since 2016. Since the publication of BT 5.0 with LE Long Range options and periodic BLE advertising. So that people could not use BLE for long distances and limit the operation of battery power - so that batteries were changed more often.)