bogde / HX711

An Arduino library to interface the Avia Semiconductor HX711 24-Bit Analog-to-Digital Converter (ADC) for Weight Scales.
MIT License
896 stars 538 forks source link

Setting both HX711 channels (A+ / A- and B+ / B-) for using two load cells of 1kg in ESP32 #211

Open lherreraq2UC opened 3 years ago

lherreraq2UC commented 3 years ago

Hi guys, I'm using this code to implement one load cell of 1kg in esp32 (channels VSPI), but when I try to use HSPI pins (esp32), the code just doesn't run, so i trying to use both channels of HX711, but i don't know how to do it.

include "HX711.h"

const int LOADCELL_DOUT_PIN = 19; const int LOADCELL_SCK_PIN = 18; HX711 scale;

void setup() { Serial.begin(115200); scale.begin(LOADCELL_DOUT_PIN, LOADCELL_SCK_PIN); delay(250);

scale.set_scale(397); scale.tare(10); // Hacer 10 lecturas, el promedio es la tara } void loop() { if (scale.is_ready()) { float reading = scale.get_units(10); Serial.println(String(reading)+" gr"); } else Serial.println("HX711 not found."); delay(500); }

lherreraq2UC commented 3 years ago

Hey guys, I've been using this code, if I comment one of the two objects HX711 (internal or external), the measure works pretty well, I mean, using this by separate ways works, but using both load cells (internal and external) the measure is absolutely wrong.

include "HX711.h"

const int DT = 19; const int SCKL = 18;

HX711 internal; HX711 external;

void setup() {
Serial.begin(115200);

internal.begin(DT, SCKL); internal.set_gain(128); internal.set_scale(549.0); internal.tare(20);

delay(250);

external.begin(DT, SCKL); external.set_gain(32); external.set_scale(-16631.0); external.tare(20);

} void loop() {

Serial.print("Internal weight: "); Serial.print(internal.get_units(20),3); delay(2000); Serial.println(" gr");

delay(100);

Serial.print(""External weight: "); Serial.print(external.get_units(20),3); delay(2000); Serial.println(" gr");

Serial.println(""); }