Skip to content

Commit

Permalink
1.2.10
Browse files Browse the repository at this point in the history
  • Loading branch information
olkal committed Nov 20, 2021
1 parent e1bc08a commit bb97935
Show file tree
Hide file tree
Showing 10 changed files with 21 additions and 4 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Latest release and change log here: https://github.com/olkal/HX711_ADC/releases

This an Arduino library for the HX711 24-bit ADC for weight scales.
Data retrieval from the HX711 is done without halting the mcu, also on the 10SPS rate setting and with Multiple HX711's performing conversions simultaneously.
Tare function can also be performed without halting the mcu.
Data retrieval from the HX711 is done without blocking the mcu, also on the 10SPS rate setting and with Multiple HX711's performing conversions simultaneously.
Tare function can also be performed without blocking the mcu.

Filtering and smoothing: "Moving average" method from a rolling data set combined with removal of high/low outliers is used for the retrieved value.

Expand Down
1 change: 1 addition & 0 deletions examples/Calibration/Calibration.ino
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ void setup() {
Serial.println("Starting...");

LoadCell.begin();
//LoadCell.setReverseVal(); //uncomment to turn a negative output value to positive
unsigned long stabilizingtime = 2000; // preciscion right after power-up can be improved by adding a few seconds of stabilizing time
boolean _tare = true; //set this to false if you don't want tare to be performed in the next step
LoadCell.start(stabilizingtime, _tare);
Expand Down
1 change: 1 addition & 0 deletions examples/Persistent_zero_offset/Persistent_zero_offset.ino
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ void setup() {
Serial.println("Starting...");

LoadCell.begin();
//LoadCell.setReverseVal(); //uncomment to turn a negative output value to positive
float calibrationValue; // calibration value (see example file "Calibration.ino")
calibrationValue = 696.0; // uncomment this if you want to set the calibration value in the sketch

Expand Down
1 change: 1 addition & 0 deletions examples/Read_1x_load_cell/Read_1x_load_cell.ino
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ void setup() {
Serial.println("Starting...");

LoadCell.begin();
//LoadCell.setReverseVal(); //uncomment to turn a negative output value to positive
float calibrationValue; // calibration value (see example file "Calibration.ino")
calibrationValue = 696.0; // uncomment this if you want to set the calibration value in the sketch
#if defined(ESP8266)|| defined(ESP32)
Expand Down
2 changes: 2 additions & 0 deletions examples/Read_2x_load_cell/Read_2x_load_cell.ino
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ void setup() {

LoadCell_1.begin();
LoadCell_2.begin();
//LoadCell_1.setReverseVal(); //uncomment to turn a negative output value to positive
//LoadCell_2.setReverseVal(); //uncomment to turn a negative output value to positive
unsigned long stabilizingtime = 2000; // tare preciscion can be improved by adding a few seconds of stabilizing time
boolean _tare = true; //set this to false if you don't want tare to be performed in the next step
byte loadcell_1_rdy = 0;
Expand Down
1 change: 1 addition & 0 deletions examples/Testing/Testing.ino
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ void setup() {
//EEPROM.get(calVal_eepromAdress, calibrationValue); // uncomment this if you want to fetch this value from eeprom

LoadCell.begin();
//LoadCell.setReverseVal(); //uncomment to turn a negative output value to positive
unsigned long stabilizingtime = 2000; // tare preciscion can be improved by adding a few seconds of stabilizing time
boolean _tare = true; //set this to false if you don't want tare to be performed in the next step
LoadCell.start(stabilizingtime, _tare);
Expand Down
2 changes: 1 addition & 1 deletion keywords.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ refreshDataSet KEYWORD2
getDataSetStatus KEYWORD2
getNewCalibration KEYWORD2
getSignalTimeoutFlag KEYWORD2

setReverseVal KEYWORD2


#######################################
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=HX711_ADC
version=1.2.9
version=1.2.10
author=Olav Kallhovd
maintainer=Olav Kallhovd
sentence=Library for the HX711 24-bit ADC for weight scales.
Expand Down
9 changes: 9 additions & 0 deletions src/HX711_ADC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,9 @@ void HX711_ADC::conversion24bit() //read 24 bit data, store in dataset and star
dataOutOfRange = 1;
//Serial.println("dataOutOfRange");
}
if (reverseVal) {
data = 0xFFFFFF - data;
}
if (readIndex == samplesInUse + IGN_HIGH_SAMPLE + IGN_LOW_SAMPLE - 1)
{
readIndex = 0;
Expand Down Expand Up @@ -505,3 +508,9 @@ bool HX711_ADC::getSignalTimeoutFlag()
{
return signalTimeoutFlag;
}

//reverse the output value (flip positive/negative value)
//tare/zero-offset must be re-set after calling this.
void HX711_ADC::setReverseVal() {
reverseVal = true;
}
2 changes: 2 additions & 0 deletions src/HX711_ADC.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ class HX711_ADC
bool getDataSetStatus(); //returns 'true' when the whole dataset has been filled up with conversions, i.e. after a reset/restart
float getNewCalibration(float known_mass); //returns and sets a new calibration value (calFactor) based on a known mass input
bool getSignalTimeoutFlag(); //returns 'true' if it takes longer time then 'SIGNAL_TIMEOUT' for the dout pin to go low after a new conversion is started
void setReverseVal(); //reverse the output value

protected:
void conversion24bit(); //if conversion is ready: returns 24 bit data and starts the next conversion
Expand Down Expand Up @@ -114,6 +115,7 @@ class HX711_ADC
bool dataOutOfRange = 0;
unsigned long lastDoutLowTime = 0;
bool signalTimeoutFlag = 0;
bool reverseVal = 0;
};

#endif
Expand Down

0 comments on commit bb97935

Please sign in to comment.