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
- Download latest Raspbian Jessie Lite build for your RPi from here.
- Format and image the SD card. Instructions here
- Enable SSH access by placing a file named ‘ssh’, without any extension, onto the boot partition of the SD card.
- Use a temporarely wired connection to connect to the RPi using Putty
- Change pwd and run
sudo raspi-configand do
set hostname like bs440rpi (or any other nice name)
sudo apt-get updateand
sudo apt-get dist-upgrade
- Enable WiFi using this tutorial.
- 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…
- Copy btmgmt to the local bin folder with:
sudo cp /home/pi/bluez-5.44/tools/btmgmt /usr/local/binso it can be used from anywhere.
- Enable BT low enegry with
btmgmt le on
hcitool lescanand 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.
- Test connectivity with
sudo gatttool -t random -b F1:37:57:6C:DE:64 -I
- at the prompt type
connectwhich should respond connected. Error 111 indicates that the adapter is not in LE mode (retry the btmgmt le on).
- Avoid having to use super user privileges (sudo) on hcitool by
sudo setcap 'cap_net_raw,cap_net_admin+eip' 'which hcitool'
- Avoid having to use super user privileges (sudo) on btmgmt by
sudo setcap 'cap_net_raw,cap_net_admin+eip' which btmgmt
- Install Pygatt 3.0.0 by
sudo apt-get install python-pipand
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
- Get the BS440 files by downloading the zip file from
https://github.com/keptenkurk/BS440and put them in a separate folder on the RPi like
- Enable the plugins of your choice by removing the underscore in the plugins folder for the .py and .ini files.
- 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
- Start BS440.py with
python BS440.py. Start a second shell and monitor the logfile with
tail -f BS440.log