Nanoshield_LoadCell

This is an Arduino library to measure weight using load cells reawith the ADS1230 IC from Texas Instruments.

Library features include:

  • Conversion to weight units, based on load cell capacity and sensitivity
  • Moving average filter, with configurable number of samples
  • Set zero weight point (tare)
  • Get measurement in weight units or raw 20-bit value
  • Continuous sampling using hardware timer (Timer 2)
  • ADS1230 offset calibration

Note: this library uses Timer 2 on the ATmega microcontroller, or Timer 5 on ATmega2560 and ATmega1280. On ATmega168 and ATmega328 (i.e. Arduino UNO or similar), usage of this library will interfere with the tone() function.

To install, just click Download ZIP and install it using Sketch > Include Library... > Add .ZIP Library in the Arduino IDE.

The following examples are provided:

Class Documentation

class Nanoshield_LoadCell

A LoadCell Nanoshield or similar module using the ADS1230 IC.

Public Functions

Nanoshield_LoadCell(float capacity, float sensitivity, int cs = 8, bool hiGain = true, int numSamples = LOADCELL_MAX_SAMPLES)

Constructor.

Creates an object to access one LoadCell Nanoshield. The constructor parameters must match the hardware configuration used.

See
begin()
Parameters
  • capacity: load cell capacity. Any measurement unit can be used.
  • sensitivity: load cell sensitivity, in mV/V.
  • cs: chip select pin matching the jumper selected on the board (D4, D7, etc.).
  • hiGain: true if operating in high gain mode (GAIN jumper closed), false if in low gain mode (GAIN jumper open).
  • numSamples: number of samples used in moving average filter. Minimum is one (no filtering) and maximum is LOADCELL_MAX_SAMPLES.

void begin(bool calibrate = true)

Initializes the module.

Initializes SPI, CS pin, Timer 2 interrupts and moving average circular buffer. Performs initial self-calibration if requested via the calibrate parameter.

Parameters
  • calibrate: if true, performs ADS1230 offset calibration during initialization.

bool updated()

Checks if a new load cell reading is available.

Return
true if a new load cell reading is available.

int32_t getValue()

Gets the current 20-bit value, filtered and offset-corrected.

Return
current load cell value.

int32_t getRawValue()

Gets the current 20-bit value, filtered but not offset-corrected.

Return
current load cell value without offset correction.

int32_t getLatestValue()

Gets the latest reading (unfiltered 20-bit value), offset-corrected.

Return
latest load cell value.

int32_t getLatestRawValue()

Gets the latest reading (unfiltered 20-bit value), offset-corrected.

Return
latest load cell value, without offset correction.

float getWeight()

Gets the weight, filtered and offset-corrected.

Return
current weight reading.

void setZero()

Sets the current value to be the zero-weight value (offset or tare).

void calibrate()

Performs ADS1230 offset calibration.


This documentation was built using ArduinoDocs.