Skip to content

Instantly share code, notes, and snippets.

@fxprime
Created August 7, 2026 02:51
Show Gist options
  • Select an option

  • Save fxprime/7901179fc0a92183bc46c57e3263587e to your computer and use it in GitHub Desktop.

Select an option

Save fxprime/7901179fc0a92183bc46c57e3263587e to your computer and use it in GitHub Desktop.
ads1232 loadcell amp 24bit not yet test
#define _dout 6
#define _sclk 7
#define _pdwn 8
#include "ADS1232.h"
ADS1232 weight = ADS1232(_pdwn, _sclk, _dout);
void do_calibration() {
long t_new_offset = 0;
long t_raw_read = 0;
float t_set_scale_value = 0;
float t_weight = 0;
// Reset to default values
weight.OFFSET = 0;
weight.SCALE = 1.0;
// Tare: read baseline offset (empty scale)
t_new_offset = weight.raw_read(3);
weight.OFFSET = t_new_offset;
Serial.print("Calibration offset = ");
Serial.println(weight.OFFSET);
Serial.println("You have 10 seconds to put a 2L CocaCola bottle on scale...");
delay(10000);
// Read raw value with 2kg load
t_raw_read = weight.raw_read(3);
Serial.print("Units read = ");
Serial.println(t_raw_read);
// Calculate SCALE using NET raw counts (Loaded value - Offset) divided by known weight (2.0 kg)
t_set_scale_value = (float)(t_raw_read - t_new_offset) / 2.0; // Divide by the weight of the CocaCola bottle (2 kg)
weight.SCALE = t_set_scale_value;
Serial.print("Calibration scale value = ");
Serial.println(weight.SCALE);
// Read calibrated weight
t_weight = weight.units_read(3);
Serial.print("Weight = ");
Serial.println(t_weight);
}
void setup() {
Serial.begin(9600);
weight.power_up();
do_calibration();
}
void loop() {
Serial.println(weight.units_read(3));
delay(1000);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment