atc1441 / ATC_MiThermometer

Custom firmware for the Xiaomi Thermometer LYWSD03MMC and Telink Flasher via USB to Serial converter
2.78k stars 466 forks source link

Advertising interval not working? #249

Open JGeeforce opened 2 years ago

JGeeforce commented 2 years ago

This weekend I flashed 2 sensors, this went very smooth. Thanks for the tools and information. I want to use them to get rid of my old 433MHz temp/humidity sensor.

I installed an ESP32 and left it running this weekend in Home Assistant. All seems to work fine, but:

  1. I configured the sensors with advertising intervals of 1 and the other 5 minutes. But when I look in HA at the last changed and last updated information, I see 1 hour/1hour for example. For the battery of one of them, I even see 9 hours ago. I would expect that at least the last updated part should be 1min or 5min. To compare this, the 433MHz sensor updates every 60 seconds, and that is indeed what I see in HA. (I clicked the 1 and 5 min button, looked at the logs and saved the config. LCD showed STO).

  2. If I take out the battery from a Xiaomi device, this is never seen in HA. After 2 hours, the status in HA is last seen/last changed 2 hours. How can this be monitored?

JGeeforce commented 2 years ago

After my message, I set the update interval to 1 minute (again, just to be sure). And watched the update intervals. Nice to have the sun shining into my house, to I can place the sensor on different places to test. Right now the sensor says 20.0, but in HA the temp is 20,2 and that data is 16 minutes old. So this sensor is not updating every minute. And as i want to use this one for the humidity in the bathroom, I need the 1 minute interval, to control a fan.

Protoncek commented 2 years ago

What do you run in esp32? Esphome, tasmota or any other fw?

JGeeforce commented 2 years ago

EspHome. Directly from Home Assistant interface.

This is in the file: esp32: board: esp-wrover-kit framework: type: arduino

And I am using this board: https://www.az-delivery.de/nl/products/esp32-developmentboard

But when I watch the logs realtime, I don't see the sensor every minute. So don't think the board is the problem.

Protoncek commented 2 years ago

Switch to tasmota. I’ve had esphome with 8 sensors and interval was pretty random. After esp32 reboot it could take up to 5 minutes (sometimes even more) to get first reading in HA, while with tasmota all readings come in the rane of seconds after restart and are in fact published every 60 seconds (or more frequent if you change interval). Supposely esphome (basically arduino, if i’m correct) has very buggy BTdrivers. Just install tasmota32 for bluetooth, set up MQTT on HA and you will be happy user…

JGeeforce commented 2 years ago

Hmm ok. I need a little help then! Just googled a bit, have to download a tosmata32 bin file, but how to flash the ESP board? And is the programming the same after that?

Update: Found this site: https://tasmota.github.io/install/ and I guess I have to select tasmota32 Bluetooh.

Protoncek commented 2 years ago

Yes, choose tasmota32 bluetooth. You can update via esphome’s website (enable website and update via OTA). After reboot you’ll have to connect to tasmota’s wifi (192.168.4.1] and set your wifi data. After you get into tasmota’s webpage just enable BT and tasmota will discover your xiaomi. then in HA install tasmota integration and set up mqtt sensors.