Home Asssistant Xiaomi Mijia LYWSD03MMC Temperature and Humidity Sensor Tutorial September 2022

Hi @n1md4 yes, same experience… but I didn’t mind waiting.

I configured the sensor integration in HA, then about 20 minutes later HA popped up with a message, I entered the encryption key, then an hour or two later all the sensors were working.

No idea why it works that way, but if retaining the manufacturer firmware means waiting a bit of time then I dont mind. Not saying there’s anything wrong with the custom firmware, but I have been taught in my line of work to question such code sources. Mind you, some original codes have vulnerabilities :stuck_out_tongue:

I am currently working out how far away from the BLE proxy the sensor can be and still work. Seems to be a reasonable distance which surprised me.

I had a spare sensor which I put in the fridge, surprised it worked! :slight_smile:

It would be interesting to move sensors to an area that’s a lot colder or warmer to see if it updates more regularly. With the custom firmware it updates every x minutes or when the temperature changes by a certain threshold.

I have a Bluetooth sensor in the fridge which works fine, given I have the power turned up and a Bluetooth receiver with an antenna. The 433MHz sensors I have that aren’t compatible with HA are more reliable, but both works

The custom firmware extends the battery life, allows you to customize the comfort range, change the info on the screen, customize the reporting time and a whole lot more. The battery life alone is worth it, but also no need to deal with keys. Not to mention you can have 5 of them done in the 20 minutes you waited for the HA message to pop up, and have your whole house done in the hour or two it took to get the first update from your first sensor.

1 Like

I do experience frequent sensor disconnects (data becomes unavailable - rebooting the host fixes the issue), and wouldn’t know what to pin that on.

My setup is RPI3 → BalenaOS → Home Assistant Container → Bluetooth integration → BTHome sensor integration.

I guess my issue is due to the layers for Bluetooth, which I have read many issues about. I am contemplating using ESP BLE trackers, as my other ESPhome integrations have been rock solid.

To rule out any issue with the sensor, and regardless of setup, what experiences have other had with connectivity?

Once I put in a Bluetooth receiver with an antenna (Amazon link, tutorial link) it’s been solid. It just works. Raspberry Pi 4, Xiaomi bluetooth sensors.

Thanks, good to know. Would need a UK equivalent.

The HA Bluetooth compatibility page says quite a few ZEXMTE adapters are compatible. There are some on Amazon UK. Amazon doesn’t list model numbers anywhere I can see, so you might need to check their website for that. There are other brands listed / available as well.

If you manage to find one, please post a link so I can add it to the first post to make it easier for others.

1 Like

I tried setting up a Bluetooth Extender as per the YT video I posted a link to in December.

I got it up and working and the data duly arrived in HA. However as I added more sensors it became unstable to the point it eventually froze. Connecting it via USB to my laptop I could see that it went through a phase where it was still running but I could not connect via WIFI but it was still sending data to HA. Then the WIFI lost connection. I tried various suggestions online about creating a rule to reset the ESP32 if it lost WIFI but to no avail. It seems the ESP32 doesn’t like a lot of WIFI and Bluetooth activity at the same time.

I have now tried setting the ESP32 using ESPHome. I believe this polls the Bluetooth devices rather than trying to handle all the incoming BLE alerts. So far it has been stable with 10 of the Mi sensors on it. They are running custom firmware and pvvx advertising.
It reports: Temp, Humidity, Battery Voltage, Battery Level and Signal. I am using them as remote sensors for Zigbee radiator valves.

My house isn’t big but has a lot of thick granite walls, I was expecting to have to put several of these around the house but one is working fine. So now I need a new project for the spare ESP32s I had earmarked for this.

I also got an ESP32 to try to extend bluetooth range, but I found it didn’t help at all. Instead I just got a decent bluetooth receiver with an antenna and turned the power up on the bluetooth sensors a bit. If I had found an ESP32 with an antenna it may have worked better.

Hello,

I have 5 of the LYWSD03MMCs in my apartment. HA Supervised running on RPI4.

Previously running Xiaomi FW and Passive BLE integration for more than one year with few issues.

I have decided to give the custom firmware a try and flashed them with PVVX flasher, set the default advertising, 2500 with 4, BTHome discovery method, and a custom name for each.

Out of 5 units, only 3 are constantly available and sending data. 2 of them are either with unavailable data after discovery or they are not discovered at all.

I pumped the signal to +3 but without big success.

Using pvvx site I can see them, the data advertised …but on in HA,

I have also tried BLE HACS integration and only the 3 are discovered.

Trying to go back to the original FW did not yield any improvement.

Batteries were changed to new ones as well.

Does anyone have an idea where to start troubleshooting?

TIA

I would start by moving them fairly close to the Bluetooth receiver to work out if it’s a signal strength issue. After that I would probably try flashing them again, just to be sure. After that… not sure really.

Done that :frowning:
For the last week I am doing so :frowning:

This is how it looks in the dashboard:

image

This is one with the issue:
image

The top one (kitchen) is coming and going throughout the day (and it is the good one):

image

You’ve tried both ideas, re-flashing and moving closer to the receiver? I can see one sensor is called “Frigider” aka Fridge. A fridge is almost a faraday cage, it is difficult to get radio signals through it, particularly 2.4GHz which is what Bluetooth is. My fridge sensor works only when it’s set to maximum power, top of the fridge, and I have a Bluetooth receiver with an antenna.

Yes, I have tried both, even removing the battery in between the re-flashing.

Indeed, it’s a fridge one.
With Xiaomi FW it was working without issues.

Occasionally I get this message:

And you see, I get data into HA when the first discovery after reflashing is made.

And one is like this:

image

I haven’t used the BTHome integration. I tried it a couple of months back and it wasn’t as good as the Passive BLE Monitor integration - link is to a guide I wrote.

I’m not an expert on either of these things, I just documented what worked for me :slight_smile:

I have bought an ASUS BT dongle and wow, everything works.

I guess the inbuilt RPi BT adapter is slowly dying,…

Interesting. I didn’t know you were trying to use Bluetooth built into the Pi, IMHO that’s only good for very short range.

Hi all, I’m the author of both BLE monitor and the BTHome integration, so if you need help, let me know. I saw some messages about the long time before it asks for the encryption key with stock firmware. Let me explain. The LYWSD03MMC has a broadcasting interval of 10 minutes, so only one message per 10 minutes (while some other Xiaomi sensors have an interval of 1 or 2 seconds). Unfortunately that means that if HA receives a message, it can take 10 minutes before the sensor is created, and another 10 minutes before it asks/checks for the encryption key. And if reception is bad, it can even take longer.

That is why pvvx has created the custom firmware, it will increase the broadcasting range to whatever you want. And it doesn’t really hurt if you miss some messages every now and than, if it broadcasts a lot.

4 Likes