We have a problem. Everytime anyone type in load cell arduino
, it's always return HX711. I mean, it works if you don't need accuracy just a ball park figure as a trigger for other things, say like a pet feeder. If weight less than 50g, move servo to X until weight is more than 100g. Then it doesn't matter, you might feed 20g more food to your dog. However, for more interesting projects, say a smart cutting board that can weight things according to ingredients listed on your phone, then HX711 is definitely not good enough.
Enters ADS1232, while it is more expensive than HX711, it is not prohibitively so. And the datasheet is quite overwhelming for most. It is not like using HX711 where you plug one end to the load cell and the other end to the micro controller, drop in a library and BAM you've got weighs. So, let's make it like that.
Pictured on top is the simplest form of the ADS1232. On the left side, blob together CLKIN, A0, TEMP, and GND. Then bridge GND across to another GND. Bridge across 3.3V and 5V, then link GAIN0, GAIN1, SPEED, and REFP to 5V. That's it, the ADS1232 is ready to be used like HX711.
- PDMN, DOUT, and SCLK connect to 3 pins on your µC.
- VCC and GND out of µC are connected to both the ADS1232 and load cell excitation voltage (red and black).
- Load cells signal voltage (green and white) connected to AINP1 and AINN1 on ADS1232.
On this mode, you'll need to use my simplified library for Whey. Just download and drop in the ads1232.h
and ads1232.cpp
onto Arduino IDE.
That's it, you can now use ADS1232 like HX711. Next let's dive a bit deeper so we can use this 24-bit analog to digital converter much better.
- You'll need 4 more pins out of your µC for A0, GAIN0, GAIN1, SPEED.
- SPEED pins is how you control the reading samples rate. Set it LOW for 10 samples per seconds, and HIGH for 80 samples per seconds.
- Gains:
- 1x: GAIN0 and GAIN1 to LOW
- 2x: GAIN0 to HIGH, and GAIN1 to LOW
- 64x: GAIN0 to LOW, and GAIN1 to HIGH
- 128x: GAIN0 and GAIN1 to HIGH
- A0 is used to read the second channel. LOW reads channel 1 (AINP1 and AINN1). HIGH reads channel 2 (AINP2 and AINN2).
IMO, these things can be decided prior to soldering things together and simplified your schema. Now that the ADS1232 has been configure, let's get some data out of it.
- Power it up: set PDMN pin to LOW and SCLK to HIGH. Reverse values to power down.
- Wait until new data is ready: wait until DOUT change from LOW to HIGH and back to LOW.
- Next you just need to read the raw 24-bit data. Refer to the library if needed.
Once you have the raw data, it's basically done. To calibrate the scale:
- Prepare a known weight, say 100g weight. But don't put it on the weight.
- Reset the calibration value
SCALE
value to 1. - Read and store the value to
OFFSET
. It's to tare off your platform - Put on the known weight.
- Read the
value
again. Now you can get the new calibration value. SCALE = (value - OFFSET) / 100
, if the known weight is 100g.- Store the
SCALE
value to EEPROM.
Bonus: if you expose all those pins to Arduino, you'd better use the original library by HammidSaffari, it's just plug and play.