Build it step by step
0 of 7 doneMount the load cell
Fix one end to a base and put a platform on the other end.
Wire the HX711
VCC and GND, DT to D4, SCK to D5, and the four load cell wires.
Wire the display and button
OLED to A4 and A5, button D2 to GND.
Install the libraries
HX711, SSD1306 and GFX.
Calibrate
Put a known weight on and find the factor from the raw value.
Zero the empty cup
Press the button.
Fill to the mark
Read the density of each liquid.
How do you build a liquid density meter?
A load cell and an HX711 weigh a cup filled to a mark and a Nano works out the density, so you can compare water, salt water and sugar water. You need Arduino Nano, HX711 load cell amplifier, Load cell 1 kg, SSD1306 OLED Display, Tactile push button 6 mm, Jumper wires male to male (40 pcs, 20 cm) and Breadboard 830 Tie Points. It takes 7 steps and about 150 minutes.
- Level
- Intermediate
- Time
- About 150 min
- Parts
- 7
Parts list
- Development BoardsBuyArduino Nano × 1
- SensorsBuy
- SensorsBuyLoad cell 1 kg × 1
- DisplaysBuy
- SwitchesBuy
- PrototypingBuy
- PrototypingBuy
Tick what you already own. It saves to My Garage, so “Build with what I have” knows.
Wiring
| From | To | Why |
|---|---|---|
| HX711 VCC | Nano 5V | Power at 5 V |
| HX711 GND | Nano GND | Common ground |
| HX711 DT | Nano D4 | Data |
| HX711 SCK | Nano D5 | Clock |
| Load cell red | HX711 E+ | Bridge excitation plus |
| Load cell black | HX711 E- | Bridge excitation minus |
| Load cell white | HX711 A- | Signal minus (swap with A+ if the weight reads negative) |
| Load cell green | HX711 A+ | Signal plus |
| OLED SDA and SCL | Nano A4 and A5 | I2C, address 0x3C (VCC and GND to 5V and GND) |
| Tare button | Nano D2 and GND | Zeros the empty cup |
Code
Density is mass divided by volume. A load cell is a metal bar with strain gauges on it that change resistance when it bends, and the HX711 is an amplifier and converter that turns the tiny signal into a number. A cup on a platform on the load cell lets the Nano weigh what you put in it. Fill the cup exactly to a mark, which is a known volume such as 100 millilitres measured with a syringe, press the tare button with the empty cup on to zero the scale, then weigh each liquid. Fresh water gives about 1.00 grams per millilitre, and salt water gives more, for example about 1.07 for a heavy solution. To calibrate, put a known weight such as a 100 gram standard on the platform, read the raw number in the Serial Monitor, divide it by the weight and enter that as the calibration factor in the sketch. Do not put more than a kilogram on the load cell, and do not press hard on it, because it bends only a tiny amount. Keep liquids well away from the electronics and clean up any spill at once. Results are good to a percent or two at best, which is enough to tell water, salt water and sugar water apart.
Runs on a virtual Arduino Nano in your browser, with sliders for the sensors. Happy with it? Verify and upload to your real board from the same page (Chrome or Edge on a computer).
#include <Wire.h>
#include <HX711.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
HX711 scale;
Adafruit_SSD1306 oled(128, 64, &Wire, -1);
const int DT = 4, SCK_PIN = 5, TARE_BUTTON = 2;
const float CAL_FACTOR = 420.0; // change after calibrating with a known weight
const float CUP_VOLUME_ML = 100.0; // the volume up to the fill mark, measured with a syringe or cylinder
void setup() {
pinMode(TARE_BUTTON, INPUT_PULLUP);
Serial.begin(9600);
scale.begin(DT, SCK_PIN);
scale.set_scale(CAL_FACTOR);
scale.tare();
Wire.begin();
if (!oled.begin(SSD1306_SWITCHCAPVCC, 0x3C)) { while (true) {} }
}
void loop() {
if (digitalRead(TARE_BUTTON) == LOW) {
scale.tare(); // set the empty cup as zero
delay(300);
}
float grams = scale.get_units(10); // average of ten readings
float density = grams / CUP_VOLUME_ML; // grams per millilitre
Serial.print("raw ");
Serial.print(scale.get_value(10));
Serial.print(" grams ");
Serial.println(grams);
oled.clearDisplay();
oled.setTextColor(SSD1306_WHITE);
oled.setTextSize(1);
oled.setCursor(0, 0);
oled.print("Liquid in the cup");
oled.setTextSize(2);
oled.setCursor(0, 16);
oled.print(grams, 1);
oled.print(" g");
oled.setCursor(0, 38);
oled.print(density, 3);
oled.setTextSize(1);
oled.print(" g/mL");
oled.setCursor(0, 56);
oled.print("Press button: zero");
oled.display();
}What the serial monitor should show
Open the serial monitor at the baud rate in the code. This is what our simulator prints for a virtual Arduino Nano with its sensors at their default values. Your numbers will follow your real readings, but the format should match.
raw 0 grams 0.00
Test checklist
What you should see at each check. If a reading is far off, stop and use the troubleshooting list.
| Check | Expected |
|---|---|
| Empty cup after tare | 0 g |
| Known weight on the platform | Matches within a gram |
| Cup of tap water to the mark | About 1.00 g/mL |
| Cup of salt water | Higher than water |
| Press the button on the empty cup | Back to zero |
If it does not work
Reading is negative
Swap the A+ and A- wires.
Reading drifts
Wait for the load cell to warm up and keep it away from drafts.
Wrong by a fixed factor
Recalibrate with a known weight.
Jumpy numbers
Fix the load cell firmly and keep wires still.
Display blank
Check the OLED address 0x3C.
Still stuck? Find the fault step by step with your multimeter →
Common questions
What parts do I need for the liquid density meter?
Arduino Nano, HX711 load cell amplifier, Load cell 1 kg, SSD1306 OLED Display, Tactile push button 6 mm, Jumper wires male to male (40 pcs, 20 cm) and Breadboard 830 Tie Points.
How long does the liquid density meter take to build?
About 150 minutes for a intermediate maker, in 7 steps.
How do I know the liquid density meter works?
Empty cup after tare: 0 g. Known weight on the platform: Matches within a gram. Cup of tap water to the mark: About 1.00 g/mL.
Reading is negative: what should I check?
Swap the A+ and A- wires.
Reading drifts: what should I check?
Wait for the load cell to warm up and keep it away from drafts.
Wrong by a fixed factor: what should I check?
Recalibrate with a known weight.
Jumpy numbers: what should I check?
Fix the load cell firmly and keep wires still.
