Qwiic Scale Hookup Guide

Pages
Contributors: Nate
Favorited Favorite 5

How to Characterize Your Scale

You should have your scale hooked up, but there's one more step before we get measuring. It's time to teach your scale how much one thing weighs so it can tell how much everything else weighs!

Load cells have a linear response meaning their value changes in proportion to the force or weight applied to it. Remember the y = mx + b stuff you learned in school? It’s ok if you didn’t! The characterization of a scale looks like this:

  • Hookup the scale and get the Example1_BasicReadings.ino outputting a good, changing value.
  • Load Example2_CompleteScale.ino
  • Take everything off your scale and press ‘c’ to get a ‘zero’ reading
  • Place a known weight (can of soda, weight lifting plate, etc) on your scale and enter its value. For example, if you placed a 150 gram weight on your scale, enter 150.0.

That’s it. You can remove the known weight and weigh anything else you have lying around. But what’s really going on?

A graph showing the relationship between weight and the load cell reading

Instead of y = mx + b imagine weight = calibrationFactor * reading + zeroOffset.

The SparkFun library for the NAU7802 takes digital readings. These readings will vary from 10,000 to over 1 million. These values are unitless - the IC doesn’t know if there’s grams or lbs or stones on your scale, all it knows is the change in value. So when you remove all weight from your scale, there’s still a non-zero value being measured. We call this the zero offset (also known as the +b portion of the y = mx + b) and it’s set when you call the calculateZeroOffset() function. When you place a known weight on the scale and call the calculateCalibrationFactor(150.0) function the library will do the following math (and set the m portion of y=mx+b).

Let's say you measured 213417 with nothing on the scale. Once you added 150grams the scale measured 265412. From these numbers we can calculate the slope of the line:

language:latex
Zero offset = 213417
Calibration factor = (265412 - 213417) / 150 = 346.6333

We now know that for every change of 346 in the digital reading we are seeing a change of 1 gram. NEAT.

Now, whatever we put on the scale we can get its weight by extrapolating between the zero offset and the known weight. For example, if we put an unknown thing on the scale and get a reading of 244094 we know:

language:latex
244094 - 213417 = 30677

30677 / 346.633 = 88.4999

88.5 grams! Again, these values are unitless but as long as you know that the known weight was in grams, then the ‘weight’ is output in grams.