Saturday, September 15, 2012

Using the FitBit Ultra Activity Tracker with Ubuntu 12.04 Precise Pangolin

Just bought the FitBit Ultra Activity Tracker, needed to get it working with my Ubuntu 12.04 computers, and here is my tale:

 A google search yields an opensourced project started by Kyle @ Openyou.org and continued along by Benoît Allard that supports uploading data from the tracker to the FitBit personal website.

Steps I used to install:

  • Registration
    • If the device hasnt already been registered with FitBit website, unfortunately you will need to by using the windows software link provided by the device.  I have an emergency WinXP vm for just such purposes.   After registration you do not need it running anymore
  • Get the source from github (as superuser):
    • apt-get install git
    • mkdir /opt
    • cd /opt
    • git clone https://github.com/benallard/libfitbit.git
    • cd libfitbit
  • Allow the device to be used by non-superusers
    • cp ./platform/linux/* /etc/udev/rules.d
  • Install python libraries needed:
    • pip install pyusb
    • apt-get install python-yaml
  • Run the service:
    • python /opt/libfitbit/python/fitbit_client.py
Done!  Now the device will be syncing with the website as long as the service is running.

24 comments:

  1. I'm getting the following error... any help would be appreciated:


    $ python /opt/libfitbit/python/fitbit_client.py
    Traceback (most recent call last):
    File "/opt/libfitbit/python/fitbit_client.py", line 57, in
    from fitbit import FitBit
    File "/opt/libfitbit/python/fitbit.py", line 69, in
    from antprotocol.bases import getBase
    ImportError: No module named bases

    ReplyDelete
  2. I got it to work by getting libfitbit from https://github.com/qdot/libfitbit.git instead of https://github.com/benallard/libfitbit.git

    ReplyDelete
  3. Regarding this error:

    Traceback (most recent call last):
    File "/opt/libfitbit/python/fitbit_client.py", line 57, in
    from fitbit import FitBit
    File "/opt/libfitbit/python/fitbit.py", line 69, in
    from antprotocol.bases import getBase
    ImportError: No module named bases

    benallard had a small bug in his fork, which is fixed now.
    https://github.com/benallard/libfitbit.git is working fine now.

    ReplyDelete
  4. Any help with this error??

    Traceback (most recent call last):
    File "libfitbit/python/fitbit_client.py", line 312, in
    FitBitDaemon(args.debug).run(args)
    File "libfitbit/python/fitbit_client.py", line 278, in run
    self.try_sync()
    File "libfitbit/python/fitbit_client.py", line 248, in try_sync
    self.do_sync()
    File "libfitbit/python/fitbit_client.py", line 234, in do_sync
    f = FitBitClient(self.debug)
    File "libfitbit/python/fitbit_client.py", line 159, in __init__
    conn = getConn()
    File "/home/dave/libfitbit/python/antprotocol/connection.py", line 124, in getConn
    if conn.open():
    File "/home/dave/libfitbit/python/antprotocol/connection.py", line 88, in open
    if not super(FitBitANT, self).open():
    File "/home/dave/libfitbit/python/antprotocol/connection.py", line 41, in open
    self._connection.set_configuration()
    File "/usr/local/lib/python2.7/dist-packages/usb/core.py", line 554, in set_configuration
    self._ctx.managed_set_configuration(self, configuration)
    File "/usr/local/lib/python2.7/dist-packages/usb/core.py", line 91, in managed_set_configuration
    self.managed_open()
    File "/usr/local/lib/python2.7/dist-packages/usb/core.py", line 70, in managed_open
    self.handle = self.backend.open_device(self.dev)
    File "/usr/local/lib/python2.7/dist-packages/usb/backend/libusb1.py", line 494, in open_device
    _check(_lib.libusb_open(dev.devid, byref(handle)))
    File "/usr/local/lib/python2.7/dist-packages/usb/backend/libusb1.py", line 403, in _check
    raise USBError(_str_error[ret], ret, _libusb_errno[ret])
    usb.core.USBError: [Errno 13] Access denied (insufficient permissions)
    []

    Closing USB device
    Exception AttributeError: "'FitBitClient' object has no attribute 'fitbit'" in > ignored

    ReplyDelete
  5. This looks like a permission issue with the USB port, look at the rules.d step.

    if it works as super user than this is the case
    >sudo python /opt/libfitbit/python/fitbit_client.py

    you could try adding yourself to the dialout group to get permission to access the usb port
    >sudo adduser yourUserName dialout

    ReplyDelete
  6. looks like it should work, however not seeing the device-- No devices connected!

    lsusb shows
    Bus 005 Device 003: ID 2687:fb01

    which I think must be the dongle

    ReplyDelete
    Replies
    1. phil@minuet:/opt/fitbit/libfitbit$ lsusb
      Bus 002 Device 004: ID 10c4:84c4 Cygnal Integrated Products, Inc.

      in my case ?

      Delete
  7. I'm getting this error on ubuntu 12.10:

    Failed to find a base
    No base found!
    []

    Closing USB device
    Exception AttributeError: "'FitBitClient' object has no attribute 'fitbit'" in > ignored

    ReplyDelete
  8. This works. Thank you. The first time it didn't. But after I disconnected the USB and reconnected, it synced.
    Thanks a lot. A lot of "failed" errors are in the Terminal, but it will still sync accurately. I also have to sudo to run the .py but no problem.
    Thanks again.
    Anthony

    ReplyDelete
  9. As long as I can see, the installation works. But when I try to run the service, it says: "No devices connected!"

    ReplyDelete
  10. I also get the message
    "No devices connected!"

    Any ideas for the solution?

    ReplyDelete
  11. Same issue as others. No devices connected. Unplugged dongle and replugged. No luck.

    ReplyDelete
  12. great, I followed the instructions and it just worked

    ReplyDelete
  13. After much reading and faffing about plus using the recommendations in this blog I managed to get to No devices connected!

    Also I see the from lsusb
    Bus 003 Device 006: ID 2687:fb01

    Can anyone help ... please I dont want to go back to windows OS

    ReplyDelete
  14. Can I use this to access the raw data out of fitibit? I'm interested in possibly exporting the data to maybe a .csv and analyzing it in mathematical software. Any help would be appreciated. Thanks!

    ReplyDelete
  15. Worked great on Mint 14, After upgrading to 16. I get the following error. Any help would be great. I hate running separate windows pc just for this.

    sudo python /opt/libfitbit/python/fitbit_client.py
    Traceback (most recent call last):
    File "/opt/libfitbit/python/fitbit_client.py", line 268, in
    FitBitDaemon(args.debug).run(args)
    File "/opt/libfitbit/python/fitbit_client.py", line 234, in run
    self.try_sync()
    File "/opt/libfitbit/python/fitbit_client.py", line 204, in try_sync
    self.do_sync()
    File "/opt/libfitbit/python/fitbit_client.py", line 190, in do_sync
    f = FitBitClient(self.debug)
    File "/opt/libfitbit/python/fitbit_client.py", line 115, in __init__
    conn = getConn()
    File "/opt/libfitbit/python/antprotocol/connection.py", line 124, in getConn
    if conn.open():
    File "/opt/libfitbit/python/antprotocol/connection.py", line 88, in open
    if not super(FitBitANT, self).open():
    File "/opt/libfitbit/python/antprotocol/connection.py", line 33, in open
    self._connection = usb.core.find(idVendor = self.VID,
    AttributeError: 'module' object has no attribute 'core'
    []

    Closing USB device
    Exception AttributeError: "'FitBitClient' object has no attribute 'fitbit'" in

    ReplyDelete
  16. I'm running ubuntu 13.10. When I run the qdot version as sudo, I get the following error...
    Traceback (most recent call last):
    File "/opt/libfitbit/python/fitbit_client.py", line 173, in
    main()
    File "/opt/libfitbit/python/fitbit_client.py", line 161, in main
    f = FitBitClient()
    File "/opt/libfitbit/python/fitbit_client.py", line 97, in __init__
    if base.open():
    File "/opt/libfitbit/python/antprotocol/bases.py", line 26, in open
    if not super(FitBitANT, self).open(vid, pid):
    File "/opt/libfitbit/python/antprotocol/libusb.py", line 62, in open
    self._connection = usb.core.find(idVendor = vid,
    AttributeError: 'module' object has no attribute 'core'

    When I run the benallard fork, also as sudo, I get slightly different errors...
    Traceback (most recent call last):
    File "/opt/libfitbit/python/fitbit_client.py", line 312, in
    FitBitDaemon(args.debug).run(args)
    File "/opt/libfitbit/python/fitbit_client.py", line 278, in run
    self.try_sync()
    File "/opt/libfitbit/python/fitbit_client.py", line 248, in try_sync
    self.do_sync()
    File "/opt/libfitbit/python/fitbit_client.py", line 234, in do_sync
    f = FitBitClient(self.debug)
    File "/opt/libfitbit/python/fitbit_client.py", line 159, in __init__
    conn = getConn()
    File "/opt/libfitbit/python/antprotocol/connection.py", line 124, in getConn
    if conn.open():
    File "/opt/libfitbit/python/antprotocol/connection.py", line 88, in open
    if not super(FitBitANT, self).open():
    File "/opt/libfitbit/python/antprotocol/connection.py", line 33, in open
    self._connection = usb.core.find(idVendor = self.VID,
    AttributeError: 'module' object has no attribute 'core'
    []

    Closing USB device
    Exception AttributeError: "'FitBitClient' object has no attribute 'fitbit'" in > ignored
    ==========
    lsusb gives me the following output...
    Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
    Bus 007 Device 004: ID 2687:fb01
    Bus 007 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
    Bus 006 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
    Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
    Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
    Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
    Bus 004 Device 003: ID 046d:c52b Logitech, Inc. Unifying Receiver
    Bus 004 Device 002: ID 051d:0002 American Power Conversion Uninterruptible Power Supply
    Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
    Bus 009 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
    Bus 008 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
    ====================
    Any thoughts about this?

    Thanks.

    ReplyDelete
    Replies
    1. Your problem is that you don't have the necessary python usb support installed. You need to:

      1) sudo apt-get install libusb-1.0-0-dev
      2) wget http://sourceforge.net/projects/pyusb/files/PyUSB%201.0/1.0.0-beta-1/pyusb-1.0.0b1.tar.gz/download, then unzip, switch to the created directory and sudo python setup.py install.

      That will get you to the place where you'll see "No devices connected!" Huzzah!

      Delete
    2. With the help of Anonymous above, I could get it to work using Ben Allard's new tool, Galileo.py. That can be found here:
      https://bitbucket.org/benallard/galileo

      It doesn't seem to work all the time, and it seems to confuse CMWayne's stepcount indicator (I have no idea why).

      Nice work Mr. Allard and Mr. Wayne. I appreciate it.

      Delete
  17. https://bitbucket.org/benallard/galileo
    i tested above today, this way is working fine in Ubuntu 13.04. good job

    ReplyDelete
  18. Hi,

    This is just what I need to do but it's running on Arch linux (on the Pi of course, with my mining s/w ) how can I get it work here - it seem to do everything and run with bad syntax print - any ideas thanks.

    ReplyDelete
  19. not working here, just comes up with NO Base Found and lsusb only shows Linux Foundation USB devices + Logitech which is my wireless keyboard/mouse

    ReplyDelete