Building a weight sensor - mitra42/frugal-iot GitHub Wiki

Building a weight sensor

This page describes how to build a basic weight sensor, using the Frugal-IoT system.

The instructions are for a system using a set of 4 load-cells (each with three wires), almost the same instructions should work for a single load-cell, and there is another pattern for a set of 4-wire load-cells in parallel (which I need to find!)

Construction

Prerequisites (tools)

  • PlatformIO or Arduino IDE and basic understanding of using it. Though I will provide instructions they may not be suitable for total beginners.
  • Soldering iron
  • Multimeter - you might get lucky, but its needed for troubleshooting
  • Glue or Glue gun
  • Screwdriver and some small screws.

Components

Item Cost Notes
Load Cell - set of 4 with brackets €4.18 I actually used the set without brackets, but this would be better.
Board to use as scales 0.00 - wood, strong glass for example. I used 300mm square plywood.
Dev board 3.00 you can use any of them, I am using the S2-mini but I have also used D1-mini-pro.

Note all prices are approximate, there may be better sources for the same or equivalent items.

Wiring

For wiring sensors to HX711, follow the notes that come with the product, as it differs depending on which cells are used and the colors of the wiring. In my case, red wires went to the HX711 in a specific order; and the black and yellow wires joined neighbors.

Line up the sensors to get the positioning, then fix the brackets to the board. I tried using a hot glue gun, but it wasn't strong enough for the legs, so a screw through the brackets worked.

Connect the HX711 to the dev board. With the lengths of wires I had, I needed to put the HX711 in the middle of the board, so the wires to the dev board were long, since I wanted the dev-board's USB port accessible. I used heat shrink to hold them together, and a blob of glue for positioning. The HX711 and Dev board are screwed to the main base.

HX711 S2 Mini or D1 series
3V3. 3.3V 3.3V
GND GND GND
DOUT 33 4
SCK 35 3

You can use other pin combinations, but if so you'll need to define SENSOR_LOADCELL_DOUTPIN and SENSOR_LOADCELL_SCKPIN in either platformio.ini or main.cpp

I started off leaving the underside exposed, but the wires are small, fragile and some broke. So I took a piece of perspex, drilled large holes for the feet to stick through. I then cut some roughly 20mm square and 11mm high seperators from some scrap wood, and screwed the perspex through these to the main board. Plywood would have worked as well as Perspex, but I wanted to see the inner workings. Note - that at 11mm seperation, this meant the perspex was not touching the ground, and all the weight was on the four legs.

Programming.

Follow the instructions at Programming and Configuring a Device on PlatformIO or Arduino IDE to set it up.

These instruction refer to an example, and you should use loadcell

Calibration

When you have the captive portal loaded (see instructions above), you should see a line with

Tare [                   ]

With nothing on the scale, hit Tare, this tells the controller what '0' is.

Then put a known weight on the scale, (I measured myself on a bathroom scale and used that) enter that weight into the box and hit Done or Enter/Return. This calibrates the scale.

Trouble shooting

This is a finicky project, small mistakes can make it not work. Here is some troubleshooting based on solving the problems I hit.

I'm assuming in all cases, that you have compiled with the -DSENSOR_LOADCELL_DEBUG in platformIO.

You should see something like this ...

LoadCell: read=-4852468.00 get_units=-1.21
loadcell raw:-1.21 converted -1.21

Where the top line is the loadcell raw reading, and the conversion, and the second line is Sensor_Float conversion (which does nothing on HX711).

  • If the first line remains static and around 8388607.00, even when you add weight, then the bridge is measuring "full saturation".

    • This could just be badly soldered wires, so check that its wired correctly based on the diagram that came with your product.
  • Check the voltages - from the GND at one end of the board to the connection points to the sensors.

    • E+ should be the system voltage - which is around 3.3
    • E- should be 0.
    • A+ and A- should be about half the supply
    • Measure the voltage between A+ and A-, it should be small, about 0.02v (20mV) between these two points. It should change with weight.
  • If GND <> E- is not 0, e.g. about 0.7 then it could be a problem with the HX711, there appear to be some (I had one) where GND and E- are erroneously not connected. Solder a wire between those two points. This fixed it for me.

We have seen drift, and a tendency to return low (sometimes negative) weights when there is nothing being measured. We don't have a good solution for this yet.

Getting help

If you get stuck - please open an issue on Github. you will need an account, but its free.