Customize Your Own Digital Scale

Published Aug 24, 2025
 3 hours to build
 Intermediate

A precise electronic scale can be obtained with simple materials and simple debugging

display image

Components Used

HX711 24-bit ADC for Weigh Scales
HX711 is a 24-bit ADC for weighing scales.
1
128x64 (0.96") OLED Display
Adafruit Accessories Monochrome 0.96" OLED Graphic Display
1
Arduino Uno board
Arduino Uno is a microcontroller board based on the ATmega328P (datasheet). It has 14 digital input/output pins (of which 6 can be used as PWM outputs), 6 analog inputs, a 16 MHz ceramic resonator (CSTCE16M0V53-R0), a USB connection, a power jack, an ICSP header and a reset button.
1
Description

Firstly, we need to understand the HX711 module, which is a 24 bit ADC amplifier with built-in amplifier. Its communication method is similar to IIC, but it only sends data to MCU

Next, let's learn about his wiring method. GND is connected to the GND of Arduino, VCC is connected to 5V, DT and SCK installation codes are connected to the corresponding pins (here PIN 2 and PIN 3 are connected respectively), E+is connected to the positive pole of the sensor, E - is connected to the negative pole of the sensor, and the data line of the sensor is connected to A+and A-

CODE:

#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>//OLED library
#define ADSK 3
#define ADDO 2
 
Adafruit_SSD1306 display(128,64, &Wire, -1);
//Set the screen size of OLED
long NormalValue;
long measuer(void);
long Weight;
int AveNub;
char i;
void setup() {
 //Serial.begin(9600);//Serial port initialization
 AveNub=5;//The larger the number of reads, the more stable it is, but also slower
 pinMode(ADSK,OUTPUT);
 pinMode(ADDO,INPUT);
 digitalWrite(ADSK,0);
 display.begin(SSD1306_SWITCHCAPVCC, 0x3C);//Initialize OLED and set IIC communication address
 NormalValue=measuer();//Store initial error value
}
void loop() {
 for(i=1;i<AveNub;i++)
 {
   Weight+=(measuer()-NormalValue);
   }
 Weight/=AveNub;
 //Serial.println(Weight/210);
 //Sent to the serial port,/400 is a parameter that converts pressure into weight and needs to be adjusted slowly
 display.clearDisplay();//Clear screen
 display.setTextColor(WHITE);//Setting text color, monochrome OLED is invalid, but must have
 display.setTextSize(2);//Set text size
 display.setCursor(0, 0);//Set the starting X and Y axes of the text
 display.print("Weith:");
 display.setCursor(0, 20);
 if(Weight<0)//If the weight is less than 0, there may be bugs when using OLED display directly
 {
   display.print("-");
   display.print((Weight/(-210000))%10);
   display.print((Weight/(-21000))%10);
   display.print((Weight/(-2100))%10);
   display.print((Weight/(-210))%10);
   display.print(".");
   display.print((Weight/(-21))%10);
 }
 else//重量大于0
 {
   display.print((Weight/210000)%10);
   display.print((Weight/21000)%10);
   display.print((Weight/2100)%10);
   display.print((Weight/210)%10);
   display.print(".");
   display.print((Weight/21)%10);
 }
 display.print("g");
 display.display();//Execute Display
}
long measuer()//Read function, channel A, gain 64
{
   long Count; 
   char i; 
   digitalWrite(ADSK,0);
   Count=0; 
   while(digitalRead(ADDO)); 
   for (i=0;i<24;i++)
   { 
   digitalWrite(ADSK,1);
   delayMicroseconds(1);
   Count=Count<<1; 
   digitalWrite(ADSK,0);
   delayMicroseconds(1);
   if(digitalRead(ADDO)) 
     Count++; 
   } 
   digitalWrite(ADSK,1);
   Count=Count^0x800000;  
   digitalWrite(ADSK,0);
   digitalWrite(ADSK,1);
   digitalWrite(ADSK,0);
   digitalWrite(ADSK,1);
   digitalWrite(ADSK,0);
   return Count; 
 }

Once the parameters are debugged, an accurate electronic scale can be obtained

 

 

Comments
Ad