Introduction: Counting Scale Made With an Arduino

This project is still somewhat of a work in progress however it's reached a point where it's useful to share the details for others to benefit from it and the idea. It is basically a scale built using the Arduino as the microcontroller, a generic load cell, the HX711 signal amplifier and a 16x2 LCD screen.

Step 1: Parts You Will Need

You will need the following parts to complete this project. (available on Maker USA)

Arduino Nano (you could also use an Arduino Uno)

3KG Load cell

HX711 signal amplifier

16 x 02 LCD screen with I2c interface

DuPont cables

A breadboard

Some plywood and screws (Or you could just buy one of these kits )

You will need to assemble the load cell to float by anchoring it at the base end and place a platform on the load side that will be used to place the objects to be weighed. Alternatively, you could simply purchase a kit that includes the load cell, the HX711 with the load cell pre-assembled to perspex boards ready to use.

Step 2: Wiring Things Together

Use the diagram to connect everything up. For clarity I have written out the details below too.

Load cell To HX711

  • Red ---- E+
  • Black ---- E-
  • White ---- A-
  • Green ---- A+

The connections above depend on the load cell configuration

HX711

  • Gnd ---- Gnd
  • DT ---- A3
  • SCK --- A2
  • VCC ---- +5V

LCD

  • Gnd ---- Gnd
  • VCC ---- +5V
  • SDA ---- A4
  • SCL ---- A5

Tare button

  • Pin1 ---- +5V
  • Pin2 ---- D2 --- 10K resistor ---- Gnd

Count set button

  • Pin1 ---- +5V
  • Pin2 ---- D3 --- 10K resistor ---- Gnd

Step 3: Arduino Firmware - 1

The Arduino code uses the Q2HX711 and the LiquidCrystal_I2C libraries.

The Q2HX711 library initializes by taking the data and clock pin as a parameter

Q2HX711 hx711(hx711_data_pin, hx711_clock_pin);

The LCD library takes initialization takes the I2C address and the pins as a parameter

LiquidCrystal_I2C lcd(0x3F,16,2);

The two buttons are assigned to an interrupt in the setup so that they can perform the relevant functions

attachInterrupt(0, _doTare, CHANGE);<br>attachInterrupt(1, _doCount, CHANGE);

Step 4: Arduino Firmware - 2

The readingAverage returns the average raw reading value received from the HX711

long readingAverage(int samples=25,long t=0) {<br>	total=0;
for (int i=0;i<samples;i++) {
total=total+((hx711.read()/resolution)-t);
delay(10)
}
return (total / samples);
}<br>

Internally the program uses the raw values when displaying, it uses the conversion value to show the weight in grams, the correction value will depend on the load cell being used and needs to be tweaked accordingly.

The complete code is hosted on this Github repository

Step 5: Using the Scale to Count

Once you power up the Arduino, it initializes by setting the TARE value to the initial reading. The scale responds to any change in weight detect and updates the LCD display.

TARE function

You may want to zero the scale with a given wight on it, for example a bowl or some other container you plan to put objects in to measure but not include the weight of the container. Simply place the empty container and press the tare button and wait a few seconds till the read out displays zero with the container on the scale.

COUNT function

You can count objects with identical weight. You first need to set a seed value and teach the scale the weight of a single item. by default the scale is programmed to weight 25 items and calculate the weight of an item by dividing this weight by 25. Once set you can add or remove objects and the scale should accurately display the count of the items placed on it.

The PC software

Optionally the scale can be paired with a PC application to communicate the weight back to the PC application and to save item weights and to set item weights back to the scale. This is still work in progress and I am not sharing the PC application, but you can see a demonstration in the video below.

Step 6: Feedback

Let me have your feedback and feel free to use / modify the firmware. I would appreciate any suggestion for improvements.