Reading raw load cell data

I'm trying to interface a load cell, and am using a digital amplifier. I'd like to apply my own filters to the data, and want to read the raw binary output from the load cell. I'm having trouble because I'm reading negative load cell values (so clearly not binary). I've tried zeroing the offset to no avail. Thanks.

Hi pdx16.

You've not provided much to go on. Without knowing what digital amplifier and general connection information the forum will not be able to help you much.


I'm trying to get raw load cell readings in binary with a load cell and load cell amp (HX711) connected to my Arduino. In theory, the measurable values should have a range of 0 to 16777215 (24 bit readings). The library for the HX711 originally allowed for both compression and tension measurements (so you could read "negative" readings with the load cell). I'd like to get only positive readings in the range mentioned above.

However, I'm having an interesting problem where, when the load cell is compressed, the read values decrease and then jump back up to 16777215 immediately, instead of staying at zero. I've tried connecting the load cell to an oscilliscope and the load cell on its own is functioning correctly. Here's the portion of the cpp file that deals with the read function where I believe the problem is:

long HX711::read() {
// wait for the chip to become ready
while (!is_ready()) {
// Will do nothing on Arduino but prevent resets of ESP8266 (Watchdog Issue)

unsigned long value = 0;
uint8_t data[3] = { 0 };
uint8_t filler = 0x00;

// pulse the clock pin 24 times to read the data
data[2] = shiftIn(DOUT, PD_SCK, MSBFIRST);
data[1] = shiftIn(DOUT, PD_SCK, MSBFIRST);
data[0] = shiftIn(DOUT, PD_SCK, MSBFIRST);

// set the channel and the gain factor for the next reading using the clock pin
for (unsigned int i = 0; i < GAIN; i++) {
digitalWrite(PD_SCK, HIGH);
digitalWrite(PD_SCK, LOW);

// Replicate the most significant bit to pad out a 32-bit signed integer
if (data[2] & 0x80) {
filler = 0xFF;
} else {
filler = 0x00;

// Construct a 32-bit signed integer
value = ( static_cast<unsigned long>(filler) << 24
| static_cast<unsigned long>(data[2]) << 16
| static_cast<unsigned long>(data[1]) << 8
| static_cast<unsigned long>(data[0]) );

return static_cast<long>(value);

I've also tried setting filler=0X00 (getting around the if loop), which makes all the numbers positive, but creates the same looping problem.


Thanks Jon--I appreciate the input. I'm new, and that's helpful for the future. I'll be sure to add more detail to my next post.


@pdx16, please do not cross-post. Threads merged.

The HX711 outputs a signed 24 bit value (2's complement), ie -8388608 to 8388607

Treat the output as signed and all is well, it doesn't do unsigned.