Skip to content

Commit

Permalink
use lib for offset
Browse files Browse the repository at this point in the history
  • Loading branch information
superpenguin612 committed Nov 6, 2024
1 parent 2dfaeb1 commit 9d5b296
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ void HX711_Bus::init() {
// if (encs[i].is_ready()) {
// encs[i].tare();
// }
encs[i].set_offset(ZERO_POINT[i]);
encs[i].set_gain(HX711_CHANNEL_A_GAIN_128);
encs[i].set_scale(SCALE_CALIBRATION[i]);
}
Expand All @@ -250,7 +251,7 @@ float HX711_Bus::read_scale(uint8_t id) {
if (encs[id].is_ready()) {
// since we could start with weight on the load cell, manually subtract zero point instead of
// taring
float val = encs[id].read() - 8142300F;
float val = encs[id].get_value(1);
// if load cell is not returning any data, but HX711 is connected
if (val == 0)
return -1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,9 @@ class HX711_Bus {
private:
static constexpr int NUM_SENSORS = 2;
static constexpr int PIN_LIST[NUM_SENSORS * 2] = {27, 26, 29, 28};
static constexpr float ZERO_POINT[NUM_SENSORS] = {8143500, 8143500};
static constexpr float SCALE_CALIBRATION[NUM_SENSORS] = {-24.111,
-24.111}; // TODO, calibrate these
static constexpr float ZERO_POINT[NUM_SENSORS] = {8143500f, 8143500f};
static constexpr float SCALE_CALIBRATION[NUM_SENSORS] = {-24.111f,
-24.111f}; // TODO, calibrate these

static HX711 encs[NUM_SENSORS];
};
Expand Down

0 comments on commit 9d5b296

Please sign in to comment.