What is the simpelest way to read HX711 data?

Hi,

I finally have my ATTiny85 board running (blink sketch) so now for my project. I want to write output pin 1 high above a certain weight on a load cell, and low below that weight. Easy, right? Well, looking at many weighcell projects online, I find people make very nice but very complicated projects. I want to read the value it is sending, which can just be the 0 to 16777215 (24 bit) value. Simple if value is above X, digitalWrite pin 1 high, else digitalWrite pin 1 low. But how can I do that 'simple' readout? I don't need to tare, don't need to convert to grams, etc.

Thanks,

Hugo

Hi Hugo,
scale.read() gives you the raw value. Then you just put in into if cycle

Regards

Jiri

#include "HX711.h"

const int LOADCELL_DOUT_PIN = 2;
const int LOADCELL_SCK_PIN = 3;
const int limitValue = 100000; //trigger value for the switch
const int switchPin = 5; //digital out pin

HX711 scale;

void setup() {
  pinMode(switchPin, OUTPUT);
  
  Serial.begin(57600);
  scale.begin(LOADCELL_DOUT_PIN, LOADCELL_SCK_PIN);
}

void loop() {

  if (scale.is_ready()) {
    long reading = scale.read();
    Serial.print("HX711 reading: ");
    Serial.println(reading);
    if (reading >= limitValue){
      digitalWrite(switchPin, HIGH);   // turn the PIN on (HIGH is the voltage level)
      } else {
       digitalWrite(switchPin, LOW);    // turn the PIN off by making the voltage LOW
       delay(1000);
    }
  } else {
    Serial.println("HX711 not found.");
  }

  delay(1000);
  
}

Marvelous, thank you. And your timing is impeccable, I am just now checking the forum in my break-time.

Thanks!

Hugo

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.