LCD Display Problem/Question

I'm using a UNO with an HX711 to read from a load cell. It works as should and I get the correct readings in the serial monitor. The issue happens when it's displayed on the LCD.

My scale is reading in pounds at 1 unit increments. When testing the scale with anything under 10 pounds, it will weigh, display the correct weight and return to "0" on the LCD. If you go to 10 pounds or above - 2 digits, when the weight is removed the LCD will read like "02" where the "2" is tenths of a pound. If you go into the 100 pound range, when the weight is removed, the LCD will then have 3 digits on the screen, like "002" where the 2 is again 2/10 of a pound.

I would like the LCD to display only the whole number weight, all the time.

It's like once a digit gets "activated" on the LCD, it never turns off, just turns into a leading zero.

Any help will be appreciated, thanks in advance,

Randy B.


Show your code

Read the forum guidelines to see how to properly post code and some information on how to get the most from the forum.
Use the IDE autoformat tool (ctrl-t or Tools, Auto format) before posting code in code tags.

Try clearing the line, it sounds like residual numbers as the monitor works correctly.

#include "HX711.h"
#include <LiquidCrystal_I2C.h>

#define calibration_factor 1290.0 //This value is obtained using the SparkFun_HX711_Calibration sketch

#define DOUT  3
#define CLK  2
int TarePin=12;

HX711 scale;
LiquidCrystal_I2C lcd(0x26, 16, 2);

void setup() {
  lcd.setCursor(0, 0);
  lcd.print(" POUNDS WEIGHT");
  scale.begin(DOUT, CLK);

void loop() {
  Serial.print("Load Cell Output: ");
  Serial.print(int(scale.get_units() + .05));
  Serial.print(" pounds");

  lcd.setCursor(7, 1);

  lcd.print(int(scale.get_units() + .05));

int TareValue = digitalRead(TarePin);
  if(TareValue == LOW)
  lcd.init(); // initialize the lcd
  lcd.setCursor(1, 1);
  lcd.print(String("-- ZEROING --"));
  lcd.setCursor(0, 0);         // move cursor to   (0, 0)
  lcd.print(" POUNDS WEIGHT");        // print message at (0, 0)

    char temp =;
    if(temp == 't' || temp == 'T')
      scale.tare();  //Reset the scale to zero      


Do not use the clear() function in loop(), it can cause flicker because it is slow.

This example uses the setCursor(row, column) function and spaces to clear space of old data before writing new data.

// hd44780 library see
// thehd44780 library is available through the IDE library manager
#include <Wire.h>
#include <hd44780.h>                       // main hd44780 header
#include <hd44780ioClass/hd44780_I2Cexp.h> // i2c expander i/o class header

hd44780_I2Cexp lcd; // declare lcd object: auto locate & auto config expander chip

// LCD geometry
const int LCD_COLS = 16;
const int LCD_ROWS = 2;

void setup()
   lcd.begin(LCD_COLS, LCD_ROWS);
   lcd.print("Hello World");
   lcd.setCursor(0, 1);
   lcd.print("Millis ");

void loop()

void updateLCD()
   static unsigned long lcdTimer = 0;
   unsigned long lcdInterval = 500;
   if (millis() - lcdTimer >= lcdInterval)
      lcdTimer = millis();
      lcd.setCursor(8, 1);
      lcd.print("       "); // overwrite old data
      lcd.setCursor(8, 1);  // reset the cursor

What is this "String" business?

The reason you are seeing incorrect numbers on the display is that printing a number with fewer digits starts at the same cursor position, and only overwrites the number of digits needed by the current number, leaving any additions digits already on the display as-is. As an example, printing 123 will put 3 digits onto the LCD display, then printing 4 will result in 423, because only the first digit is overwritten.

Do not use lcd.init() more than once - that is for initializing the display, not clearing it. If you need to clear the entire display, that is what lcd.clear() is for.

Adding 0.05 to a float will round to the nearest tenth, not the nearest whole number.
If you want to print only the integer part of a float, with rounding, you can use lcd.print(scale.get_units(), 0); , where the 0 specifies no decimal places.

Thanks david_2018. I understand what you're saying about the LCD position.

I used the lcd.clear() as you recommended and used the lcd.print(scale.get_units(), 0); as you also recommended. It's working close to what I want now. Only issue now is that "zero weight" is displayed as "-0" and from 1-9 going up is displayed as "10,20,30,40,50,60,70,80,90" with a trailing zero. The trailing zero would be fine down in that low range but would need a decimal as to not look like "tens of pounds" when it's actually just 1 through 9 pounds.

Look at reply #6, the code shows how to print spaces over the previous number to blank out the previous digits.

The -0 is likely the result of rounding a number slightly below zero. You will get negative weights when you have a tare weight set and have nothing on a scale.

Thanks david_2018.

Yes, you were correct. That worked.

I think I have it working as I need it to now. I was a little over concerned with the negative numbers and was going to write a trap for negatives but then it occurred to me that this is an "S type" load cell that will be used for compression and tension... So... I'm good.

Thanks to everyone for their input and help!

But of course, you generally do not want to clear the entire display for two reasons, one being that then you have to re-draw everything and the other that doing so causes annoying flicker.

Yes I learned about the flicker the hard way.

This is the first time I’ve ever worked with an Arduino. I’ve had quite a bit of experience writing different languages of code in the financial industry over the years but this is the first time interfacing this type of hardware with it. So far it’s been enjoyable and a good learning experience.

Thank everyone for their quick responses to my post.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.