At the Restart Project in London we hold repair events where members of the public are invited to bring in all manner of electrical and electronic items for repair, so as to save them from landfill. A few months ago (at an event I didn't actually attend) someone brought in some faulty kitchen weighing scales which nobody could fix.
Never having seen inside any digital weighing scales and not knowing how they work, I took it as a challenge to research them, in the process, building two versions of my own.
If you wish to build your own weighing scales or incorporate a weighing function in a wider project, you can use this Instructable as a basis, whatever your requirements, from weighing fractions of a gram up to many kilograms.
Hence I will concentrate on the electronics, the software and the underlying principles. How you realise your own project is completely up to you.
I will also show you how to calibrate them, even if you don't have any standard weights.
Having done my research and having validated it by building my own scales, I wrote up the principles of weighing scales, including whatever I could deduce about fault-finding, in the Restart Project Wiki. Go and take a look!
Step 1: Choosing Your Load Cells
All digital weighing scales are built around either a 4-terminal load cell or four 3-terminal load cells. Which to get depends on what sort of scales you want to make. They are all electrically compatible and fairly cheap so you can change your mind later, or get more than one type to experiment with.
For kitchen or postal scales with a maximum load in the range of 100g to 10kg, you can get 4-terminal load cells consisting of an aluminium bar. This is mounted horizontally, supported at one end and supporting the weighing platform at the other. It has 4 strain gauges attached to it. I explain fully how it works in my wiki article so I shan't repeat it here.
These are less suitable for heavier loads such as bathroom scales, where a person's full weight, not necessarily centred on the platform, is better supported by 4 load cells supporting the 4 corners of the platform.
This is where four 3 terminal load cells are more suitable. Ones rated at 50kg each are widely available, which together will weigh up to 200kg.
Others with even higher ratings are designed for suspending the weight to be measured after the fashion of luggage scales
Step 2: What Else You Need
In addition to your load cell or load cells, you will need:
- An Arduino. You can use virtually any type you like but I used the Nano as it has the USB interface built-in and still only costs a few pounds.
- A HX711 module. This may come bundled with your load cell but is available very cheaply as a separate item from many sources.
- For prototyping, a 400 point breadboard, jumper leads, pin and socket strips.
You will also need wood, plastic, screws, glue, or whatever you require for your particular version of the project.
Step 3: Preparing the Parts
To use the HX711 module on the breadboard, solder a 4-wide pinstrip to the interface pins (GND, DT, SCK, VCC) of the HX711.
For easy connection and disconnection of the load cell (particularly if you're experimenting with more than one sort) solder a 6-wide pin socket strip to the analogue pins. (You only need the E+, E-, A- and A+ pins but I fitted a 6-wide strip anyway in case I wanted to experiment with the other two.)
If you are using a 4-wire load cell you will then need to solder the 4 leads from the load cell to a 4-wide pin strip. The first two pins will be E+ and E- and the other two A- and A+. I taped over the solder joints with PVC tape to protect them. A mark on one end and a corresponding mark on the pin socket means I know which way round to connect it, though I don't think it matters.
Different load cells colour code the wires differently, but it's easy to tell which is which. With a test meter on a resistance range, measure the resistance between each pair of wires. There are 6 possible pairs of 4 wires but you will only get 2 different readings. There will be 2 pairs which read 33% more than the other 4, say, 1,000Ω instead of 750Ω. One of those pairs is E+ and E- and the other is A+ and A- (but it doesn't matter which).
Once you get everything working, if the scale reads a negative weight when you put something on it, swap E+ and E-. (Or A+ and A- if it's easier. But not both!)
Step 4: How to Use 3-wire Load Cells
If you are using four 3-wire load cells you will have to wire them us together with a piece of stripboard, and take the E+, E-, A+ and A- connections from the combination.
Since the wire colours of yours may be different from mine, let's call the 3 wire colours of each load cell A, B and C.
With a test meter on a resistance range, measure the resistance between each pair of wires. There are 3 possible pairs, but you will only measure 2 different readings. Identify the pair that reads twice either of the other two. Call this pair A and C. The one you left out is B. (The resistance between B and either A or C is half the resistance between A and C.)
Simply stated, you need to wire the 4 load cells in a square, with the A wire of each connected to the A wire of its neighbour, and the C wire to the C wire of its neighbour on the other side. The B wires of two load cells on opposite sides of the square are E+ and E-, and the B wires of the other pair are A+ and A-
Step 5: Wiring Up the Breadboard
Wiring up the breadboard is very simple, needing only 4 jumpers. The Fritzing library only offered me a slightly different version of the HX711 module from mine but the wiring is the same. You can follow the diagram, or if you're using a different Arduino, wire it up as in the table below:Arduino Pin HX711 Pin 3V3 VCC GND GND A0 SCK A1 DT
Step 6: Mounting the Load Cells
The aluminium bar type of load cell has two threaded holes in each end. You can use one pair to mount it on a suitable base with a spacer in between. The other pair you can use in the same way to mount a weighing platform, again, with a spacer. Just for experimental purposes you can use whatever pieces of scrap wood or plastic you have to hand, but for a polished end product you will want to take more care.
The easiest way to mount the four 3-wire load cells is between two pieces of chipboard. I used a router to make 4 shallow indentations in the base so as to positively locate the four cells. In my case the indentations needed a slightly deeper central well so that two rivets on the bottom didn't rest on the base.
I used a hot melt glue gun to hold the load cells in place on the base and also to fix the stripboard onto the base in the middle. I then pressed the weighing platform hard down on them so that the pimples on the tops of the load cells made slight indentations. I deepened these with the router and checked they still aligned nicely with the load cells. I then put hot melt glue on and around each indentation and quickly pressed the weighing platform onto the load cells before the glue hardened.
Step 7: Programming the Arduino
I assume you have the Arduino IDE installed on your computer and know how to use it. If not, check out one of the many Arduino tutorials - that is not my purpose here.
From the IDE drop-down menus, select Sketch - Include Library - Manage Libraries...
Type hx711 in the search box. It should find HX711-master. Click Install.
Download the attached file HX711.ino example sketch. From the IDE File drop-down menu, open the file you just downloaded. The IDE will say it needs to be in a folder - allow it to put it in one.
Compile and upload the sketch, then click on the serial Monitor in the IDE.
Below is some example output. In the initialisation phase it displays an average of 20 raw readings from the HX711, then sets the tare (i.e. the zero point). After this it gives a single raw reading, an average of 20 and an average of 5 less the tare. Finally, an average of 5 less the tare and divided by the scale factor to give a calibrated reading in grams.
For each reading it gives the calibrated average of 20, and the standard deviation. The standard deviation is the rage of values within which 68% of all measurements are expected to lie. 95% will lie within twice this range and 99.7% within three times the range.It's therefore useful as a measure of the range of random errors in the result.
In this example, after the first reading I placed a new pound coin on the platform, which should weigh 8.75g.
HX711 Demo<br>Initializing the scale Raw ave(20): 1400260 After setting up the scale: Raw: 1400215 Raw ave(20): 1400230 Raw ave(5) - tare: 27.00 Calibrated ave(5): 0.0 Readings: Mean, Std Dev of 20 readings: -0.001 0.027 Time taken: 1.850Secs Mean, Std Dev of 20 readings: 5.794 7.862 Time taken: 1.848Secs Mean, Std Dev of 20 readings: 8.766 0.022 Time taken: 1.848Secs Mean, Std Dev of 20 readings: 8.751 0.034 Time taken: 1.849Secs Mean, Std Dev of 20 readings: 8.746 0.026 Time taken: 1.848Secs
Step 8: Calibration
The Arduino sketch in the previous step contains two calibration values (or scale factors) relating to my 1kg and my set of four 50kg 3-wire load cells. These are on lines 19 and 20. You will need to perform your own calibration, starting with any arbitrary calibration value such as 1 (on line 21).
I didn't have any standard weights, so for the 1kg load cell I used a new £1 coin, which weighs 8.75g. Ideally you should use something weighing at least a tenth of the scale's maximum.
Find something - anything - of a roughly suitable weight. Take it down to your local post office, pretend you need to post it, and put it on the scales there and make a careful note of the weight. Or you could take it to a trader such as a friendly local greengrocer. Any reputable trader should have their scales calibrated regularly to comply with trading standards.
You now have an object of known weight. Place it on your scales and note the reading. Multiply your current scale factor by the reading you got and divide the result by what the reading should have been, whether in grams, kilograms, pounds, micro-elephants or whatever units you choose. The result is your new scale factor. Try your know weight again, and if necessary, repeat the process.