// Just a sample project to learn how to make an electronic scale using an ESP32 and HX711 load cell
#include <Arduino.h>
#include "soc/rtc.h"
#include "HX711.h"
const int LOADCELL_DOUT_PIN = 16;
const int LOADCELL_SCK_PIN = 4;
HX711 scale;
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
rtc_cpu_freq_config_t config;
rtc_clk_cpu_freq_get_config(&config);
rtc_clk_cpu_freq_to_config(RTC_CPU_FREQ_80M, &config);
rtc_clk_cpu_freq_set_config_fast(&config);
scale.begin(LOADCELL_DOUT_PIN, LOADCELL_SCK_PIN);
}
void loop() {
// put your main code here, to run repeatedly:
if (scale.is_ready()) {
scale.set_scale();
Serial.println("Taring... Remove any weights from the scale.");
delay(5000);
scale.tare();
Serial.println("Place a weight on the scale");
delay(5000);
long reading = scale.get_units(10);
Serial.print("Result: ");
Serial.println(reading);
}
else {
Serial.println("HX711 not found");
}
delay(1000);
}