50ButtonsEach / fliclib-linux-hci

Flic SDK for Linux
307 stars 53 forks source link

Battery Lasts only a few weeks #50

Open gabalicious opened 7 years ago

gabalicious commented 7 years ago

I currently have 4 Flic buttons setup with my raspberry pi and the batteries only last for about 2-4 weeks. Let me know what type of information I should provide so we can troubleshoot.

Emill commented 7 years ago

What Raspberry Pi model? Do you use an external bluetooth dongle, if so, which? Do you have your buttons close to the raspberry pi?

denwilliams commented 7 years ago

I am also having this issue. Lucky if I can get more than 2 weeks of battery life.

RPi 2 with dongle. Have tried a couple of different ones. Current dongle is ID 0a12:0001 Cambridge Silicon Radio, Ltd Bluetooth Dongle (HCI mode)

Buttons are very close to RPi.

avzdk commented 7 years ago

Same problem with my FLIC-Doorbell RasbPi B+ BT-dongle https://www.amazon.co.uk/dp/B009ZIILLI/ref=pe_385721_37986871_TE_item Distance between flic and Pi: 4 meters. Changed battery yesterday

Log:

2017-06-06 08:31:28,753 root DEBUG Flic sort2 80:e4:da:71:4e:ac ConnectionStatus.Connected 2017-06-06 08:31:28,884 root DEBUG Flic sort2 80:e4:da:71:4e:ac ConnectionStatus.Ready 2017-06-06 08:32:01,341 root DEBUG Flic sort2 80:e4:da:71:4e:ac ConnectionStatus.Disconnected DisconnectReason.TimedOut 2017-06-06 08:32:03,445 root DEBUG Flic sort2 80:e4:da:71:4e:ac ConnectionStatus.Connected 2017-06-06 08:32:03,625 root DEBUG Flic sort2 80:e4:da:71:4e:ac ConnectionStatus.Ready 2017-06-06 08:33:16,581 root DEBUG Flic sort2 80:e4:da:71:4e:ac ConnectionStatus.Disconnected DisconnectReason.TimedOut 2017-06-06 08:33:16,885 root DEBUG Flic sort2 80:e4:da:71:4e:ac ConnectionStatus.Connected 2017-06-06 08:33:16,999 root DEBUG Flic sort2 80:e4:da:71:4e:ac ConnectionStatus.Ready 2017-06-06 08:33:21,441 root DEBUG Flic sort2 80:e4:da:71:4e:ac ConnectionStatus.Disconnected DisconnectReason.TimedOut 2017-06-06 08:33:24,197 root DEBUG Flic sort2 80:e4:da:71:4e:ac ConnectionStatus.Connected 2017-06-06 08:33:24,288 root DEBUG Flic sort2 80:e4:da:71:4e:ac ConnectionStatus.Ready 2017-06-06 08:34:11,392 root DEBUG Flic sort2 80:e4:da:71:4e:ac ConnectionStatus.Disconnected DisconnectReason.TimedOut 2017-06-06 08:34:13,340 root DEBUG Flic sort2 80:e4:da:71:4e:ac ConnectionStatus.Connected 2017-06-06 08:34:13,429 root DEBUG Flic sort2 80:e4:da:71:4e:ac ConnectionStatus.Ready 2017-06-06 08:34:38,572 root DEBUG Flic sort2 80:e4:da:71:4e:ac ConnectionStatus.Disconnected DisconnectReason.TimedOut 2017-06-06 08:34:38,717 root DEBUG Flic sort2 80:e4:da:71:4e:ac ConnectionStatus.Connected 2017-06-06 08:34:38,808 root DEBUG Flic sort2 80:e4:da:71:4e:ac ConnectionStatus.Ready 2017-06-06 08:35:27,983 root DEBUG Flic sort2 80:e4:da:71:4e:ac ConnectionStatus.Disconnected DisconnectReason.TimedOut 2017-06-06 08:35:28,287 root DEBUG Flic sort2 80:e4:da:71:4e:ac ConnectionStatus.Connected 2017-06-06 08:35:28,377 root DEBUG Flic sort2 80:e4:da:71:4e:ac ConnectionStatus.Ready

Emill commented 7 years ago

Have you tried having the Flic closer? Have you tried another Flic? Do these two things change the disconnect behaviour?

jusmop commented 6 years ago

Hi, I have exactly the same issue with my Flic buttons. I have 6 buttons and all of them do it. I use a bluetooth USB dongle plugged into a PC running Ubuntu. I'm running a Python script that uses the client in fliclib-linux-hci to respond to button events and switch my LIFX lights. My setup details:

My buttons connect and disconnect every few seconds more-or-less continuously, even though they are not being pressed. This obviously chews through the batteries.

I don't believe that this is a range issue, or a broken button issue. The buttons shouldn't be connecting (or attempting to connect) when not used, right?

A log excerpt from this morning (same sort of output as avzdk reported): 2018-03-02 07:11:32,508 INFO 80:e4:da:73:55:ac ConnectionStatus.Disconnected DisconnectReason.TimedOut 2018-03-02 07:11:33,057 INFO 80:e4:da:73:55:ac ConnectionStatus.Connected 2018-03-02 07:11:33,182 INFO 80:e4:da:73:55:ac ConnectionStatus.Ready 2018-03-02 07:11:33,631 INFO 80:e4:da:73:55:ac ConnectionStatus.Disconnected DisconnectReason.TimedOut 2018-03-02 07:11:34,019 INFO 80:e4:da:73:55:ac ConnectionStatus.Connected 2018-03-02 07:11:34,157 INFO 80:e4:da:73:55:ac ConnectionStatus.Ready 2018-03-02 07:11:36,861 INFO 80:e4:da:71:fb:a8 ConnectionStatus.Disconnected DisconnectReason.TimedOut 2018-03-02 07:11:38,630 INFO 80:e4:da:73:55:ac ConnectionStatus.Disconnected DisconnectReason.TimedOut 2018-03-02 07:11:41,703 INFO 80:e4:da:71:fb:a8 ConnectionStatus.Connected 2018-03-02 07:11:41,803 INFO 80:e4:da:71:fb:a8 ConnectionStatus.Ready 2018-03-02 07:11:41,811 INFO 80:e4:da:73:55:ac ConnectionStatus.Connected 2018-03-02 07:11:41,912 INFO 80:e4:da:73:55:ac ConnectionStatus.Ready 2018-03-02 07:11:46,313 INFO 80:e4:da:73:55:ac ConnectionStatus.Disconnected DisconnectReason.TimedOut 2018-03-02 07:11:49,923 INFO 80:e4:da:73:55:ac ConnectionStatus.Connected 2018-03-02 07:11:50,216 INFO 80:e4:da:73:55:ac ConnectionStatus.Disconnected DisconnectReason.TimedOut 2018-03-02 07:11:50,761 INFO 80:e4:da:73:55:ac ConnectionStatus.Connected 2018-03-02 07:11:51,040 INFO 80:e4:da:73:55:ac ConnectionStatus.Ready 2018-03-02 07:11:53,200 INFO 80:e4:da:71:fb:a8 ConnectionStatus.Disconnected DisconnectReason.TimedOut 2018-03-02 07:11:56,804 INFO 80:e4:da:71:fb:a8 ConnectionStatus.Connected `

Cheers, Justin.

mrwhale commented 6 years ago

Adding my plus one to this. Mainly because of the log output above. I assume battery drain because of the constant connection/disconnections. This is what my log file looks like too and battery's don't last very long

For me doesn't matter the distance either

Emill commented 6 years ago

Try set the auto disconnect timeout value to for example 15. That will make the button disconnect 15 seconds after inactivity. Otherwise they will try stay connected all the time, which consumes energy.

jusmop commented 6 years ago

Hi Emill,

Is this done via the fliclib-linux-hci client? I'm using the python one...

Cheers, Justin.

On 2 Mar. 2018 5:12 pm, "Emill" notifications@github.com wrote:

Try set the auto disconnect timeout value to for example 15. That will make the button disconnect 15 seconds after inactivity. Otherwise they will try stay connected all the time, which consumes energy.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/50ButtonsEach/fliclib-linux-hci/issues/50#issuecomment-369864402, or mute the thread https://github.com/notifications/unsubscribe-auth/AYOI4rOX61D3LgKzTzBRFPCUFws5UUCFks5taQztgaJpZM4MfqTf .

Emill commented 6 years ago

Yes, see the last parameter for the constructor of a connection channel https://github.com/50ButtonsEach/fliclib-linux-hci/blob/master/clientlib/python/fliclib.py#L140

mrwhale commented 6 years ago

Is there a similar option for the node client? I see a force disconnect command code but it doesn't look too me like it does anything yet

Emill commented 6 years ago

Sure. See the documentation:

/**

jusmop commented 6 years ago

Thanks Emill. I set the auto disconnect to 15 sec in my script and that has stopped the continuous connecting/disconnecting. Hopefully that will solve my battery issues!

Given the tiny battery and typical use cases, I can't think of a reason for the Flic buttons to be trying to connect continuously. Shouldn't the default auto disconnect time be set to something reasonable?

Emill commented 6 years ago

Yes we have discussed that many times. When we began the Flic project we only had connecting to smartphones in mind. In particular, Android Kitkat (which was the latest version back then) had such terrible scan window/interval that it could easy take multiple seconds to connect the button. To get low delay, we had to stay connected all the time. We also calculated the battery life to be over a year even if it stayed connected, but those calculations assumed ideal conditions.

With the hci daemon we can select a better scan window/interval which leads to quicker connection setup and also optimize the packet flow after the connection has been set up. So yes with the hci daemon the latency is very low even if it has to connect first and maybe we should by default set the auto disconnect timeout to something else than inf...

Sawtaytoes commented 6 years ago

How would I change the auto-disconnect timeout? It's supposed to be called when you create the daemon right?

Emill commented 6 years ago

It's done when a connection channel is created. It's also possible to change it for an existing connection channel. See the documentation for more info.

Sawtaytoes commented 6 years ago

I'm using the Node.js client and after looking through these docs, and think I found the solution. Seems like the fliclib.js source code is the place be:

const flicConnectionChannel = (
  new FlicConnectionChannel(
    bluetoothAddress,
    {
      autoDisconnectTime: 15,
      latencyMode: 'LowLatency',
    }
  )
)

After reading this thread, I'm under the impression the reason a lot of my buttons stopped functioning all within the last month is probably because of battery life and not because my connection software isn't working properly.