-
Notifications
You must be signed in to change notification settings - Fork 162
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Limit number of measures #3
Comments
Ok I'll implement. Probably I'll implement tomorrow. However I'm not sure if you will save any batterylife withit. As long as the raspberry pi is connected with the Xiaomi sensor (showing the bluetooth symbol), is doesn't send and regular advertisment data anymore. Or at least very very seldom, since most of the time this device can't be found with a BLE Scanner App. So it could be more powersaving to stay connected. However if its very useful to only connect at certain intervals, I'll implement. But beware this connection process could use more energy than staying connected. I'm no BLE expert, so I don't know the protocol for establishing the connection. But since it takes some seconds, I think it uses a significant amount of energy compared to staying connected. |
I'm no expert in BLE either, but it seems to me that, to maintain a connection open, you need to send some data on a regular basis. |
Function was implemented. Please try if it works for you and then close the issue. Please report the battery levels after some time, so we know if it saves power. Thx. |
Great! Working perfectly for the moment. |
Please use the latest version. Due to a bug in bluepy script stopped sometimes collecting data. Now a workaround is implemented. Which trouble do you have with the continious loop? |
I don't need a measure every 6 seconds. One every 5 minutes is largely enough. My concern is that, by sending data through BTLE every 6 seconds, the battery is drained faster than it would be with a single measure sent every 5 minutes. |
@funkylab could you share your callback mqtt script i would need an example so i can adapt it to my needs and i am no programming star :-) |
Sure. |
top
Sent from Mail for Windows 10
From: FunkyFab
Sent: Wednesday, 22 January 2020 08:08
To: JsBergbau/MiTemperature2
Cc: wesselah; Comment
Subject: Re: [JsBergbau/MiTemperature2] Limit number of measures (#3)
@funkylab could you share your callback mqtt script i would need an example so i can adapt it to my needs and i am no programming star :-)
Sure.
Here it is.
pushToMQTT.zip
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
@wesselah |
Just did see this also so again thx, it is already working on three sensors.
Found out that a raspberry zero w has the best Bluetooth reach
Sent from Mail for Windows 10
From: JsBergbau
Sent: Wednesday, 22 January 2020 11:46
To: JsBergbau/MiTemperature2
Cc: wesselah; Mention
Subject: Re: [JsBergbau/MiTemperature2] Limit number of measures (#3)
@wesselah
THere is also a "sendToMQTT" script in the main repository, provided by @Chiunownow
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
Which devices did you test? The Pi Zero W actually is amazing. It goes through 2 thick outer stonewalls and still can read a sensor ~20m away. A RPI 3 didn't even manage to go through the basement ceiling. |
Raspberry 3 and 4 and both where worse then raspberry zero w which was amazing
Sent from Mail for Windows 10
From: JsBergbau
Sent: Wednesday, 22 January 2020 13:00
To: JsBergbau/MiTemperature2
Cc: wesselah; Mention
Subject: Re: [JsBergbau/MiTemperature2] Limit number of measures (#3)
ound out that a raspberry zero w has the best Bluetooth reach
Which devices did you test? The Pi Zero W actually is amazing. It goes through 2 thick outer stonewalls and still can read a sensor ~20m away.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
Hi. First of all thank you for your work. I'm testing it and I'm experiencing and odd behavior with an "on-demand" activation. Let's say I want to call it every 10 minutes to get an update on my MQTT broker. If I try with "-c 1" I don't get the MQTT update:
So I try with "-c 2" and I can see the update, but without the battery info (so the script write to the mqtt broker the timestamp as the battery value):
Then I think to set "-b 1" to retrieve the battery info, and effectively it does, but the battery info sent to the callback script is different:
How can I do it? Thank you. |
Hi giuseppegimo, thanks for exactly describing your problem. I have understood. I use a thread to send the data to callback. However the main script exits before this thread can send data. I'll fix in the following days. |
@giuseppegimo |
Thank you @JsBergbau , it's ok now. I understand that the first battery readout is 0, it just seems strange to me that there is the correct value (99) in the output but then it is passed to callback 0:
|
Let me explain you:
Is printed in the callback function receiving the temperature values. This function also sets the measurement data in this case 0 for batterylevel, since we haven't read yet. Reading the batterylevel uses extra energy from the sensor, thats why it is implemented that way. If you don't want to stay constantly connected to the aqara, I'd read only temperature and humidity, and once a day or so, I'd read the battery level. The aqara I'm running for more than 3 weeks now, still shows 99% batterylevel. PS: The debouncing function only works if you run the script constantly. With limiting the number of measurements to a small number it makes no sense. |
@giuseppegimo Can you please check if it works for you know as intended? |
Hi @JsBergbau and thank you.
Maybe the first callback has to be skipped. |
Hi @giuseppegimo Just checked again:
|
Yeah there was something wrong, it seems ok now:
Thanks! |
I'm no expert either; But from what I read, actually staying connected and not pulling data so fast would be better; Cause when you are not connected the sensor is in "advertising mode" so it sends out data packages every so often. If you remain connected and only request data once a minute you only "keep the connection" alive, reducing the overall packages send. I'm not planning to poll more then once per hour, so I don't think I will stay connected; but the cheapest (power wise) option would be good to know! Thanks for this useful tool ! |
Seems to be solved --> Closing |
Hi,
Could it be possible to add a new parameter (--count for instance).
This parameter would be an integer, and the script would exit after receiving this number of measures.
That would allow a limited bluetooth connection.
For instance, I would trigger the script from cron every 5 minutes, with 3 measures. The bluetooth connection would then be maybe 30 seconds every 5 minutes.
Thanks for considering my request.
The text was updated successfully, but these errors were encountered: