Header Ads Widget

Responsive Advertisement

Digital-Weighing-Scale-using-HX711-and-Load-Cell-main

 


Digital Weighing Scale

ESP32, HX711 Load Cell & OLED Interface

👁️ Operational Overview System Logic

This system utilizes an ESP32 processing core combined with an HX711 high-precision analog-to-digital converter matrix to interface with a strain-gauge Load Cell sensor hardware block. Mass measurements are accurately captured, computed into stable real-time data using multi-sample smoothing filters, and routed to an ergonomic 0.96-inch SSD1306 OLED graphical interface panel display.

Measurement Precision Filtering
⚖️ Micro-fluctuations below 0.005 kg zeroed
HCI Interface Mode
📟 High-Contrast 128x64 Pixels Display
📺 Project Demonstration & Guide Video Hub

Watch the full demonstration, calibration configuration walkthrough, and test setup executing live below:

🛠️ Structural BOM Requirements Hardware List

Procure the following structural components to initialize development configurations:

Target Component Label Structural Allocation Quantity Functional Deployment Purpose
ESP32 Development Board1 UnitCentral execution platform and processing array.
HX711 Load Cell Amplifier1 UnitAmplifies tiny analog structural strain data signals.
Load Cell Transducer (1kg/5kg/10kg)1 UnitPhysical sensor element to register external load mass.
0.96" SSD1306 OLED Display (I2C)1 UnitReal-time visual telemetry status tracking terminal.
Solderless Prototyping Board & Wires1 BoxSubsystem routing connection architecture.
🔌 Device Interface Pin Maps I/O Infrastructure

Wire the system communication buses according to these optimized node mapping tables:

HX711 Amplifier Module to ESP32:
HX711 Subsystem Node PinESP32 Host Destination Pin Node
VCC3V3 Power Output Rail
GNDGND Common Reference Ground
DT (Data Line Out)GPIO 12 Intercept Node
SCK (Serial Clock In)GPIO 13 Intercept Node
0.96" SSD1306 OLED Display to ESP32:
OLED Display Module Node PinESP32 Host Destination Pin Node
VCC3V3 Shared Positive Power Bus
GNDGND Shared Common Reference Ground
SDA (Serial Data Line)GPIO 20 Custom Hardware Interface
SCL (Serial Clock Line)GPIO 21 Custom Hardware Interface
💻 Optimized Production Code Engine Firmware Source

Copy and deploy this production script directly inside your Arduino IDE workspace environment:

#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include "HX711.h"

// Screen configuration
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
#define OLED_RESET    -1
#define SCREEN_ADDRESS 0x3C // Common I2C address for SSD1306

// Define custom I2C pins for OLED
const int I2C_SDA_PIN = 20;
const int I2C_SCL_PIN = 21;

// Define custom pins for HX711 (Remapped DT to pin 12)
const int LOADCELL_DOUT_PIN = 12;
const int LOADCELL_SCK_PIN = 13;

// Calibration Factor definition block to maintain precision
const float CALIBRATION_FACTOR = 420.0; 

// Initialize hardware objects
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
HX711 scale;

void setup() {
  Serial.begin(115200);
  delay(1000);
  
  // Initialize custom I2C bus for the OLED
  Wire.begin(I2C_SDA_PIN, I2C_SCL_PIN);
  
  // Initialize OLED Display
  if(!display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS)) {
    Serial.println(F("SSD1306 allocation failed"));
    for(;;);
  }
  
  display.clearDisplay();
  display.setTextColor(SSD1306_WHITE);
  
  // Initialize scale parameter configuration array
  scale.begin(LOADCELL_DOUT_PIN, LOADCELL_SCK_PIN);
  scale.set_scale(CALIBRATION_FACTOR);
  scale.tare(); // Auto-zero calibration routine trigger on power up
  
  display.clearDisplay();
  display.setCursor(10, 20);
  display.println("Scale Ready!");
  display.display();
  delay(1000);
}

void loop() {
  display.clearDisplay();
  
  if (scale.is_ready()) {
    float weight_grams = scale.get_units(5); // Average 5 readings for stability
    
    // Convert grams to kilograms
    float weight_kg = weight_grams / 1000.0;
    
    // Absolute function logic to force positive scaling metrics values
    weight_kg = abs(weight_kg);
    
    // Filter micro fluctuations close to zero
    if(weight_kg < 0.005) weight_kg = 0.000; 
    
    // Draw layout headers
    display.setTextSize(1);
    display.setCursor(0, 0);
    display.println("DIGITAL SCALE");
    display.drawLine(0, 12, 128, 12, SSD1306_WHITE);
    
    // Print mass value on screen (using 3 decimal places for precision)
    display.setTextSize(2);
    display.setCursor(10, 25);
    display.print(weight_kg, 3); 
    display.print(" kg");
    
    // Debug output to Serial Monitor
    Serial.print("Weight: ");
    Serial.print(weight_kg, 3);
    Serial.println(" kg");
  } else {
    display.setTextSize(1);
    display.setCursor(10, 25);
    display.println("HX711 Not Found");
  }
  
  display.display();
  delay(500);
}
HCI Calibration Tip: If the scale outputs incorrect values, increase the CALIBRATION_FACTOR factor setting if output values track low, or decrease it if measurements track higher than the real mass payload.

Post a Comment

0 Comments