Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can you get more than one calibration factor? #136

Closed
chaba34 opened this issue Nov 15, 2024 · 5 comments
Closed

How can you get more than one calibration factor? #136

chaba34 opened this issue Nov 15, 2024 · 5 comments
Labels

Comments

@chaba34
Copy link

chaba34 commented Nov 15, 2024

Hi!
I'm a bloody beginner with arduino and programming, so I'm really interested in recommendations in order to learn new stuff.
Thank you so much for providing this library and the examples!
I'd like to measure weight using a setup with an uno R3, the hx711 and a load cell (range:0-50kg)
Unfortunatly, my project requires precise and on long term reliable values.
The problem is that using only one value with a given mass could result in poor measurement performance.
So I'd like to use at least three weights to calibrate the cell.

Now, how can this be implemented in the calibration code?
Also, should I, after getting those calibration-values, implement those in the "measure - code" using switch case* or is it better to plot those values and use a linear approximation in order to use an average calibration factor for the complete range of the cell?

*E.g. obtained 3 cal.- values for 10kg, 25kg and 45kg. Then in the code use for the range 0-10kg value 1, for 10-25kg value 2 and value 3 for the rest of the range..

@olkal
Copy link
Owner

olkal commented Nov 15, 2024

hi

Calibration code: easiest is to use the code more or less as is, but repeating the process n times to get the calibration factors at each calibration point.

In the main sketch I would get the data from HX711 using cal factor 1.0. Then based on the data value decide which calibration range the data falls in to (range 1, 2, 3 or 4). Interpolate the calibration factors e.g. for 0-10 kg use value1, for 10-25kg use (value1+value2)/2, for 25-45kg (value2+value3)/2, for 45kg+ use value 3, and then divide the data value with the interpolated calibration value.

@chaba34
Copy link
Author

chaba34 commented Nov 15, 2024

Hi! Thanks for your fast response!
That sounds like a very good idea!
Do you think implenenting the calibration values using switch case in the code(like the Read_1x_load_cell.ino), would be a good idea?

@olkal
Copy link
Owner

olkal commented Nov 15, 2024

Hi!
Using switch case vs. if/else is often a matter of taste, switch case is easy to read and fine for deciding an action from multiple exact integer values, but if/else is more flexible and probably what you want for this. For example, for the code below is it's better to use if/else:

if ((myData >= 0) && (myData <= 1000)) {
  // do something
} 
else if ((myData > 1000) && (myData <= 2000)) {
  // do something else
}

Copy link

This issue is stale because it has been open for 30 days with no activity.

@github-actions github-actions bot added the stale label Dec 16, 2024
Copy link

This issue was closed because it has been inactive for 14 days since being marked as stale.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants