Load Cell Calibration & Sensitivity การสอบเทียบโหลดเซลล์และ Sensitivity (Calibration & Sensitivity)

Read a load cell through an HX711 and Arduino over Web Serial, fit the transfer function, and turn ADC levels into grams.

อ่านค่าโหลดเซลล์ผ่าน HX711 และ Arduino ด้วย Web Serial หาสมการ transfer function แล้วแปลงค่า ADC level เป็นกรัม

A load cell is a device that converts an applied force into an electrical signal that can be measured. It works on the principle that when a material is loaded, a Wheatstone bridge circuit is used to detect the resulting change in an electrical value. However, the electrical value from this circuit is in the millivolt range, which a typical microcontroller cannot detect and distinguish accurately. For example, an Arduino board can measure a voltage up to 5 V with a resolution of 210 (1024 levels), so it can distinguish signals only down to 4.88 mV. When a load cell carries a weight of 50 g, the voltage changes by 4.9 mV, which is very close to the minimum resolution of the Arduino board. As a result, a weight change smaller than 50 g cannot be measured. A load cell therefore needs a signal amplifier circuit to increase the resolution of the measurement.

Load Cell คืออุปกรณ์ที่ทำหน้าที่แปลงแรงกระทำ (Force) ให้เป็นสัญญาณทางไฟฟ้าที่สามารถวัดค่าได้ โดยอาศัยหลักการที่ว่าเมื่อวัสดุได้รับแรง โดยใช้วงจร Wheatstone Bridge ช่วยตรวจจับการเปลี่ยนแปลงค่าทางไฟฟ้า อย่างไรก็ตามค่าทางไฟฟ้าที่ได้จากวงจรดังกล่าวมีค่าอยู่ในระดับ mV ซึ่งไมโครคอนโทรลเลอร์ทั่วไปไม่สามารถตรวจจับและแยกแยะได้อย่างแม่นยำ เช่น Arduino board สามารถวัดแรงดันไฟฟ้าได้สูงสุด 5 V โดยมีความละเอียด 210 (1024 level) ทำให้แยกแยะสัญญาณได้ละเอียดที่สุดเพียง 4.88 mV ในกรณีที่ Load Cell รับน้ำหนัก 50 กรัม แรงดันไฟฟ้าเปลี่ยนไป 4.9 mV ซึ่งใกล้เคียงกับความละเอียดขั้นต่ำของ Arduino board มาก ส่งผลให้ไม่สามารถวัดน้ำหนักที่เปลี่ยนแปลงน้อยกว่า 50 กรัมได้ ดังนั้นการใช้งาน Load Cell จึงจำเป็นต้องมีวงจรขยายสัญญาณ เพื่อเพิ่ม Resolution ในการวัด

In this practice a load cell is used together with an HX711 ADC module, which amplifies the signal Vo and converts it into a digital signal of 224 (16,777,216 levels) before sending it to the Arduino. The relationship between the weight (W) and the value read from the sensor (L) is linear, because the relationship between the change in resistance and the applied force is linear and the structure is in the elastic state, as described in the earlier topics. This relationship is called the transfer function, and it is written as follows.

ในปฏิบัตินี้เลือกใช้ Load Cell ร่วมกับโมดูล ADC รุ่น HX711 ซึ่งทำหน้าที่ขยายสัญญาณ Vo และแปลงเป็นสัญญาณดิจิตอลขนาด 224 (16,777,216 level) ก่อนส่งไปยัง Arduino ความสัมพันธ์ระหว่างน้ำหนัก (W) กับค่าที่อ่านได้จากเซนเซอร์ (L) เป็นแบบเชิงเส้น เนื่องจากความสัมพันธ์ระหว่างการเปลี่ยนแปลงค่าความต้านทานกับแรงที่กระทำเป็นแบบเชิงเส้น และโครงสร้างอยู่ในสภาวะ Elastic ตามที่กล่าวไว้ในหัวข้อก่อนหน้า ความสัมพันธ์นี้เรียกว่า Transfer Function เขียนสมการได้ดังนี้

\[ L = mW + c \]

Here m is the slope, which indicates the sensitivity of the measurement system. Sensitivity is the rate of change of the ADC value per unit of weight. The higher the sensitivity, the better the sensor can distinguish weights that differ only slightly. c is a constant obtained from linear fitting.

โดยที่ m คือความชัน ใช้บอก Sensitivity ของระบบวัด โดย Sensitivity หมายถึงอัตราการเปลี่ยนแปลงของค่า ADC ต่อหนึ่งหน่วยน้ำหนัก ยิ่ง Sensitivity สูง แสดงว่าเซนเซอร์สามารถแยกแยะน้ำหนักที่แตกต่างกันเพียงเล็กน้อยได้ดียิ่งขึ้น และ c คือค่าคงที่ค่าหนึ่ง ที่ได้จากการทำ Linear fitting

Once the transfer function is known, the equation can be rearranged to convert a measured ADC value back into a weight. This equation is called the inverse transfer function.

เมื่อได้สมการ Transfer Function แล้ว สามารถจัดรูปสมการใหม่เพื่อแปลงค่า ADC ที่วัดได้กลับเป็นค่าน้ำหนัก เรียกสมการนี้ว่า Inverse Transfer Function ดังนี้

\[ W = \frac{1}{m}\,L - \frac{c}{m} \]

Equipment อุปกรณ์ที่ต้องใช้

  • Load cell with four wires (red, black, green, white)
  • HX711 module
  • Arduino Uno board and a USB cable
  • Jumper wires
  • Known weights
  • A computer with Arduino IDE (with the HX711 library [1]) and the Chrome or Edge browser
  • Load Cell ที่มีสายสี่เส้น (แดง ดำ เขียว ขาว)
  • โมดูล HX711
  • บอร์ด Arduino Uno และสาย USB
  • สายจัมเปอร์
  • ตุ้มน้ำหนักที่ทราบค่า
  • คอมพิวเตอร์ที่ติดตั้ง Arduino IDE (พร้อมไลบรารี HX711 [1]) และเบราว์เซอร์ Chrome หรือ Edge

Wiring การต่อสาย

Connect the four load-cell wires to the E+, E−, A− and A+ terminals of the HX711, then the HX711's VCC, GND, DT and SCK to the Arduino's 5V, GND, D3 and D2 respectively. The sketch below uses the data pins dataPin = 3, clockPin = 2

ต่อสายโหลดเซลล์ทั้งสี่เส้นเข้ากับขั้ว E+, E−, A− และ A+ ของ HX711 จากนั้นต่อ VCC, GND, DT และ SCK ของ HX711 เข้ากับ 5V, GND, D3 และ D2 ของ Arduino ตามลำดับ สเก็ตช์ด้านล่างใช้ขาข้อมูล dataPin = 3, clockPin = 2

Load cell HX711 Arduino Uno E+ E− A− A+ GND DT SCK VCC GND D3 D2 5V B−, B+ : not used
Wiring of the load cell: red E+, black E−, green A−, white A+ to the HX711, and the HX711 to the Arduino board
การต่อสายโหลดเซลล์: แดง E+, ดำ E−, เขียว A−, ขาว A+ กับ HX711 เข้ากับ Arduino board

Arduino code Arduino code

The sketch uses the HX711 library [1]. In setup() the serial port is used at 9600 baud and the HX711 is connected through pin D3 (data) and pin D2 (clock). In loop() the 24-bit sensor value is read with scale.read(), one value per line is printed to the serial port, and then it waits 100 ms before the next reading. Serial.begin(9600) must match the board rate in this page below.

สเก็ตช์นี้ใช้ไลบรารี HX711 [1] ในฟังก์ชัน setup() ใช้พอร์ตอนุกรมที่ 9600 baud และเชื่อมต่อ HX711 ผ่านขา D3 (ข้อมูล) และขา D2 (สัญญาณนาฬิกา) ในฟังก์ชัน loop() อ่านค่าเซนเซอร์ 24 บิตด้วย scale.read() พิมพ์ค่าหนึ่งค่าต่อหนึ่งบรรทัดทางพอร์ตอนุกรม แล้วหน่วงเวลา 100 ms ก่อนอ่านค่าครั้งถัดไป ค่า Serial.begin(9600) ต้องตรงกับ board rate ในหน้านี้ด้านล่าง

#include <HX711.h>
const int dataPin=3;
const int clockPin=2;
long value=0;
HX711 scale;
void setup() {
  Serial.begin(9600);
  scale.begin(dataPin, clockPin);
}
void loop() {
  value=scale.read();
  Serial.println(value);
  delay(100);
}

How to use this lab วิธีใช้เครื่องมือ

  1. Close the Arduino IDE's Serial Monitor (only one program can use the port), then use Chrome or Edge on this page.
  2. Set the Setting board rate to 9600, press Connect, and choose the Arduino port in the browser's dialog. The Serial read box shows the last line received (string) and its numeric value (number).
  3. The Sensor value with moving average is the mean of the latest samples, according to Number of average. After Connect or Play, this box shows 0 until that many samples have arrived, so wait for a real value.
  4. When the weight is steady, press Pause to freeze the displayed value and record it in the results table. Pressing Play resumes receiving values, but it starts a new capture.
  5. Enter the true weight (W, g) and the recorded sensor value (L, ADC level) into the Calibration table (at least two rows; an empty row is skipped), then press Update calibration data.
  6. Read the Transfer function (equation) and Invers transfer function. The Calibration graph shows the data points you entered and the Linear fit line, and the Weight (g) value is shown in real time.
  7. You can press Export calibration to save the table and settings as a JSON file. Import calibration loads the data and settings back, so the table does not need to be filled in again.
  8. Check the result with weights that were not used for calibration.
  1. ปิด Serial Monitor ของ Arduino IDE (พอร์ตใช้ได้ทีละโปรแกรม) แล้วใช้ Chrome หรือ Edge เปิดหน้านี้
  2. ตั้ง Setting board rate เป็น 9600 กด Connect แล้วเลือกพอร์ตของ Arduino ในกล่องโต้ตอบของเบราว์เซอร์ ช่อง Serial read จะแสดงบรรทัดล่าสุดที่รับ (string) และค่าตัวเลข (number)
  3. ตัวเลข Sensor value with moving average คือค่าเฉลี่ยของตัวอย่างล่าสุดตามจำนวน Number of average หลัง Connect หรือ Play ช่องนี้จะแสดง 0 จนกว่าจะมีตัวอย่างครบตามจำนวน จึงต้องรอให้ได้ค่าจริง
  4. เมื่อน้ำหนักนิ่งแล้วกด Pause เพื่อหยุดค่าที่แสดงและจดค่านั้นลงตารางบันทึกผล เมื่อกดปุ่ม Play จะรับค่าต่อ แต่เป็นการเริ่มเก็บใหม่
  5. กรอกน้ำหนักจริง (W, g) และค่าเซนเซอร์ที่บันทึกไว้ (L, ADC level) ลงใน Calibration table (อย่างน้อยสองแถว แถวที่เว้นว่างจะถูกข้าม) แล้วกด Update calibration data
  6. อ่าน Transfer function (equation) และ Invers transfer function ส่วนกราฟ Calibration แสดงจุดข้อมูลที่คุณกรอก และเส้น Linear fit พร้อมแสดงค่า Weight (g) จะแสดงน้ำหนักแบบ real time
  7. คุณสามารถกดปุ่ม Export calibration เพื่อบันทึกตารางและการตั้งค่าเป็น JSON ไฟล์ ส่วน Import calibration คือการโหลดข้อมูลและการตั้งค่ากลับ จึงไม่ต้องกรอกข้อมูลลงตารางใหม่
  8. ตรวจผลด้วยน้ำหนักที่ไม่ได้ใช้สอบเทียบ

Worked example (made-up numbers) ตัวอย่างการตีความผล (ตัวเลขสมมติ)

Suppose the four calibration points are those in Table 2. They are invented for illustration, and were computed with the same least-squares formulas the page uses.

สมมติจุด calibration สี่จุดเป็นไปตามตารางที่ 2 ตัวเลขเหล่านี้แต่งขึ้นเพื่อประกอบคำอธิบาย และคำนวณด้วยสูตร least squares เดียวกับที่หน้านี้ใช้

Table 2. Calibration points used in the worked example (made-up numbers)ตารางที่ 2 จุด calibration ที่ใช้ในตัวอย่าง (ตัวเลขสมมติ)
N True weight (W, g)น้ำหนักจริง (W, g) Sensor value (L, ADC level)ค่าเซนเซอร์ (L, ADC level)
10105000
21001103000
32002097000
45005090000

The fit gives \(m = 9969.29\) ADC level/g and \(c = 104892.86\) ADC level
so \(L = 9969.29\,W + 104892.86\)
and \(W = \dfrac{L}{9969.29} - \dfrac{104892.86}{9969.29}\)
or \(W = 0.0001\,L - 10.5216\).

A reading of \(L = 3\,000\,000\)
converts, with the last equation, to \(W = 0.0001\times 3\,000\,000 - 10.5216 = 289.48\) g.

Now place a 300 g weight that was not used in the table and read \(L = 3\,088\,000\).
The inverse function gives \(W = 0.0001\times 3\,088\,000 - 10.5216 = 298.28\) g,
so the absolute error is \(|298.28 - 300| = 1.72\) g.
The sensitivity, about 9969 ADC levels per gram, tells you that 1.72 g corresponds to roughly 17,100 levels of ADC.

การ fit ให้ \(m = 9969.29\) ADC level/g และ \(c = 104892.86\) ADC level
ดังนั้น \(L = 9969.29\,W + 104892.86\)
และ \(W = \dfrac{L}{9969.29} - \dfrac{104892.86}{9969.29}\)
หรือ \(W = 0.0001\,L - 10.5216\)

ค่าที่อ่านได้ \(L = 3\,000\,000\)
แทนค่าในสมการสุดท้าย ได้ \(W = 0.0001\times 3\,000\,000 - 10.5216 = 289.48\) g

จากนั้นวางน้ำหนัก 300 g ที่ไม่ได้ใช้ในตาราง แล้วอ่านได้ \(L = 3\,088\,000\)
สมการผกผันให้ \(W = 0.0001\times 3\,088\,000 - 10.5216 = 298.28\) g
ดังนั้น absolute error เท่ากับ \(|298.28 - 300| = 1.72\) g
ค่า sensitivity ประมาณ 9969 ADC level ต่อกรัม บอกว่า 1.72 g เทียบเท่าราว 17,100 ADC level

Reading the result: an absolute error of 1.72 g on a 300 g weight (about 0.6 %) is small compared with the weight measured, so the linear model fits well over the calibrated range. Because the four points are almost perfectly on a line here, most of this error comes from rounding the coefficients to 0.0001 and 10.5216. Using the unrounded values, W = (L − 104892.86)/9969.29, the same reading gives W = 299.23 g and an error of only 0.77 g. In a real measurement, reading noise and the instant at which you pressed Pause add to the error.

การตีความ: absolute error 1.72 g ที่น้ำหนัก 300 g (ประมาณ 0.6 %) เล็กเมื่อเทียบกับน้ำหนักที่วัด แสดงว่าโมเดลเชิงเส้นเข้ากับข้อมูลดีในช่วงที่สอบเทียบ ในตัวอย่างนี้จุดทั้งสี่เกือบอยู่บนเส้นตรงพอดี error ส่วนใหญ่จึงมาจากการปัดเศษสัมประสิทธิ์เป็น 0.0001 และ 10.5216 ถ้าใช้ค่าที่ไม่ปัดเศษ W = (L − 104892.86)/9969.29 ค่าที่อ่านเดียวกันจะได้ W = 299.23 g และ error เพียง 0.77 g ในการวัดจริง สัญญาณรบกวนตอนอ่านค่ากับจังหวะที่กด Pause จะทำให้ error เพิ่มขึ้นอีก

Common mistakes & limitations ข้อควรระวังและข้อจำกัด

  • Place each weight at the centre of the platform; an off-centre load changes the reading.
  • Wait until the value is steady before pressing Pause, and do not touch the platform or the table while reading.
  • The zero reading can drift over time [2], and temperature changes it too [2], so re-check the empty platform and calibrate again if the room or the load cell is at a changed temperature.
  • Do not use the load cell beyond its rated capacity. Beyond the elastic limit the structure deforms permanently and the old calibration no longer holds [3].
  • The line is only valid within the calibrated range; do not trust the value of a weight that is heavier or lighter than the weights used for calibration.
  • วางน้ำหนักแต่ละตัวไว้กลางแท่นชั่ง การวางเยื้องศูนย์ทำให้ค่าที่อ่านเปลี่ยน
  • รอให้ค่านิ่งก่อนกด Pause และอย่าแตะแท่นชั่งหรือโต๊ะขณะอ่านค่า
  • ค่าศูนย์อาจเลื่อน (drift) ตามเวลา [2] และอุณหภูมิก็ทำให้ค่าเปลี่ยน [2] จึงควรตรวจแท่นชั่งเปล่าซ้ำ และสอบเทียบใหม่หากห้องหรือโหลดเซลล์อยู่ในอุณหภูมิที่เปลี่ยนไป
  • ห้ามใช้ Load Cell เกินพิกัด เมื่อเกินขีดจำกัดยืดหยุ่น โครงสร้างจะเปลี่ยนรูปถาวรและค่าสอบเทียบเดิมใช้ไม่ได้อีก [3]
  • เส้นตรงใช้ได้เฉพาะในช่วงที่สอบเทียบ อย่าเชื่อค่าของน้ำหนักที่อยู่ไกลหรือเบากว่าค่าน้ำหนักที่ใช้สอบเทียบ

Applications การประยุกต์ใช้งาน

The idea of finding a transfer function can be used not only with a load cell but also with other sensors, to convert an electrical signal into the quantity of interest.

แนวคิดการหา Transfer Function นอกจากใช้ได้กับ Load Cell แล้วยังสามารถใช้แนวคิดนี้กับเซนเซอร์อื่นได้ เพื่อแปลงสัญญาณทางไฟฟ้าเป็นปริมาณที่สนใจได้

Load Cell Calibration & Sensitivityการสอบเทียบโหลดเซลล์และ Sensitivity
Connectingการเชื่อมต่อ (Connecting)
Serial read:ข้อมูลที่อ่านจาก Serial:
string —
number
—
Sensor value with moving average:ค่าเซนเซอร์ที่เฉลี่ยแบบเคลื่อนที่ (Sensor value with moving average):
—
SD:
—
Weight (g)น้ำหนัก (Weight, g)
Weight (g):น้ำหนัก (g):
—
SD:
—
Settingการตั้งค่า (Setting)
Calibration tableตาราง Calibration (Calibration table)
N True weight (W, g)น้ำหนักจริง (W, g) Sensor value (L, ADC level)ค่าเซนเซอร์ (L, ADC level)
1
2
3
4
Transfer function (equation):Transfer function (สมการ):
L = mW + c
Invers transfer function:Invers transfer function (สมการผกผัน):
W = (1/m)L − (c/m)

Referencesเอกสารอ้างอิง

  1. "HX711 Arduino Library," ver. 0.7.5, GitHub. [Online]. Available: https://github.com/bogde/HX711
  2. C. Slattery and M. Nie, "A reference design for high-performance, low-cost weigh scales," Analog Dialogue, vol. 39, Dec. 2005. Accessed: Sep. 28, 2026. [Online]. Available: https://www.analog.com/en/resources/analog-dialogue/articles/a-reference-design-for-weigh-scales.html
  3. R. C. Hibbeler, Mechanics of Materials, 8th ed. Upper Saddle River, NJ, USA: Prentice Hall, 2011, chs. 1–3.