Upload files to "libraries/HX711/examples/HX_performance"

This commit is contained in:
2026-01-14 14:29:48 -05:00
parent d930cfd3e7
commit 5c9a753955
4 changed files with 202 additions and 0 deletions

View File

@@ -0,0 +1,108 @@
//
// FILE: HX_performance.ino
// AUTHOR: Rob Tillaart
// PURPOSE: HX711 performance measurements
// URL: https://github.com/RobTillaart/HX711
#include "HX711.h"
HX711 scale;
// adjust pins if needed
uint8_t dataPin = 6;
uint8_t clockPin = 7;
uint32_t start, stop;
volatile float f;
void setup()
{
Serial.begin(115200);
Serial.println();
Serial.println(__FILE__);
Serial.print("HX711_LIB_VERSION: ");
Serial.println(HX711_LIB_VERSION);
Serial.println();
scale.begin(dataPin, clockPin);
Serial.println("\nUNCONFIGURED");
delay(1000);
measure(10);
// TODO find a nice solution for this calibration..
// load cell factor 20 KG
// scale.set_scale(127.15);
// load cell factor 5 KG
scale.set_scale(420.0983); // TODO you need to calibrate this yourself.
// reset the scale to zero = 0
scale.tare();
Serial.println("\nCONFIGURED");
delay(1000);
measure(10);
Serial.println("\nSLEEP");
scale.power_down();
delay(2000);
scale.power_up();
Serial.println("\nWAKE UP");
delay(1000);
measure(10);
/*
* PERFORMANCE
* 100x get_units(1) = 9404352 (UNO)
* VAL: 0.05
*/
Serial.println("\nPERFORMANCE");
delay(10);
start = micros();
f = 0;
for (int i = 0; i < 100; i++)
{
f = scale.get_units(1);
}
stop = micros();
Serial.print("100x get_units(1) = ");
Serial.println(stop - start);
Serial.print(" VAL: ");
Serial.println(f, 2);
Serial.println("\nPRECISION");
f = 0;
for (int i = 0; i < 100; i++)
{
f += scale.get_units(1);
}
Serial.print(" VAL:");
Serial.println(f * 0.01, 4);
}
void loop()
{
// continuous scale 4x per second
// f = scale.get_units(5);
// Serial.println(f);
// delay(250);
}
void measure(uint8_t cnt)
{
Serial.print(" RAW: ");
Serial.println(scale.read());
Serial.print(" AVG: ");
Serial.println(scale.read_average(cnt));
Serial.print("VALUE: ");
Serial.println(scale.get_value(cnt));
Serial.print("UNITS: ");
Serial.println(scale.get_units(cnt), 1);
}
// -- END OF FILE --

View File

@@ -0,0 +1,29 @@
LIBRARY VERSION: 0.3.1
UNCONFIGURED
RAW: 0.00
AVG: 0.00
VALUE: 0.00
UNITS: 0.0
CONFIGURED
RAW: 0.00
AVG: 0.00
VALUE: 0.00
UNITS: 0.0
SLEEP
WAKE UP
RAW: 0.00
AVG: 0.00
VALUE: 0.00
UNITS: 0.0
PERFORMANCE
100x get_units(1) = 41164
VAL: 0.00
PRECISSION
VAL:0.0000

View File

@@ -0,0 +1,31 @@
(UNO)
LIBRARY VERSION: 0.3.2
UNCONFIGURED
RAW: 0.00
AVG: 0.00
VALUE: 0.00
UNITS: 0.0
CONFIGURED
RAW: 0.00
AVG: 0.00
VALUE: 0.00
UNITS: 0.0
SLEEP
WAKE UP
RAW: 0.00
AVG: 0.00
VALUE: 0.00
UNITS: 0.0
PERFORMANCE
100x get_units(1) = 40944
VAL: 0.00
PRECISSION
VAL:0.0000

View File

@@ -0,0 +1,34 @@
BOARD: UNO
IDE: 1.8.19
SKETCH: HX_performance.ino
LIBRARY VERSION: 0.3.4
UNCONFIGURED
RAW: 0.00
AVG: 0.00
VALUE: 0.00
UNITS: 0.0
CONFIGURED
RAW: 0.00
AVG: 0.00
VALUE: 0.00
UNITS: 0.0
SLEEP
WAKE UP
RAW: 0.00
AVG: 0.00
VALUE: 0.00
UNITS: 0.0
PERFORMANCE
100x get_units(1) = 40904
VAL: 0.00
PRECISION
VAL:0.0000