Motivational Bathroom Scale

by 10DotMatrix in Circuits > Raspberry Pi

62097 Views, 84 Favorites, 0 Comments

Motivational Bathroom Scale

4L1A4036.JPG
4L1A4039.JPG
4L1A4040.JPG
4L1A4049.JPG

Introducing the latest and greatest in health technology: the Motivational Bathroom Scale. Getting unwanted family comments about your recent weight gain? Now you can get criticized by both your family and your bathroom scale! Simply enter your goal weight with the keypad and step onto the scale. The scale compares your real weight with your goal weight. If you've been exercising extra at the gym, the scale gives you a flattering compliment. Otherwise, beware, this scale is very sassy.

The Motivational Bathroom Scale is made with a cheap bathroom scale hooked up to an amplifier and a Raspberry Pi. A numeric keypad plugs into the Pi's USB port. Sassy comments are stored on the Pi and played through 8-ohm speakers connected to an audio amplifier.

Materials for scale

Materials for Pi Case

Materials for audio (speakers plus amplifying circuit)

Materials for base

  • 24"x36"x3/16" piece of plywood
  • 34"x20" bath rug Target

Useful materials for the Raspberry Pi

  • External monitor
  • Mouse
  • Keyboard

Other useful materials

  • Electrical tape
  • Solder
  • 2-part epoxy

Project Overview

Screen Shot 2014-10-03 at 5.22.46 PM.png

To help you get a sense of how this project is designed, this Instructable is broken up into sections, each illustrated by a block in this flowchart. I will refer to this flowchart again and again as a roadmap.

Project Overview: How Digital Scales Work

IMG_9719.JPG
IMG_9716.JPG
IMG_9708.JPG
IMG_9709.JPG

The way a digital scale works is based on a component called a strain gauge. A strain gauge can be used to measure the force applied on an object.

When a material is pushed or pulled, it stretches or compresses. Take a diving board for example. If a swimmer stands at the end of a diving board, the board deforms. The bottom of the board compresses and the top stretches. Now image a wire is placed on top of the board. A wire acts like a resistor, and the longer the wire the higher the resistance. So if the wire is stretched on the diving board, its resistance goes up. The more force applied to the board, the higher the wire's resistance. This, in essence, is how a strain gauge operates.

We can see this for ourselves with a digital scale. Detach one of the 3-wire strain gauges from the bathroom scale. Connect its red wire to power, blue or black wire to ground, and white wire to the oscilloscope. Have a friend "pump" the strain gauge, or apply weight to it on and off. AC couple the oscilloscope and watch while the stain gauge's output voltage changes with force.

Project Overview: Hacking the Digital Scale

Screen Shot 2014-10-03 at 5.14.17 PM.png

This section covers how to rewire the strain gauges inside a digital scale, amplify strain gauge output, and enable a Raspberry Pi to read analog input.

Scale Circuitry: Disassemble the Case

IMG_9992.JPG
IMG_9993.JPG

Remove the screws on the underside of the scale. Pull off the scale's top case.

Scale Circuitry: Cut the Wiring

photo 1.JPG
IMG_9998.JPG

My scale has four 3-wire load cells. Each load cell has a blue, a red, and a white wire, where

  • red = V-in
  • white = V-out
  • blue = GND

Cut these wires (12 total) from the scale's PCB. Also snip away the power and ground wires running from the battery pack to the PCB.

There will be labels underneath the connections that were just snipped away. They read "E+, E-, S+, S-". On my board, these labels are underneath the connection between the white wires and the PCB. These labels stand for "Excite" and "Sense". I colored coded each white wire with a piece of colored tape to help me differentiate the load cells.

Scale Circuitry: Prepare the Wire

Solder a small piece of solid wire to the end of each stranded load-cell wire. Wrap a piece of electrical tape around the solder joint to protect it from breaking.

Scale Circuitry: Remove the Scale's PCB and LCD

IMG_0006.JPG
IMG_0007.JPG
IMG_9997.JPG

Remove the scale's PCB and LCD from the lid.

Scale Circuitry: Power

pop out battery.JPG

Swap out the scale's 4.5V battery pack for a 6V pack and scale it down with a 5V regulator. This feeds the circuit a constant 5V, ensuring that the scale calibration (which is described later) won't go wonky when batteries get low.

Scale Circuit: Voltage Regulator

IMG_9967.JPG
IMG_9968.JPG
IMG_9972.JPG
Screen Shot 2014-09-25 at 1.55.03 PM.png
IMG_9974.JPG

Bend the legs of a LM7805 voltage regulator at a right angle. Solder the legs down so the regulator lies flat against the board. Solder a 0.33 μF capacitor from the regulator's input pin to ground pin and a 0.1 μF capacitor from the regulator's output pin to ground pin. Solder in a AA 6V battery pack into the board and connect its red output wire to the regulator's input pin, and its ground to the regulator's ground pin.

Scale Circuitry: Load Cell Wheatstone Bridge

IMG_9784.JPG
fritzing wheatsone .png

Scales use a circuit known as a wheatstone bridge. A standard wheatstone bridge is composed of two voltage dividers in parallel. A wheatstone bridge makes it possible to measure small changes in resistance by measuring the voltage across the two dividers.

In this circuit, the scale's four load cells create the four legs legs of the wheatstone bridge. As the load cells are compressed, their output voltages vary minutely. This small difference in voltage will be correlated to the weight of a person on the scale. This small change in voltage is detected with the wheatstone bridge.

Wire the wheatstone bridge as illustrated in the Fritzing schematic. In my scale the R and W labels (which refer to the cell's red and white wires) are switched. Recall that the white wires attached to each load cell are labeled "E+, E-, S+" and "S-" for "Excite" and "Sense". The "Excite" wires are linked to the circuit's excitation source, and the "Sense" wires sense changes in weight.

Scale Circuitry: Instrumental Amplifier

AD620 circuit.jpg
photo (5) copy.jpg
IMG_9980.JPG

The wheatstone bridge only outputs a few mV when a person's full weight is applied. The analog-to-digital converter (ADC) used with the Raspberry Pi can only read 1024 divisions per 5V or,

5V/1024 steps = 5 mV/step

This means that the ADC's resolution is too large to detect the wheatstone's output voltage, so the output voltage must be amplified. I use an AD620 instrumental amplifier tuned to have a gain of 150.

Solder the connections as illustrated in the circuit diagrams included here.

Scale Circuitry: MC3008 ADC Convertor

mcp3008 circuit.png
IMG_9990.JPG
IMG_0010.JPG
IMG_0015.JPG
IMG_0020.JPG

The Raspberry Pi alone cannot read analog inputs like an Arduino or other microcontrollers. An analog-to-digital converter (ADC) is necessary for the Pi to read the AD620's output signal. A MCP3008 ADC chip acts like a bridge between the amplifier's analog output and the Pi's digital input. The MCP3008 is wired to two 1x13 male-to-male header pins that are soldered into the board. They act as a makeshift Raspberry Pi Cobbler. The header pins are connected with a ribbon cable to the Raspberry Pi. Look at the included circuit diagram for how to connect the MCP3008 to the Pi.

It easy to misconnect the header pins to the Pi. One edge of the ribbon cable has a white or red stripe. Connect the cable so the stripe is closest to the SD card on the Pi. The cable's connection to the header pins on your circuit board may differ depending on your wiring.

I also decided to put a small piece of paper underneath the circuit to prevent any shorts.

Scale Modification: Remove the Display Cover

IMG_9761.JPG
IMG_9762.JPG
IMG_9763.JPG

The scale's plastic top has been sitting off to the side while I've been hacking the base's load cells. It is now time to modify the top.

Take the white plastic top and pop off the plastic display cover. Flip the top over and unscrew the platform that held the 7-segment display (the screws are circled in red).

Scale Modification: Cut the Exterior

IMG_9766.JPG
IMG_9767.JPG
IMG_9769.JPG
IMG_9770.JPG

Draw two parallel lines running down the front edge of the scale top. Use masking tape as a guide to draw straight lines.The distance between them should be slightly larger than the width of the ribbon cable.

Secure the scale top in a vice and saw along the lines to cut out a chunk of scale.

Scale Modification: Replace the Display Cover

IMG_9772.JPG
IMG_9773.JPG
IMG_9775.JPG

With a hand saw, cut about 1" of plastic off the lip of the display cover. Place back onto the scale case.

Project Overview: Audio

Screen Shot 2014-10-03 at 5.16.07 PM.png

This section covers how to record audio files and amplify audio output from the Raspberry Pi.

Audio: Recording Comments

Screen Shot 2014-09-28 at 10.38.56 AM.png
Screen Shot 2014-09-28 at 10.39.35 AM.png

I recorded audio clips of mean and nice comments for my scale. The mp3 files are included here. Make a folder on your computer desktop called 'comments'. Download these audio files and put them into 'comments'. Insert the Raspberry Pi SD card into your computer and copy comments into it.

If you wish instead to record your own sassy comment follow these instructions:

If you don't have it already, download Audacity here. Audacity is a free and easy-to-use audio editor that runs on any operating system. Also download the LAME mp3 encoder here so you can generate mp3 files through Audacity. Open Audacity and press the circular red button in the upper left-hand corner to record your comment. When you are finished, press the yellow stop button in the upper left-hand corner. Save each section of sound as a separate mp3 file by selecting it with your cursor and using the 'File' -> 'Export Selection' command.

Audio: Circuit

Screen Shot 2014-09-18 at 5.11.28 PM.png
Screen Shot 2014-09-18 at 3.27.17 PM.png
IMG_9886.JPG
IMG_9920.JPG
Screen Shot 2014-09-18 at 2.39.35 PM.png

The Raspberry Pi is known for being good at playing audio and video. The board comes with a 3.5 mm audio jack for ear buds or active speakers. However, the audio jack cannot feed passive speakers enough power to drive them directly. To connect passive speakers to the Pi's audio jack, the Pi's audio output must be amplified with an audio amplifier circuit.

Follow the included circuit diagram to create an audio amplifier for the Pi. I use LM386 audio amplifier chip to amplify the Pi's audio output and power the chip with a 9V battery. Small 8-ohm speakers I got from RadioShack play the amplified comments. Instead of soldering the speakers directly into the board, use a 2-pin screw terminal to connect the speakers to the circuit. It will become clear why this is necessary in later steps.

Project Overview: Raspberry Pi (RPi)

Screen Shot 2014-10-03 at 5.14.49 PM.png

This section covers how to configure the Raspberry Pi, download libraries, and connect all the different parts in the sassy scale to the Raspberry Pi.

The brains of the project are in the program weight_v3.py, provided here. Download this file to your computer, save it on a flash drive, plug the flash drive into a USB port on the Pi, and copy the code onto the Pi's desktop.

Downloads

RPi: Configure

There are already many good Raspberry Pi setup tutorials online, so I won't go into detail here. I followed Scott Kildall's wonderful Instructable to set mine up. Make sure to enable user privileges by following the instructions here. Also follow this guide set the Pi's audio output to headphone jack.

RPi: Install Libraries

Several libraries must be installed on the Raspberry Pi for the sassy scale program to operate correctly.

Below is a list of downloads, how to download them (or links to instructions), and why they are useful:

Git
sudo apt-get install git
for downloading other libraries
GPIO librarysee installation guide herefor external hardware
PyGamesee installation guide herefor audio
Numpysee installation guide herefor calibration

RPi: Making the Box

IMG_0022.JPG
IMG_0037.JPG

I used a project box from RadioShack to house the Raspberry Pi and the audio circuitry. I drilled holes into the box for wiring.

Making the Power Switch

usb cord.JPG
IMG_9864.JPG
IMG_9867.JPG
IMG_9869.JPG
IMG_9872.JPG
IMG_9877.JPG
IMG_0047.JPG
IMG_9879.JPG
IMG_9880.JPG
IMG_9882.JPG

Snip a usb to mini usb cord in half and strip away about an inch of insulating rubber. Four wires will be exposed on each half. Snip away wires that are not power (red) or ground (black). Strip the ends of the power and ground wires. Solder the power wires to each side of the rocker switch and tape over with electrical tape to avoid shorts. Next, solder the ground wires to each other and wrap with electrical tape. To protect the solder joints, wrap all connections one more time with electrical tape. The power switch is complete.

Thread the wires on the end of the switch through the box opening from front to back. Push the switch into the case, and screw the switch down to the box wall.

Putting It All Together: Connect Everything

IMG_0043.JPG
IMG_0057.JPG
IMG_0049.JPG
IMG_0040.JPG
IMG_0063.JPG
IMG_0066.JPG
IMG_0070 copy.JPG
IMG_0073.JPG
IMG_0075.JPG
IMG_0079.JPG
IMG_0081.JPG
IMG_0083.JPG

Plug the connector from the circuit board in the scale through the slot in the RPi box and plug into RPi's GPIO pins.

Plug mini usb connected to the switch into RPi's power. Thread the other side of the usb through the hole in the back and plug it into the wall adapter.

Thread keyboard through hole on the top of the box and plug into RPi USB port.

Plug audio jack from audio amp circuit into the pi.

Thread the two 8-ohm speakers into the two holes in the box top and using and flat-head screwdrive screw them down into the terminal connectors

Stuff everything into the box and place the top on.

Putting It All Together: Callibration

Screen Shot 2014-10-03 at 4.35.15 PM.png
IMG_0085.JPG
IMG_9934.JPG

In the code, uncomment the line:

calibration()

under the section

#CALIBRATION PROCEDURE

Run the code. When prompted with

ready for the zero lb calibration? y/n

enter 'y'. When prompted with

ready for the three lb calibration? y/n

place a 3 lb exercise weight on the center of the scale and then enter 'y'. Finally when prompted with

ready for the ten lb calibration? y/n

place a 10 lb exercise weight on the scale and type 'y'.

The code will run a linear regression create the coefficients for a linear function. This function will be used to convert voltage to weight in pounds.

Putting It All Together: Silly Base

IMG_9724.JPG

This base holds both the RPi case and the scale. But, because everyone keeps their scales in the bathroom, the base is decorated with a bathroom shag rug.

Silly Base: Trim the Wood

IMG_9727.JPG

Cut the wooden sheet down so the edges of the rug just fall over it.

Silly Base: Cut Out an Opening

IMG_9735.JPG
IMG_9739.JPG
IMG_9743.JPG
IMG_9744.JPG

Place the scale and Raspberry Pi case in the center of the rug and trace around them. Cut around the trace with a pair of shears or an X-Acto knife.

Silly Base: Glue the Rug

IMG_9749.JPG
IMG_9751.JPG
IMG_9752.JPG
IMG_9758.JPG

Mix quarter-sized dollops of two-part epoxy and spread across the top of the wood sheet. Lay the rug on top of the epoxy and weigh it down with with weights (I used two heavy boxes). Let the epoxy dry for at least half an hour.