19.01.2026

HX711 Load Cell - MIDI Controller

Arduino
HX711 Load Cell - MIDI Controller

Table of contents

Introduction What is a Load Cell? When would you use a load cell? HX711 Load Cell Amplifier Simple reading example HX711 Midi Controller Project
Table of contents
Introduction What is a Load Cell? When would you use a load cell? HX711 Load Cell Amplifier Simple reading example HX711 Midi Controller Project

Introduction

We’ve all stepped on a scale at some point in our lives, taking a quick peek at our own weight. Or, before a flight, your luggage was weighed in at some point. Sometimes in your kitchen, portioning the ingredients. With so many modern scales being digital, most of them have one key element in common: load cells.

As microcontrollers get more powerful and affordable, and as sensor modules become easier to integrate, technologies which were once reserved for commercial and industrial weighing systems are now available on a simple breakout board sitting on your desk. That means you can implement accurate, real-world weight measurements into your own DIY projects.

In this article you will learn about how load cells work. How to use HX711 Load Cell Amplifier and connect it with a load cell to get basic weight readings. In the end, we’ll show you a fun little project where you can apply sound filters to a tone based on the weight input from the load cell.

What is a Load Cell?

A load cell is a type of transducer that converts a force (compression, tension or torque) into a measurable electrical signal. The magnitude of this signal is directly proportional to the applied force which is then converted into a readable output like a weight on a scale.

A typical load cell consists of two parts: the main body and an attached electrical circuit. The main body is what bears the weight or force and accounts for most of the load cell’s size. To ensure reliability and predictable strain distribution, it is usually made from high-grade steel or aluminium. 

The electrical circuit is housed within the load cell, tightly bonding to the main body. The circuit includes strain-gauges which are specialised parts of the circuit designed to sense the deformations of the main body (when force is applied).

Strain gauges consist of thin, conductive wire or foil. When stretched or compressed along their length, their electrical resistance changes slightly, allowing us to detect tiny deformations - and ultimately converting physical force into electrical signals.


When would you use a load cell?

A load cell measures mechanical force, primarily the weight of objects. Today, almost all digital weighing scales use load cells because of the accuracy with which they can measure weight. They are used in a variety of fields that demand accuracy and precision. There are different classes to load cells, and each class is different in terms of accuracy and capacity.

HX711 Load Cell Amplifier

The HX711 load cell amplifier is designed to take a weaker electrical signal from a load cell and amplify it so that the digital signal can then be processed by a microcontroller. The HX711 amplifier operates with high resolution and low power consumption, making it ideal for applications like weighing scales and force measurement systems.


The HX711 has two differential input channels that can interface directly with a load cell. It measures the small voltage changes produced by the load cell under pressure. It uses  24-bit A/D conversion to convert the amplified analog signal into a high resolution digital signal. This provides accurate measurements with minimal noise interference. Once the signal is converted, it transmits the digital data via serial interface.

Simple reading example

Now we’ll walk through how to use the load cell and the amplifier to get simple weight readings. Our HX711 amplifier board comes in two versions:

  • Standard version - uses serial interface for communication, the two primary pins are Data (DOUT) and Clock (PD_SCK)
  • I2C version - uses Qwiic/easyC cable for communication (default address 0x30)

Connecting the Load cell with the HX711:

Load cell wires

HX711 breakout board

Red

E+

Black

E-

Green

A-

White

A+

After you’ve connected the load cell with the amplifier board, now we can dive into the code example. In these examples we will be using HX711 Arduino library.

Code example:

Below is the code for reading weight in a set unit. But, before reading values from the laid cell in units, we need to do one test measurement to calibrate the scale:

  1. Get an object which you know the weight of (for example, a 0.5kg weight)
  2. Run this sketch, don't change the SCALE_UNITS value for now
  3. After running the sketch, place the known weight on the load cell
  4. Note the displayed value, let's call it X
  5. Your SCALE_UNITS is X / known weight, set it to that
  // Include the library

#include "HX711-SOLDERED.h"
// Define pins used for DAT and SCK here
#define PIN_DAT 4
#define PIN_SCK 3
// Scale units
#define SCALE_UNITS 1.0
// Create the HX711 object on the right pins
HX711 hx711(PIN_DAT, PIN_SCK);
void setup()
{
Serial.begin(115200); // For debugging
// Init HX711
hx711.begin();
// Wait a bit until it initializes fully delay(200);
// While calibrating - don't put any load on the load cell! hx711.setZero();
// Set calculated scale units hx711.setScale(SCALE_UNITS); }
void loop() { // Make reading in units double readingInUnits = hx711.getReadingInUnits(); // You may also call getReadingInUnits(n) for the result to be an average of n readings // Print the reading // Try reading this over the serial plotter! Serial.print("HX711 Reading: "); Serial.println(readingInUnits); // Wait a short while until the next reading // This serial print is quite fast because it looks better on the serial plotter delay(200); }

 

HX711 Midi Controller Project

Now let’s have some fun with the load cell! In this project, we use an ESP32-S3 as a Midi controller. The device acts as a musical instrument interface, sending real-time data from a load cell over USB to your computer. Since the ESP32-S3 can transmit MIDI CC (Control Change) messages or other MIDI events over USB, using Surge XT (a free open-source virtual synthesizer) we can then map MIDI CC messages to parameters such as filter cutoff, resonance, envelopes, etc.

Full code example:


#include "usb.h"
#include "usbmidi.h"
#include "HX711-SOLDERED.h"
// Define Load cell pins
#define PIN_DAT 4
#define PIN_SCK 3
// Approximate MIN / MAX load values
#define RAW_MIN  390000L
#define RAW_MAX -1100000L
// MIDI config
#define MIDI_CHANNEL 1
#define CC_NUMBER 1
#define SEND_RATE_MS 10 // CC update rate
// Note playback
#define HOLD_NOTE    1
#define NOTE_NUMBER   60 // C4 note
#define NOTE_VELOCITY  100
// Interrupt button
struct Button
{
 const uint8_t PIN;
 bool pressed;
};
// Create MIDI/HX711/PUSHBUTTON objects
USBMIDI MIDI;
HX711 hx711(PIN_DAT, PIN_SCK);
Button btn = {5, false};
static uint32_t lastSendMs = 0; // CC
static int lastCC = -1; // 0 ... 127
// Pushbutton time / state config
unsigned long button_time = 0;
unsigned long last_button_time = 0;
bool playNote = false;
// Pushbutton ISR
void IRAM_ATTR isr()
{
 button_time = millis();
 if (button_time - last_button_time > 250)
 {
  btn.pressed = true;
  last_button_time = button_time;
 }
}
void setup()
{
 USB.begin();
 MIDI.begin();
 hx711.begin();
 // Initialize button with interrupt
 pinMode(btn.PIN, INPUT_PULLUP);
 attachInterrupt(btn.PIN, isr, FALLING);
}
void loop()
{
 uint32_t now = millis();
 // Send interval
 if (now - lastSendMs < SEND_RATE_MS) return;
 lastSendMs = now;
 // Play/Pause
 if (btn.pressed)
 {
  playNote = !playNote;
  btn.pressed = false;
 }
 // Play/Pause C4 note
 if (playNote) { MIDI.noteOn(NOTE_NUMBER, NOTE_VELOCITY, MIDI_CHANNEL); }
 else { MIDI.noteOff(NOTE_NUMBER); }
 // Get raw reading from load sensor
 long raw = hx711.getRawReading();
 // Constrain the value in range (RAW_MAX first because readings are inverted)
 long r = constrain(raw, RAW_MAX, RAW_MIN);
 // Map 0 ... 127 and constrain with slight offset
 int ccVal = map(r, RAW_MIN, RAW_MAX, 0, 127);
 ccVal = constrain(ccVal + 8, 0, 127);
 // Send only when value changes
 if (ccVal != lastCC)
 {
  MIDI.controlChange(CC_NUMBER, (uint8_t)ccVal, MIDI_CHANNEL);
  lastCC = ccVal;
 }
}

 

Full code available on GitHub.

Products mentioned in this article

Related Articles