Skip to content

Commit 4efd4be

Browse files
committed
1.2.6
1 parent 36b4815 commit 4efd4be

File tree

8 files changed

+22
-28
lines changed

8 files changed

+22
-28
lines changed

examples/Calibration/Calibration.ino

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,15 @@ const int HX711_sck = 5; //mcu > HX711 sck pin
2929
HX711_ADC LoadCell(HX711_dout, HX711_sck);
3030

3131
const int calVal_eepromAdress = 0;
32-
long t;
32+
unsigned long t = 0;
3333

3434
void setup() {
3535
Serial.begin(57600); delay(10);
3636
Serial.println();
3737
Serial.println("Starting...");
3838

3939
LoadCell.begin();
40-
long stabilizingtime = 2000; // preciscion right after power-up can be improved by adding a few seconds of stabilizing time
40+
unsigned long stabilizingtime = 2000; // preciscion right after power-up can be improved by adding a few seconds of stabilizing time
4141
boolean _tare = false; //set this to false if you don't want tare to be performed in the next step
4242
LoadCell.start(stabilizingtime, _tare);
4343
if (LoadCell.getTareTimeoutFlag() || LoadCell.getSignalTimeoutFlag()) {
@@ -72,7 +72,6 @@ void loop() {
7272

7373
// receive command from serial terminal
7474
if (Serial.available() > 0) {
75-
float i;
7675
char inByte = Serial.read();
7776
if (inByte == 't') LoadCell.tareNoDelay(); //tare
7877
else if (inByte == 'r') calibrate(); //calibrate
@@ -98,7 +97,6 @@ void calibrate() {
9897
LoadCell.update();
9998
if (Serial.available() > 0) {
10099
if (Serial.available() > 0) {
101-
float i;
102100
char inByte = Serial.read();
103101
if (inByte == 't') LoadCell.tareNoDelay();
104102
}

examples/Read_1x_load_cell/Read_1x_load_cell.ino

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ const int HX711_sck = 5; //mcu > HX711 sck pin
2929
HX711_ADC LoadCell(HX711_dout, HX711_sck);
3030

3131
const int calVal_eepromAdress = 0;
32-
long t;
32+
unsigned long t = 0;
3333

3434
void setup() {
3535
Serial.begin(57600); delay(10);
@@ -44,7 +44,7 @@ void setup() {
4444
#endif
4545
//EEPROM.get(calVal_eepromAdress, calibrationValue); // uncomment this if you want to fetch the calibration value from eeprom
4646

47-
long stabilizingtime = 2000; // preciscion right after power-up can be improved by adding a few seconds of stabilizing time
47+
unsigned long stabilizingtime = 2000; // preciscion right after power-up can be improved by adding a few seconds of stabilizing time
4848
boolean _tare = true; //set this to false if you don't want tare to be performed in the next step
4949
LoadCell.start(stabilizingtime, _tare);
5050
if (LoadCell.getTareTimeoutFlag()) {
@@ -77,7 +77,6 @@ void loop() {
7777

7878
// receive command from serial terminal, send 't' to initiate tare operation:
7979
if (Serial.available() > 0) {
80-
float i;
8180
char inByte = Serial.read();
8281
if (inByte == 't') LoadCell.tareNoDelay();
8382
}

examples/Read_1x_load_cell_interrupt_driven/Read_1x_load_cell_interrupt_driven.ino

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ const int HX711_sck = 5; //mcu > HX711 sck pin
2828
HX711_ADC LoadCell(HX711_dout, HX711_sck);
2929

3030
const int calVal_eepromAdress = 0;
31-
long t;
31+
unsigned long t = 0;
3232
volatile boolean newDataReady;
3333

3434
void setup() {
@@ -44,7 +44,7 @@ void setup() {
4444
//EEPROM.get(calVal_eepromAdress, calibrationValue); // uncomment this if you want to fetch the value from eeprom
4545

4646
LoadCell.begin();
47-
long stabilizingtime = 2000; // tare preciscion can be improved by adding a few seconds of stabilizing time
47+
unsigned long stabilizingtime = 2000; // tare preciscion can be improved by adding a few seconds of stabilizing time
4848
boolean _tare = true; //set this to false if you don't want tare to be performed in the next step
4949
LoadCell.start(stabilizingtime, _tare);
5050
if (LoadCell.getTareTimeoutFlag()) {
@@ -84,7 +84,6 @@ void loop() {
8484

8585
// receive command from serial terminal, send 't' to initiate tare operation:
8686
if (Serial.available() > 0) {
87-
float i;
8887
char inByte = Serial.read();
8988
if (inByte == 't') LoadCell.tareNoDelay();
9089
}

examples/Read_2x_load_cell/Read_2x_load_cell.ino

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ HX711_ADC LoadCell_2(HX711_dout_2, HX711_sck_2); //HX711 2
2323

2424
const int calVal_eepromAdress_1 = 0; // eeprom adress for calibration value load cell 1 (4 bytes)
2525
const int calVal_eepromAdress_2 = 4; // eeprom adress for calibration value load cell 2 (4 bytes)
26-
long t;
26+
unsigned long t = 0;
2727

2828
void setup() {
2929
Serial.begin(57600); delay(10);
@@ -43,7 +43,7 @@ void setup() {
4343

4444
LoadCell_1.begin();
4545
LoadCell_2.begin();
46-
long stabilizingtime = 2000; // tare preciscion can be improved by adding a few seconds of stabilizing time
46+
unsigned long stabilizingtime = 2000; // tare preciscion can be improved by adding a few seconds of stabilizing time
4747
boolean _tare = true; //set this to false if you don't want tare to be performed in the next step
4848
byte loadcell_1_rdy = 0;
4949
byte loadcell_2_rdy = 0;
@@ -86,7 +86,6 @@ void loop() {
8686

8787
// receive command from serial terminal, send 't' to initiate tare operation:
8888
if (Serial.available() > 0) {
89-
float i;
9089
char inByte = Serial.read();
9190
if (inByte == 't') {
9291
LoadCell_1.tareNoDelay();

examples/Testing/Testing.ino

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ const int HX711_sck = 7; //mcu > HX711 sck pin
2929
HX711_ADC LoadCell(HX711_dout, HX711_sck);
3030

3131
const int calVal_calVal_eepromAdress = 0;
32-
long t;
32+
unsigned long t = 0;
3333

3434
void setup() {
3535
Serial.begin(57600); delay(10);
@@ -44,7 +44,7 @@ void setup() {
4444
//EEPROM.get(calVal_eepromAdress, calibrationValue); // uncomment this if you want to fetch this value from eeprom
4545

4646
LoadCell.begin();
47-
long stabilizingtime = 2000; // tare preciscion can be improved by adding a few seconds of stabilizing time
47+
unsigned long stabilizingtime = 2000; // tare preciscion can be improved by adding a few seconds of stabilizing time
4848
boolean _tare = true; //set this to false if you don't want tare to be performed in the next step
4949
LoadCell.start(stabilizingtime, _tare);
5050
if (LoadCell.getTareTimeoutFlag()) {
@@ -92,7 +92,6 @@ void loop() {
9292

9393
// receive command from serial terminal, send 't' to initiate tare operation:
9494
if (Serial.available() > 0) {
95-
float i;
9695
char inByte = Serial.read();
9796
if (inByte == 't') LoadCell.tareNoDelay();
9897
}

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=HX711_ADC
2-
version=1.2.5
2+
version=1.2.6
33
author=Olav Kallhovd
44
maintainer=Olav Kallhovd
55
sentence=Library for the HX711 24-bit ADC for weight scales.

src/HX711_ADC.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ void HX711_ADC::begin(uint8_t gain)
4444
/* start(t):
4545
* will do conversions continuously for 't' +400 milliseconds (400ms is min. settling time at 10SPS).
4646
* Running this for 1-5s in setup() - before tare() seems to improve the tare accuracy */
47-
void HX711_ADC::start(unsigned int t)
47+
void HX711_ADC::start(unsigned long t)
4848
{
4949
t += 400;
5050
lastDoutLowTime = millis();
@@ -60,7 +60,7 @@ void HX711_ADC::start(unsigned int t)
6060
/* start(t, dotare) with selectable tare:
6161
* will do conversions continuously for 't' +400 milliseconds (400ms is min. settling time at 10SPS).
6262
* Running this for 1-5s in setup() - before tare() seems to improve the tare accuracy. */
63-
void HX711_ADC::start(unsigned int t, bool dotare)
63+
void HX711_ADC::start(unsigned long t, bool dotare)
6464
{
6565
t += 400;
6666
lastDoutLowTime = millis();
@@ -79,7 +79,7 @@ void HX711_ADC::start(unsigned int t, bool dotare)
7979
/* startMultiple(t): use this if you have more than one load cell and you want to do tare and stabilization simultaneously.
8080
* Will do conversions continuously for 't' +400 milliseconds (400ms is min. settling time at 10SPS).
8181
* Running this for 1-5s in setup() - before tare() seems to improve the tare accuracy */
82-
int HX711_ADC::startMultiple(unsigned int t)
82+
int HX711_ADC::startMultiple(unsigned long t)
8383
{
8484
tareTimeoutFlag = 0;
8585
lastDoutLowTime = millis();
@@ -128,7 +128,7 @@ int HX711_ADC::startMultiple(unsigned int t)
128128
* use this if you have more than one load cell and you want to (do tare and) stabilization simultaneously.
129129
* Will do conversions continuously for 't' +400 milliseconds (400ms is min. settling time at 10SPS).
130130
* Running this for 1-5s in setup() - before tare() seems to improve the tare accuracy */
131-
int HX711_ADC::startMultiple(unsigned int t, bool dotare)
131+
int HX711_ADC::startMultiple(unsigned long t, bool dotare)
132132
{
133133
tareTimeoutFlag = 0;
134134
lastDoutLowTime = millis();
@@ -171,6 +171,7 @@ int HX711_ADC::startMultiple(unsigned int t, bool dotare)
171171
}
172172
}
173173
}
174+
else return 1;
174175
}
175176
}
176177
return startStatus;
@@ -422,7 +423,6 @@ long HX711_ADC::getSettlingTime()
422423
void HX711_ADC::setSamplesInUse(int samples)
423424
{
424425
int old_value = samplesInUse;
425-
int old_divbit = divBit;
426426

427427
if(samples <= SAMPLES)
428428
{

src/HX711_ADC.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,10 @@ class HX711_ADC
5454
void setGain(uint8_t gain = 128); //value must be 32, 64 or 128*
5555
void begin(); //set pinMode, HX711 gain and power up the HX711
5656
void begin(uint8_t gain); //set pinMode, HX711 selected gain and power up the HX711
57-
void start(unsigned int t); //start HX711 and do tare
58-
void start(unsigned int t, bool dotare); //start HX711, do tare if selected
59-
int startMultiple(unsigned int t); //start and do tare, multiple HX711 simultaniously
60-
int startMultiple(unsigned int t, bool dotare); //start and do tare if selected, multiple HX711 simultaniously
57+
void start(unsigned long t); //start HX711 and do tare
58+
void start(unsigned long t, bool dotare); //start HX711, do tare if selected
59+
int startMultiple(unsigned long t); //start and do tare, multiple HX711 simultaniously
60+
int startMultiple(unsigned long t, bool dotare); //start and do tare if selected, multiple HX711 simultaniously
6161
void tare(); //zero the scale, wait for tare to finnish (blocking)
6262
void tareNoDelay(); //zero the scale, initiate the tare operation to run in the background (non-blocking)
6363
bool getTareStatus(); //returns 'true' if tareNoDelay() operation is complete
@@ -102,8 +102,8 @@ class HX711_ADC
102102
const uint8_t divBitCompiled = DIVB;
103103
bool doTare;
104104
bool startStatus;
105-
long startMultipleTimeStamp;
106-
long startMultipleWaitTime;
105+
unsigned long startMultipleTimeStamp;
106+
unsigned long startMultipleWaitTime;
107107
uint8_t convRslt;
108108
bool tareStatus;
109109
unsigned int tareTimeOut = (SAMPLES + IGN_HIGH_SAMPLE + IGN_HIGH_SAMPLE) * 150; // tare timeout time in ms, no of samples * 150ms (10SPS + 50% margin)

0 commit comments

Comments
 (0)