Skip to content

Part 3. The Final Script

jrbail01 edited this page Apr 8, 2016 · 5 revisions

Assuming you ran the "git clone https://github.com/InitialState/smart-scale.git " command in Part 2, the final script that puts everything together is called smartscale.py in your ~/smart-scale directory. (https://github.com/InitialState/smart-scale/blob/master/smartscale.py)

A few settings need to be set in the script before you can run it. Open up smartscale.py in your favorite text editor such as nano.

$ cd ~
$ cd smart-scale
$ nano smartscale.py

Near the top of this file, there is a User Settings section.

# --------- User Settings ---------
BUCKET_NAME = ":apple: My Weight History"
BUCKET_KEY = "weight11"
ACCESS_KEY = "PLACE YOUR INITIAL STATE ACCESS KEY HERE"
METRIC_UNITS = False
WEIGHT_SAMPLES = 500
THROWAWAY_SAMPLES = 100
WEIGHT_HISTORY = 7
# ---------------------------------
  • BUCKET_NAME sets the name of the Initial State data bucket that your weight/data will be streamed into. This can be set here and changed later in the UI.
  • BUCKET_KEY is the unique bucket identifier that specifies where your data will stream into. If you want to create a different bucket/dashboard, use a different identifier here (*note, if you archive a bucket, you cannot reuse its key in a new bucket).
  • ACCESS_KEY is your Initial State account key. If you do not put your ACCESS_KEY in this field, your data will not show up in your account.
  • METRIC_UNITS allows you to specify your weight in kg if set to True or lb if set to False.
  • WEIGHT_SAMPLES specifies how many measurements are taken and averaged together to get your actual weight. 500 measurements takes about 4-5 seconds and provides fairly accurate results.
  • THROWAWAY_SAMPLES specifies the number of samples that are thrown away when you first step on the board. This prevents the initial steps and shifting from throwing off the final measurement. This should always be much less than WEIGHT_SAMPLES.
  • WEIGHT_HISTORY sets the number of measurements taken before an extra update is sent. Only measurements taken two hours or more apart count toward the history.

Once you have specified each parameter in this section and saved your changes, you are ready to run the final script. Before we run the script, let's go through what it is going to do.

  • At the start of the script, you will be asked to pair your Wii Balance Board with your Raspberry Pi. Use the lever that you hacked together in section Part 2: Hardware Tweaks to press the sync button when prompted.
  • Once the script is running, step on the Wii Board to begin measuring your weight. After a 4-5 seconds, your weight will be automatically sent to your Initial State account.
  • After we setup SMS notifications (in a couple of steps), you will receive a text message soon after your measurement.

Run the script to start the magic.

$ sudo python smartscale.py

<< Part 3: Initial State - Part 3: Dashboard >>