ESP32 BLE Scan interval

The code working amazingly good!
For the first time i got my 4 Miflower sensors working :grinning:

I publish all the sensor values, mqtt -> nodered -> Domoticz

I see the sensor updates really quickly every 1 min aprox so battery draining fast atm.
I tried to delay for each sensor update to 1 hour with mqtt command with help of putty:
mosquitto_pub -t home/OpenMQTTGateway/commands/MQTTtoBT/config -m ‘{“interval”:3600000}’

But the sensor is still getting updated every 1 min aprox.
Im not handy with platformini, i just flashed the standard esp32 image.

Can i update the interval with putty and that it is saved?

I would like to update
Temp
Moisture
Lux
Feritily
every 1 hour,

At the moment I see the sensor values passing in nodered in 4 messages everyone with 1 sensor value like discribed in the wiki

Thanks!

Hi,

I think something might have gone wrong with trying to update the interval, as scans are only really done after every interval time, so setting it to {“interval”:3600000} should not really still give updates around every 1 minute. Also I would assume that your sensors would only get connected to every 10 scan cycles (default ScanBeforeConnect 10 in config_BT.h), but then I am not familiar with the Miflower sensors and their connection functionality.

Could it be that your command to set the interval has a wrong topic/gateway name? Not sure what the default gateway name of the standard esp32 BLE image is, could it be OpenMQTTGateway_ESP32_BLE? So the command for setting the interval should be

mosquitto_pub -t home/OpenMQTTGateway_ESP32_BLE/commands/MQTTtoBT/config -m ‘{“interval”:3600000}’

Can you show us the topic with the gateway name of the received sensor messages?

You can also view and verify the active interval and scanbcnct (Scan Before Connect) settings in the regular SYStoMQTT messages of your gateway.

Thank you for the fast responds.
Im new to MQTT :slight_smile:

Atm MQTT explorer gives the value
{“uptime”:1802,“version”:“v0.9.5”,“freemem”:177796,“rssi”:-59,“SSID”:“secret”,“ip”:“192.168.1.152”,“mac”:“secret”,“wifiprt”:0,“lowpowermode”:0,“interval”:55555,“scanbcnct”:10,“modules”:“BTHADiscovery”}

So indeed the value is not updated.

My gateway name is indeed diffrent :stuck_out_tongue:
standard image: home/OpenMQTTGateway_ESP32_BLE

I tried with putty:
mosquitto_pub -t home/OpenMQTTGateway_ESP32_BLE/commands/MQTTtoBT/config -m ‘{“interval”:3600000}’

I tried to publish in MQTT explorer: (3 diffrent ways json/raw/xml)
home/OpenMQTTGateway_ESP32_BLE/commands/MQTTtoBT/config -m ‘{“interval”:3600000}’

But still the value is not updated i must do something stupid wrong lol

Any toughts?

Ok, always the problem here with the double quotes getting auto-converted into curly quotes (when not using preformatted text), sometimes also when you copy them from the Docs pages and pasting them to send the command ;). First of all make sure they are the ordinary

"

when publishing the command in either putty or MQTT explorer.

In MQTT Explorer you just need to specify the topic as

home/OpenMQTTGateway_ESP32_BLE/commands/MQTTtoBT/config

and the payload only as the JSON

{"interval":3600000}

Maybe also try with a shorter new interval for testing, just in case there is an upper limit to the interval - @1technophile - is there?

Ok, the only restriction I see in the code is the unsigned int definition of BLEinterval, which shouldn’t be an issue on the ESP32.

Cool, i tried “interval”: 600000, and it is accepted

(Did it with mqtt explorer the way you told me)

I will monitor if the sensors gets an update every 10 min. :):slight_smile:

:slight_smile:

Great, I also tested your desired 3600000 here, and it is taken fine.

The upper limit is 4 294 967 295ms

Note that this has no battery impact on the Mi Flora.
Indeed the Mi Flora advertize its data (there is no BLE connection) and OMG just read the data.

Good to know! I remember when i tried with python and bluez the creator told me don’t to poll too much.
Could it be that because he implemented battery reading he is connecting to the miflora for the cost of battery?

Yes it could be due to recurring BLE connections.