Arduino Tutorial: HX711 Load Cell Amplifier (Weight Sensor Module) + LCM1602 IIC V1 LCD

In this tutorial, it is shown how to utilize an Arduino Uno, a HX711 breakout board, and a load cell in order to measure weight. Moreover, an LCD module of type LCM1602 IIC V1 is used to display the measured weight.

List of materials:
– Arduino Uno [Search on Aliexpress | Amazon | eBay.com]
– Jumper wires [Search on Aliexpress | Amazon | eBay.com]
– HX711 Load Cell Amplifier [Search on Aliexpress | Amazon | eBay.com]
– Load Cell [Search on Aliexpress | Amazon | eBay.com]
– LCM1602 IIC V1 (LCD) [Search on Aliexpress | Amazon | eBay.com]
– Small squared timber and screws

A load cell (left hand side) and an HX711 breakout board (right hand side).

A load cell (left hand side) and an HX711 breakout board (right hand side).

The HX711 is a 24-bit analog-to-digital converter which fits perfectly to weight scale applications. Fortunately, there exist many breakout boards for the HX711. Therefore, it is very easy to use it in combination with a so-called load cell. Load cells are transducers that convert pressure/force into an electrical signal. As the electrical signal has typically only a few millivolts, it has to be amplified. And that’s where the HX711 breakout board comes in:  as it amplifies the weak signal to a few volts so that we can read the signal with the help of an Arduino Uno.

Preparations for Wiring:
In order to easily connect the load cell to the pins of the HX711 module, you can add DuPont connectors to the wires. This step is totally optional. You can use whatever you want to connect the wires to module’s pins. If you use DuPont connectors, keep in mind that such load cells often have thin single-strand wires. I used the help of some solder to attach the thin wires more tightly to their connectors.

Preparation of crimping tools, raw connectors, and shells in order to add DuPont connectors to the wires of the load cell. As a result, the load cell can be easily connected to the HX711 breakout board.

Preparation of crimping tools, raw connectors, and shells in order to add DuPont connectors to the wires of the load cell. As a result, the load cell can be easily connected to the HX711 breakout board.

Preparation of crimping tools, raw connectors, and shells in order to add DuPont connectors to the wires of the load cell. As a result, the load cell can be easily connected to the HX711 breakout board.

Load cell with DuPont connectors.

You will retrieve consistent pressure values from the load cell, if you mount the load cell on something that is solid and heavy. I used a part of an old squared timber for this task:

Load cell mounted on squared timber.

Load cell mounted on squared timber.

Wiring:

Fritzing file that shows how to connect the load cell to the HX711 module. Moreover, it is shown how to connect the HX711 module and the LCM1602 IIC v1 (LCD) module to the Arduino.

Fritzing file that shows how to connect the load cell to the HX711 module. Moreover, it is shown how to connect the HX711 module and the LCM1602 IIC v1 (LCD) module to the Arduino.

First, the load cell is connected to the HX711 module. The load cell has four wires, which must be connected to the first four pins of the HX711 module: Red wire to E+, black wire to E-, white wire to A-, and green wire to A+. The remaining pins, B- and B+, can be used if a second load cell has to be connected to the HX711 module.
Next, the HX711 module is connected to the Arduino Uno. The module’s GND pin must be connected to the Arduino’s GND pin. DT and SCK must be connected to digital pins of the Arduino. In this tuorial, DT is connected to digital pin #4 and SCK is connected to digital pin #5. The remaining pin VCC must be connected to the 5V pin of the Arduino. As the LCM1602 module requires also a connection to the 5V pin, a breadboard is used in-between to split the Arduino’s 5V signal.
As a last step, the LCM1602 module’s SDA and SCL pins must be connected to the corresponding SDA and SCL pins of the Arduino Uno. Moreover, the GND pin must be connected to one of the Arduino’s GND pins and the VCC pin has to be connected to the 5V signal of the breadboard.

Example source code:

// (c) Michael Schoeffler 2017, http://www.mschoeffler.de
#include <HX711_ADC.h> // https://github.com/olkal/HX711_ADC
#include <Wire.h>
#include <LiquidCrystal_I2C.h> // LiquidCrystal_I2C library

HX711_ADC LoadCell(4, 5); // parameters: dt pin, sck pin<span data-mce-type="bookmark" style="display: inline-block; width: 0px; overflow: hidden; line-height: 0;" class="mce_SELRES_start"></span>
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); // 0x27 is the i2c address of the LCM1602 IIC v1 module (might differ)

void setup() {
  LoadCell.begin(); // start connection to HX711
  LoadCell.start(2000); // load cells gets 2000ms of time to stabilize
  LoadCell.setCalFactor(999.0); // calibration factor for load cell => strongly dependent on your individual setup
  lcd.begin(16, 2); // begins connection to the LCD module
  lcd.backlight(); // turns on the backlight
}

void loop() {
  LoadCell.update(); // retrieves data from the load cell
  float i = LoadCell.getData(); // get output value
  lcd.setCursor(0, 0); // set cursor to first row
  lcd.print("Weight[g]:"); // print out to LCD
  lcd.setCursor(0, 1); // set cursor to secon row
  lcd.print(i); // print out the retrieved value to the second row
}

 

Calibration

The last step is to calibrate the weighing scale. This steps becomes very easy if you have some calibration weights. Unfortunately, I do not have such weights. Therefore, I used an alternative approach to calibrate my weighing scale. First, I grabbed another weighing scale and put something on it (dc motor):

Then I put the dc motor on my weighing scale. Next, I adapted the parameter of the setCalFactor method (see setup function) until the correct weight was shown on my weighing scale. Keep in mind, each load cell and setup needs a different calibration factor. Therefore, it makes no sense to tell you mine.

In order to check whether my calibration factor is working, I did the same thing again with something else (screwdriver):

Overall, I’m satisfied with the accuracy:

Video Tutorial:

34 thoughts on “Arduino Tutorial: HX711 Load Cell Amplifier (Weight Sensor Module) + LCM1602 IIC V1 LCD

  1. Arnold

    Respected sir,
    when I had compiled your code I was getting an error about ” positive ” on 7th line of the code will you please help me with it.
    Thank u sir.

    Reply
  2. Koushik koley

    I have used 16*2 liquidcrystal dispaly..but the weighting value in display does not set to zero after the load is removed..plz help me out by clearing the display for 16*2 lcd diplay

    Reply
  3. Jim Sauer

    Cannot get code to compile. Get following error message:
    Arduino: 1.8.1 (Windows 10), Board: “Arduino/Genuino Uno”

    The sketch name had to be modified. Sketch names can only consist
    of ASCII characters and numbers (but cannot start with a number).
    They should also be less than 64 characters long.

    C:\Users\Dell\Documents\Arduino\load_cell_1\load_cell_1.ino:2:61: fatal error: HX711_ADC.h: No such file or directory

    #include // https://github.com/olkal/HX711_ADC

    ^

    compilation terminated.

    exit status 1
    Error compiling for board Arduino/Genuino Uno.

    This report would have more information with
    “Show verbose output during compilation”
    option enabled in File -> Preferences.

    Can you help me? I’m a beginner.

    Reply
  4. srikant

    sir i have arduino uno, hx711, lcd key pad sheild, and i am facing the problam with programing . i need program as a arduino scale load cell hx711 with alrt . also i have realy . so sir please help me. and if you scatch make for me .i will thanking to you.

    Reply
  5. Allan

    Hello, i don’t know whats happen with my load cell.
    but when i try to read your data (LoadCell.getData()) the number start in zero and increasing by yourself, i don’t have the same reaction like you.

    do you know why this happens?

    Reply
  6. Diosdado Illut Jr

    Hello! Good day Sir! I need your help for my school project. I just want to know what is the code if ever the display on the LCD is 1kilogram then it will make the light on. if ever it is half kilo then it will run the motor. I am looking forward for your response Sir. Thank you for sharing your knowledge!

    Reply
  7. PRIYAL

    POSITIVE WAS NOT DECLARE IN THIS SCOPE……………..THIS TYPE OF ERROR IS ACCUR….WHAT IS SOLUTION?????????????

    Reply
  8. Saowapak

    Hello, I am thai student. I do my project about weighing scale as yours. I connected everything as you did and wrote the code as yours. But I changed only the calibration factor is 33814. For loadcell, I used 60kgs. But I got a problem when I put the object 5kgs on the loadcell but I got 10 g/kgs (I am not sure about your scale). I thought the weight that show is increase double.

    – Thank you for your support –

    Reply
  9. Shahin Afshari

    Thank you very much for the nice video, it was really good.
    Thank you for the instructions. I would like to do this with mini Arduino, does the wiring diagram changes?
    Also, in addition to LCD display, I would like data to be recorded in SD card? How can I add the SD card recorder?
    Finally, how can a tear push bottom can be add to the system?

    Sincerely,

    Shahin

    Reply
  10. Horst S.

    I dont get your scale Faktor why did you put in 20.000?
    an you please explain why you write that 20000 while meassure 54260 g ?

    Reply
  11. Romi Thomas

    thankyou for the tutorial..but i have a problem …because when i want uploading the programe my lcd was blacklight

    Reply
  12. Brendan

    hello im trying to recreate your set up but i keep getting an error of – ‘POSITIVE’ was not declared in the scope and im just wondering what LiquidCrystal_I2C library you used

    Reply
    1. mschoeffler Post author

      There might be something wrong with the LiquidCrystal_I2C -> look for another variant of the library and/or check whether the library is correctly installed (sorry, I do not have my library in reach right now)

      Reply
  13. STEPHEN VOWELL

    I get a error when I compile.your code.. Can you help
    error: ‘POSITIVE’ was not declared in this scope
    LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); // 0x27 is the i2c address of the LCM1602 IIC v1 module (might differ)

    Reply
    1. mschoeffler Post author

      It might have something to do with a wrongly installed LiquidCrystal_I2C library (or the wrong version/variant of LiquidCrystal_I2C was installed)

      Reply
  14. valmir queiroz

    hello michael, I loved your project and I had an idea but I couldn’t make it work send the weight via modbus rs232 protocol, could you help me, thanks!!!!!!
    i’m from Brasil

    Reply
  15. durai

    Arduino: 1.8.12 (Windows Store 1.8.33.0) (Windows 10), Board: “Arduino Uno”

    sketch_feb17a:7:53: error: ‘POSITIVE’ was not declared in this scope

    LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); // 0x27 is the i2c address of the LCM1602 IIC v1 module (might differ)

    ^~~~~~~~
    sir while compiling the source code am receiving this message…
    ‘exit status 1
    ‘POSITIVE’ was not declared in this scope,

    This report would have more information with
    “Show verbose output during compilation”
    option enabled in File -> Preferences.

    Reply
  16. Surya

    Michael I really appreciate the simple programming.
    I and new to this and had been running around in circles to get this working.

    Reply
  17. Lukmas Andreas

    Her Schoffler guten tag.Ich schreibe Ihnen fon Griechenland,und Ihre waage die durch arduino funkzuniert ist sehr indresand.Ich bin imker und mochte eine solche bauen,fur die bienenkaste zu wiegen.Ich wahr in Deutschland vor viele viele jahre,in Baden Wurtemberg,bei firma Bauknecht,eine praktikung gemacht als betriebselektriker.Den haba ich in Thessaloniki die Staatlice Ingenieur Schule als batriebs elektiker gemacht.Ich habe fast die Deutsche sprache vergest,und ist mir leicter sp,rechen.Das wegen ,wenn Ihnen nicht aus macht ,ici habe eine Biete an Sie ,das Ihre telephon numer mich senden,um viel besser kan ich underhalten mit Ihnen .Fur Ihre information ,ich werdr Ihnen bezalen mit honig wen Sie nach Griechenland komen in sommer in Halkidiki.

    // Edit: removed telephone number

    Reply
    1. mschoeffler Post author

      Hallo Herr Lukmas,… das ehemalige Bauknecht-Gelände ist bei mir um die Ecke (10min mit dem Auto). Auch wenn ich unheimlich gerne ihren Honig mag, muss ich leider zugeben, dass mit die Zeit für eine genaue Hilfestellung zu einer Bienenwaage fehlt :( Trotzdem beste Grüße nach Griechenland!

      Reply
    1. mschoeffler Post author

      There might be a problem with the LiquidCrystal_I2C library. Either it’s the wrong one or the library has not been installed correctly.

      Reply
  18. KimJuYeon

    Thank you for your favor sir, I am Korean engineering student. This is very big help for me to make a code.

    Reply
  19. Maximilian de Rozieres

    Hello,

    I am trying to make the same exact setup as you have here. However, when inputting the code, I receive an error saying “POSITIVE was not declared in this scope”

    Do you have any idea where this would stem from

    I’ve checked already a lot on the internet

    _Max

    Reply
    1. mschoeffler Post author

      I can’t solve your issue, however, I might be able to point you into the right direction: I already got some messages/emails describing the same problem. In most cases a wrong LiquidCrystal_I2C library was used or the library was wrongly installed.

      Reply
  20. dinçer

    Hello … Is it possible to apply the same calibration method with 200 kg loadcell with 1 kg sample weight? Your work is excellent. Congratulations.

    Reply
  21. z.k.hart

    Hello and thank you for uploading this project. I have tried to recreate this project and whenever I power on the Arduino the number on the LCD is never stabilize and this behavior continues even when adding a load to the load cell. have you experienced a similar issue or know of a way to solve it?

    Reply
  22. Marcus

    Hallo Michael, vielen Dank für Dein schönes und hilfreiches Tutorial! Hat sofort funktioniert (den LCD-Kram habe ich durch Ausgaben auf die serielle Schnittstelle ersetzt). Der mechanische Aufbau zur Messung wird das eigentliche Problem werden (für mich). Ich möchte einen Behälter wiegen, in welchem sich Filament für den 3D-Druck befindet. Durch die Messung (bzw. Differenzbildung) wird dann klar, wieviel g Filament auf der Rolle verblieben sind.
    Ich denke mit ein paar Aluprofilen kann ich einen entsprechenden Rahmen zimmern, bei entsprechendem Gewicht auf der Zelle muss es ja stabil sein und darf nicht kippen (meine Wägezelle funktioniert bis 5kg).
    Grüße
    Marcus

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.