Connecting the Medisana BS440 Bluetooth scale (epilogue)

Having used the BS440 bathroom scale script for over a year i got time to update the whole thing. I decided to do a full reinstall and log all the individual steps it takes to get things running. So here is the recipe.


  • Raspberry Pi B+ (note: i have no Pi3 so no experience in using the built in BLE adapter)
  • USB BLE adapter (I use brand ADJ model 100-00006 BT 4.0 adapter which uses driver broadcom BCM20702A0)
  • WiFI adapter (unless you can position a wired RPi within 1 m from the scale) like this one


  1. Download latest Raspbian Jessie Lite build for your RPi from here.
  2. Format and image the SD card. Instructions here
  3. Enable SSH access by placing a file named ‘ssh’, without any extension, onto the boot partition of the SD card.
  4. Use a temporarely wired connection to connect to the RPi using Putty
  5. Change pwd and run sudo raspi-config and do
    expand filesystem
    set timezone
    set hostname like bs440rpi (or any other nice name)
  6. run sudo apt-get update and sudo apt-get dist-upgrade
  7. Enable WiFi using this tutorial.
  8. Follow Tony DiCola tutorial to set up Bluez on the RPi. I selected the latest and greatest Bluez 5.44. Follow this tutorial step by step. No need to enable “experimental”. Building Bluez will take half an hour or so…
  9. Copy btmgmt to the local bin folder with:  sudo cp /home/pi/bluez-5.44/tools/btmgmt  /usr/local/bin so it can be used from anywhere.
  10. Enable BT low enegry with btmgmt le on
  11. run hcitool lescan  and step on the scale with a registered user selected so all your properties are measured and stored. The scale should report with its MAC address and name like F1:37:57:6C:DE:64 [0202B664DE6C5737F1] write down both.
  12. Test connectivity with sudo gatttool -t random -b F1:37:57:6C:DE:64 -I
  13. at the prompt type connect which should respond connected. Error 111 indicates that the adapter is not in LE mode (retry the btmgmt le on).
  14. Avoid having to use super user privileges (sudo) on hcitool by sudo setcap 'cap_net_raw,cap_net_admin+eip' 'which hcitool'
  15. Avoid having to use super user privileges (sudo) on btmgmt by sudo setcap 'cap_net_raw,cap_net_admin+eip' which btmgmt
  16. Install Pygatt 3.0.0 by sudo apt-get install python-pip and sudo pip install "pygatt[GATTTOOL]" This will throw a number of warnings and even errors but should end with Successfully installed pygatt pyserial enum34 pexpect ptyprocess
  17. Get the BS440 files by downloading the zip file from  and put them in a separate folder on the RPi like /home/pi/BS440.
  18. Enable the plugins of your choice by removing the underscore in the plugins folder for the .py and .ini files.
  19. Edit BS440.ini (fill in your scale’s MAC address and name from step 11) and all the enabled BS440<plugin>.ini in the plugins folder
  20. Start with  python Start a second shell and monitor the logfile with tail -f BS440.log
  21. Enjoy
This entry was posted in BLE. Bookmark the permalink.

7 Responses to Connecting the Medisana BS440 Bluetooth scale (epilogue)

  1. Fabian says:

    Thanks for sharing, great work !
    Just installed this on a Rpi 3 using the build in wifi and bluetooth module.

    It was mostly just a copy/paste job. A few minor changes:
    Step 14, the quotes around `which` seem to be missing: setcap ‘cap_net_raw,cap_net_admin+eip’ `which hcitool`

    Step 15, it’s btmgmt instead of bgmgmt


    • keptenkurk says:

      Thanks fort pointing Fabian! Corrected the flaws. Got a lot of help from jovandeginste lately. Got the BS410 also to work and another few improvements. Stay tuned!


  2. Teddy May says:

    I got “INFO connect Connecting to D0:FF:41:B3:85:84 with timeout=8” in the log while trying to execute script. I’m on Raspbian Jessy. “sudo setcap ‘cap_net_raw,cap_net_admin+eip’ ‘which hcitool'” dosen’t work. I replaced both “ble_adresss” and “device_name” with what I get with hcitool scan and no luck


    • keptenkurk says:

      Not sure what you mean with “sudo setcap…whcih hcitool’ doesn’t work. Can you run hcitool without sudo and does it find your device? Pygatt basically runs hcitool in “wait_for_device” and i remember that adapter.reset() was a problem when running the script as su. But it;s worth the try…


  3. Frank says:

    Thanks for sharing your code!

    I almost got it to work; I seem to be very close. When the scale (BS444) connects I get an error message. The log give the following output. Do you have an idea what is going wrong?
    Thanks for your work, time and advice in advance, Frank


    2018-04-11 21:28:03,842 INFO init_ble_mode hci0 Set Low Energy complete, settings: powered bondable ssp br/edr le secure-conn

    Exception in thread Thread-1:
    Traceback (most recent call last):
    File “/usr/lib/python2.7/”, line 801, in __bootstrap_inner
    File “/home/pi/.local/lib/python2.7/site-packages/pygatt/backends/gatttool/”, line 137, in run
    File “/home/pi/.local/lib/python2.7/site-packages/pygatt/backends/gatttool/”, line 480, in _handle_notification_string
    handle = int(hex_handle, 16)
    ValueError: invalid literal for int() with base 16: ‘=’

    2018-04-11 21:31:01,894 INFO Waiting for notifications for another 30 seconds
    2018-04-11 21:31:31,981 INFO Done receiving data from scale
    2018-04-11 21:31:31,987 ERROR Unreliable data received. Unable to process


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s