Unable to get frequent refresh interval - Xiaomi LYWSD03MMC

No matter how I try to configure the interval parameters, I can’t get the refresh interval to match Tasmota for the same device ( Xiaomi LYWSD03MMC temp-hum sensor)
see graph below - Yellow dots are Tasmota, Green : openmqttgateway

What I am configuring wrong ?

parameters:
OMG:

{
  "bleconnect": true,
  "interval": 1000,
  "adaptivescan": false,
  "intervalacts": 1000,
  "intervalcnct": 5000,
  "scanduration": 1000,
  "onlysensors": false,
  "randommacs": false,
  "hasspresence": false,
  "presenceTopic": "presence/",
  "presenceUseBeaconUuid": false,
  "minrssi": -92,
  "extDecoderEnable": false,
  "extDecoderTopic": "undecoded",
  "filterConnectable": false,
  "pubadvdata": false,
  "pubBeaconUuidForTopic": false,
  "ignoreWBlist": true,
  "presenceawaytimer": 120000,
  "movingtimer": 60000,
  "btqblck": 133,
  "btqsum": 29841,
  "btqsnd": 23474,
  "btqavg": 1.271236,
  "bletaskstack": 3032,
  "blecoretaskstack": 2768,
  "blestarts": 1
}

Tasmota

MI32period "15"
MI32option0 "0"
MI32option1 "0"
MI32option2 "1"
MI32option4 "1"
MI32option5 "0"
MI32option6 "1"
TelePeriod "10"

image

Are you using the stock firmware with the LYWSD03MMC ?

If yes OMG retrieve the data by a connection and even if you have intervalcnct at 5s, retrieving data with a connection is less easy than broadcasting.
I would advise to change the LYWSD03MMC firmware with PVVX one. You will get a better battery life.

If you already use an alternative firmware, could you detail the version and configuration options?

Yes I do have an alternative firmware but haven’t upgraded recently so I have the original one from

:GitHub - atc1441/ATC_MiThermometer: Custom firmware for the Xiaomi Thermometer LYWSD03MMC and Telink Flasher via USB to Serial converter

Was about to upgrade to the other version but wanted to technically understand why I couldn’t get the data via OMG since it can obviously be done with Tasmota without upgrading.

Especially that I’m still not totally sure I understand the full differences and use cases for :

Interval
Intervalacts
Intervalcnct
scanduration
Bleconnect

And how it aligns with Tasmota parameters.

Let me know if you can shed some light on this :grinning:

Of course,

  • Interval is the time the esp32 is waiting between 2 passives scans
  • Intervalacts is the time the esp32 is waiting between 2 active scans
  • Intervalcnct is the time the esp32 is waiting between 2 connection to retrieve data
  • Scanduration is the time the esp32 will scan for advertisement data
  • Bleconnect is, if you want or not the esp32 to retrieve data with a connection

Not sure of this, as I don’t know Tasmota parameters

Thank you,

would you have any recommendations regarding my omg configuration/parameters above? All scan modes are set below 5 second so what would explain it only captures a fraction of the updates every 5minutes?

Will try the pvvx upgrade but would like to identify the root cause of this.

Thx

Installed pvvx 4.6;

which parameters do you recommend?

Thx

For now, results are the same:

very frequent and precise results with Tasmota
unfortunately not the case with OMG:

Let me know if you have suggestions to troubleshoot the issue, thx.

Thanks for the data, are the 2 esp32 located at the same distance from the sensor?

With an advertising interval of thePVVX firmware of 2.5 seconds, and

"interval": 1000,

and

"scanduration": 1000,

you could well miss the broadcast several time, with it falling into the interval reception pause.

How about setting

"scanduration": 3000,

so that each scan should pick up at least a single broadcast from the LYWSD03MMC.

1 Like

Thanks for the feedback,

In fact the OMG ESP32 is actually closer to the device than the Tasmota ESP32.

I had already set “scanduration” to 5000 earlier today after upgrading to pvvx4.6 but still no success:

I also tried to disable the Tasmota ESP32 in case there was some kind of conflict but it has no effect on the OMG response frequency. something else is going on on the OMG side.

Did you not set/change the minimum rssi to quite a bit lower earlier on?

"minrssi":-70

so that your OneMQTTGateway is much less sensitive to publishing picked up devices.

How about setting it back to the default -100.

I was back to -92 but changed to -100 just to be sure. Still no change.

This sensor is used to trigger the shower fan so I do need frequent refresh. I can use Tasmota but puzzled at why results are so different.

Could you erase your flash and try a stock v1.7.0 esp32dev-ble firmware if not already done?

Would be interesting to see the behaviour with the default parameters.

Can I do it OTA (is there some force erase option) or only via cable (erase/flash)?

Not possible OTA unfortunately.

Although I’m not sure if an erase and then init of the saved settings in flash would function in a similar way with a pre-build binary install, but really best to to a complete erase flash via cable :slight_smile:

ESP32 erased + fresh install/flash. A little better but still not great.

Tried not to use round numbers to avoid some type of command overlapping.

Is there some type of data “filter” as it seems the data resolution is low.

Last option would be to change the ESP32 unit itself. Maybe some physical issue with the BLE receiver? but even then, for the same device, OMG reports RSSI -70 and Tasmota -85…

{
  "bleconnect": true,
  "interval": 5555,
  "adaptivescan": true,
  "intervalacts": 1212,
  "intervalcnct": 9595,
  "scanduration": 9393,
  "onlysensors": false,
  "randommacs": false,
  "hasspresence": false,
  "prestopic": "presence/",
  "presuseuuid": false,
  "minrssi": -100,
  "extDecoderEnable": false,
  "extDecoderTopic": "undecoded",
  "filterConnectable": false,
  "pubadvdata": false,
  "pubuuid4topic": true,
  "ignoreWBlist": true,
  "presenceawaytimer": 120000,
  "movingtimer": 60000,
  "forcepscn": false,
  "tskstck": 2592,
  "crstck": 1556,
  "enabled": true,
  "scnct": 569
  "scnct": 576
}

Ok, looking better already, but not quite what you’re expecting.

Could you do a few more adjustments to your setting?

Initially, can you set

  "bleconnect": false,
  "adaptivescan": false,

As the LYWSD03MMC do not require active scanning you can set

"intervalacts": 300000,

just for testing to only scan actively every 5 minutres - I don’t know what other sensors you might have which require active scanning.

Then for a more frequent passive scanning you can keep

"interval": 1000,

but set

"scanduration": 5000,

This should give you a reading every 6 seconds.

Could you also monitor the LYWSD03MMC in MQTT Explorer History for the device. Just to see if there are possibly some undecoded messages in between the decoded ones, in a format which we do not currently decode. What are the reading intervals in parenthesis in the History?

Other than that I am also not sure of some of the PVVX settings you showed above when installing it. Were those the default suggested settings?

Thanks. you didn’t specify intervalcnct so I’ve used 1500.
Will monitor both HA and MQTTexporer.
more to come.

  "bleconnect": true,
  "interval": 1000,
  "adaptivescan": true,
  "intervalacts": 300000,
  "intervalcnct": 1500,
  "scanduration": 5000,
  "onlysensors": false,
  "randommacs": false,
  "hasspresence": false,
  "prestopic": "presence/",
  "presuseuuid": false,
  "minrssi": -100,
  "extDecoderEnable": false,
  "extDecoderTopic": "undecoded",
  "filterConnectable": false,
  "pubadvdata": false,
  "pubuuid4topic": true,
  "ignoreWBlist": true,
  "presenceawaytimer": 120000,
  "movingtimer": 60000,
  "forcepscn": false,
  "tskstck": 3948,
  "crstck": 3056,
  "enabled": true,
  "scnct": 3

Intervalcnt should be every hour at maximum if you have devices eligible to connection.
I would better set it to 3600000

Done.

Intervalcnt set to 3600000
Doesn’t look too bad.
I think the extra resolution on the tasmota side comes from the fact that I have a secondary esp32 outdoors which probably feeds additional data from the same sensor.

Can I do the same with OMG, IE: have multiple ESP32 publish to the same topic?