Can i speed up the execution of a code?

hello … i used a library for a weight sensor with the Hx711 module that shows the result on an LCD … the code works perfectly but it is really slow, and it’s not because of delays or such things because i tried it with and without delays and the results were the same. What happens is that the weight sensor takes up to 2 to 3 seconds to read the weight and do it in like two steps, for instant if I’m measuring a 100g it would read 30g first and then 100g. Im wondering if there is a way to make it read the weight instantly?

the code is below:

// Hx711.DOUT - pin #A1
// Hx711.SCK - pin #A0

// LCD.RS - pin 12
// LCD.En - pin 11
// LCD.D4 - pin 5
// LCD.D5 - pin 4
// LCD.D6 - pin 9
// LCD.D7 - pin 8

#include <LiquidCrystal.h>
#include <hx711.h>

LiquidCrystal lcd(12, 11, 5, 4, 9, 8 );
Hx711 scale(A1, A0);

void setup() {

lcd.begin(16, 2);

void loop() {

lcd.setCursor(0, 0);
lcd.print(scale.getGram(), 1);
lcd.print(" g");
lcd.print(" ");


Any scale takes time to settle. Physically, it's a spring-and-damper situation. If you are reading large numbers of things, it may come down to how you are putting the objects on the scale. If you can rig up your assembly line so that objects are placed on the scale instead of being dropped on it from a height, it may settle quicker.

Read the datasheet:

The chip has two update rates: 10 Hz and 80 Hz. At low speed the 'settling time' is typically 400 milliseconds (0.4 seconds). Sounds like you need to switch it to 80 Hz speed.

@johnwasser hello sir .. do you by any chance know how to switch that :) ?

Alqudimi: how to switch that :) ?

The datasheet that John linked shows that pin 15 RATE on the chip needs to be taken high for the higher speed.

But whether or not that pin is accessible to you in your scale, only you can tell. It may even be at the faster speed already.

I'd say you'll need to check the specs of the scale (as opposed to the specs of its chip).