ESP32 Wi-Fi Weight Sensor
with HX711 Interface
Build a real-time IoT weighing system that measures, processes, and wirelessly transmits weight data using ESP32 and the HX711 24-bit load cell amplifier.
The ESP32 Wi-Fi Weight Measurement System is an advanced IoT-based smart weighing solution designed for real-time remote monitoring and industrial automation. Powered by the high-performance ESP32 and the precision HX711 amplifier, this system delivers accurate 24-bit weight readings and transmits data wirelessly over Wi-Fi.
This project is perfect for smart inventory systems, industrial automation, agriculture monitoring, and IoT research.
🧩 Components Required
⚡ How the System Works
Load Cell Senses Weight
Applied weight causes mechanical strain → generates tiny millivolt analog signal via strain gauge
HX711 Amplifies & Digitizes
Amplifies the weak signal and converts it to 24-bit digital data via SPI-like protocol
ESP32 Processes Data
Applies calibration factor, averages 10 samples, converts raw counts into kg/grams
Wi-Fi Transmission
Sends data to cloud, IoT dashboard (ThingSpeak/Blynk), or hosts a local web server
🔌 Circuit Diagram
📋 Pin Connection Table
| HX711 Pin | ESP32 Pin | Wire Colour | Description |
|---|---|---|---|
| DOUT | GPIO12 | Blue | Serial data output from HX711 |
| SCK | GPIO14 | Yellow | Clock signal from ESP32 |
| VCC | 3.3V | Red | Power supply (3.3V from ESP32) |
| GND | GND | Black | Common ground |
| E+ (Load Cell) | HX711 E+ | Red wire (LC) | Excitation positive to load cell |
| E- (Load Cell) | HX711 E- | Black wire (LC) | Excitation negative to load cell |
| A+ (Load Cell) | HX711 A+ | Green wire (LC) | Signal positive from load cell |
| A- (Load Cell) | HX711 A- | White/Orange wire (LC) | Signal negative from load cell |
📝 Step-by-Step Instructions
Install Arduino IDE & ESP32 Board Package
Open Arduino IDE → File → Preferences. In "Additional Board Manager URLs" paste:
https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json
Then go to Tools → Board → Board Manager, search for esp32 and install the Espressif package.
Install HX711 Library
Go to Sketch → Include Library → Manage Libraries. Search for HX711 and install the library by Bogdan Necula or Rob Tillaart.
- Library: HX711 by Bogdan Necula
- Version: Latest stable
- Include:
#include "HX711.h"in your sketch
Wire the Hardware
Follow the pin connection table above carefully:
- Connect HX711 DOUT → ESP32 GPIO12
- Connect HX711 SCK → ESP32 GPIO14
- Connect HX711 VCC → ESP32 3.3V (do NOT use 5V)
- Connect HX711 GND → ESP32 GND
- Wire your load cell's 4 wires to the HX711 E+, E-, A+, A- terminals
Upload the Base Code
Copy the code from the section below into a new Arduino sketch. In Tools → Board, select your ESP32 model (e.g., "ESP32 Dev Module"). Select the correct COM port. Click Upload.
Calibrate the Scale
Place a known weight (e.g., 100g or 1kg) on the load cell. Open Serial Monitor at 115200 baud. Adjust the calibration factor scale.set_scale(2280.f) until the reading matches your known weight.
- If reading is too high, increase the calibration number
- If reading is too low, decrease the calibration number
- Start fresh with
scale.tare()to zero the scale
Verify Output in Serial Monitor
Open Tools → Serial Monitor at 115200 baud. You should see output like:
Weight: 0 kg
Weight: 1 kg
Weight: 1 kg
Add Wi-Fi (Optional Extension)
To enable full Wi-Fi functionality, extend the code to:
- Add your Wi-Fi SSID and password credentials
- Create a simple WebServer on port 80 to display weight
- Or use HTTPClient to POST data to ThingSpeak/Blynk
- Or use the MQTT PubSubClient library for broker integration
Calibration is Critical!
The default calibration factor 2280.f is a starting point only. Every load cell is different — always calibrate with a known reference weight before trusting readings. The calibration value is typically between 1000 and 5000.
Pro Tip: Averaging for Stability
The code uses scale.get_units(10) which averages 10 readings. Increase this number (e.g. 20) for more stable readings in vibration-prone environments, at the cost of slightly slower update rate.
💻 Arduino Code
/* * ESP32-Powered Wi-Fi Weight Sensor with HX711 Interface * * Connections: * - HX711 DATA pin → ESP32 GPIO12 * - HX711 SCK pin → ESP32 GPIO14 * - HX711 VCC → ESP32 3.3V * - HX711 GND → ESP32 GND * * Tutorial: https://www.makemindz.com */ #include "HX711.h" // Pin definitions const int LOADCELL_DOUT_PIN = 12; // GPIO12 const int LOADCELL_SCK_PIN = 14; // GPIO14 // HX711 instance HX711 scale; void setup() { Serial.begin(115200); scale.begin(LOADCELL_DOUT_PIN, LOADCELL_SCK_PIN); // Wait for the HX711 to stabilize Serial.println("Initializing the scale..."); delay(1000); if (scale.is_ready()) { Serial.println("HX711 is ready."); } else { Serial.println("HX711 not found. Check wiring!"); while (1); // Halt if not found } // Set calibration factor — adjust this for your load cell scale.set_scale(2280.f); scale.tare(); // Reset scale to 0 Serial.println("Scale tared. Ready to weigh!"); } void loop() { if (scale.is_ready()) { long reading = scale.get_units(10); // Average of 10 samples Serial.print("Weight: "); Serial.print(reading); Serial.println(" kg"); } else { Serial.println("HX711 not ready."); } delay(1000); // Read every second }
🚀 Try the Live Simulation
Simulate this entire circuit in your browser using Wokwi or Cirkit Designer — no hardware or installation required!
✨ Key Features
24-bit Precision ADC
HX711 provides industrial-grade 24-bit resolution for highly accurate weight readings
Wi-Fi Ready
Built-in ESP32 Wi-Fi eliminates the need for any external communication module
Real-Time Monitoring
1-second update cycle with averaged readings for stable, noise-free output
Low Power Consumption
ESP32 deep sleep modes available for battery-powered deployments
Calibration Control
Simple single-variable calibration factor makes tuning straightforward
Compact & Scalable
Minimal hardware footprint, easily expandable to LCD, MQTT, or cloud dashboards
Comments
Post a Comment