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
Useful materials for the Raspberry Pi
Other useful materials
Step 1: Project Overview
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.
Step 2: Project Overview: How Digital Scales Work
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.
Step 3: Project Overview: Hacking the Digital Scale
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.
Step 4: Scale Circuitry: Disassemble the case
Remove the screws on the underside of the scale. Pull off the scale's top case.
Step 5: Scale Circuitry: Cut the Wiring
My scale has four 3-wire load cells. Each load cell has a blue, a red, and a white wire, where
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.
Step 6: 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.
Step 7: Scale Circuitry: Remove the Scale's PCB and LCD
Remove the scale's PCB and LCD from the lid.
Step 8: Scale Circuitry: Power
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.
Step 9: Scale Circuit: Voltage Regulator
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.
Step 10: Scale Circuitry: Load Cell Wheatstone Bridge
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.
Step 11: Scale Circuitry: Instrumental Amplifier
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.
Step 12: Scale Circuitry: MC3008 ADC Convertor
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.
Step 13: Scale Modification: Remove the Display Cover
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).
Step 14: Scale Modification: Cut the Exterior
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.
Step 15: Scale Modification: Replace the display cover
With a hand saw, cut about 1" of plastic off the lip of the display cover. Place back onto the scale case.
Step 16: Project Overview: Audio
This section covers how to record audio files and amplify audio output from the Raspberry Pi.
Step 17: Audio: Recording Comments
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.
Step 18: Audio: Circuit
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.
Step 19: Project Overview: Raspberry Pi (RPi)
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.
Step 20: 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.
Step 21: 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
Step 22: RPi: Making the box
I used a project box from RadioShack to house the Raspberry Pi and the audio circuitry. I drilled holes into the box for wiring.
Step 23: Making the Power Switch
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.
Step 24: Putting It All Together: Connect Everything
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.
Step 25: Putting it all together: Callibration
In the code, uncomment the line:calibration()
under the section#CALIBRATION PROCEDURE
Run the code. When prompted withready for the zero lb calibration? y/n
enter 'y'. When prompted withready 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 withready 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.
Step 26: Putting it all together: Silly base
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.
Step 27: Silly Base: Trim the wood
Cut the wooden sheet down so the edges of the rug just fall over it.
Step 28: Silly Base: Cut out an opening
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.
Step 29: Silly Base: Glue the Rug
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.